BUGFIX: format;

This commit is contained in:
shahaibo
2023-10-20 14:47:18 +08:00
parent f18c27fe02
commit 9fa605f83e
134 changed files with 1345 additions and 1203 deletions

View File

@@ -20,25 +20,26 @@ public class FileProperties {
private String linuxDomain;
public ElPath getSys(){
public ElPath getSys() {
String os = System.getProperty("os.name");
if(os.toLowerCase().startsWith("win")) {
if (os.toLowerCase().startsWith("win")) {
return windows;
} else if(os.toLowerCase().startsWith("mac")){
} else if (os.toLowerCase().startsWith("mac")) {
return mac;
}
return linux;
}
public String getLinuxDomain(){
public String getLinuxDomain() {
String os = System.getProperty("os.name");
if((!os.toLowerCase().startsWith("win") )&& (!os.toLowerCase().startsWith("mac"))) {
if ((!os.toLowerCase().startsWith("win")) && (!os.toLowerCase().startsWith("mac"))) {
return linuxDomain;
}
return null;
}
@Data
public static class ElPath{
public static class ElPath {
private String path;
}
}

View File

@@ -18,10 +18,11 @@ public class MinIoClientConfig {
/**
* 注入minio 客户端
*
* @return
*/
@Bean
public MinioClient minioClient(){
public MinioClient minioClient() {
return MinioClient.builder()
.endpoint(endpoint)

View File

@@ -14,7 +14,7 @@ public class BusinessException extends RuntimeException {
private Integer code;
private String msg;
public BusinessException(ResultEnum resultEnum){
public BusinessException(ResultEnum resultEnum) {
super(resultEnum.getMsg());
this.code = resultEnum.getCode();
this.msg = resultEnum.getMsg();

View File

@@ -51,11 +51,12 @@ public class ExceptionCatch {
return Response.error(resultEnum.getCode(), resultEnum.getMsg());
}
}
return Response.error(ResultEnum.ERROR.getCode(), e.getMessage()==null?ResultEnum.ERROR.getMsg():e.getMessage());
return Response.error(ResultEnum.ERROR.getCode(), e.getMessage() == null ? ResultEnum.ERROR.getMsg() : e.getMessage());
}
/**
* 处理参数校验异常
*
* @param e
* @return ResponseData
*/
@@ -68,6 +69,7 @@ public class ExceptionCatch {
/**
* 处理参数校验异常
*
* @param e
* @return ResponseData
*/

View File

@@ -22,7 +22,7 @@ import java.util.function.Function;
**/
@Data
@Slf4j
public abstract class QueryCriteria<T,E> {
public abstract class QueryCriteria<T, E> {
private long page = 1;
private long limit = 10;
@@ -36,12 +36,12 @@ public abstract class QueryCriteria<T,E> {
this.mapper = mapper;
}
public QueryWrapper<T> buildWrapper(){
public QueryWrapper<T> buildWrapper() {
QueryWrapper<T> wrapper = new QueryWrapper<>();
Field[] fields = this.getClass().getDeclaredFields();
for (Field field : fields) {
Condition condition = field.getAnnotation(Condition.class);
if(condition != null){
if (condition != null) {
field.setAccessible(true);
Object value = null;
try {
@@ -49,27 +49,27 @@ public abstract class QueryCriteria<T,E> {
} catch (IllegalAccessException e) {
log.warn("reflection anomaly!");
}
if(!StrUtil.isEmptyIfStr(value)){
switch (condition.type()){
if (!StrUtil.isEmptyIfStr(value)) {
switch (condition.type()) {
case EQ:
wrapper.eq(ConvertUtil.humpToLine2(field.getName()), value);
break;
case LIKE:
wrapper.like(ConvertUtil.humpToLine2(field.getName()), value);
case BETWEEN:
if(value instanceof Collection && ((List) value).size() >= 2){
wrapper.between(ConvertUtil.humpToLine2(field.getName()), ((List)value).get(0), ((List)value).get(1));
if (value instanceof Collection && ((List) value).size() >= 2) {
wrapper.between(ConvertUtil.humpToLine2(field.getName()), ((List) value).get(0), ((List) value).get(1));
}
default:
}
}else if(condition.isNull()){
} else if (condition.isNull()) {
wrapper.isNull(ConvertUtil.humpToLine2(field.getName()));
}
}
Order order = field.getAnnotation(Order.class);
if(order != null){
if(!StrUtil.isEmptyIfStr(order.order())){
switch (order.order()){
if (order != null) {
if (!StrUtil.isEmptyIfStr(order.order())) {
switch (order.order()) {
case DESC:
wrapper.orderByDesc(ConvertUtil.humpToLine2(field.getName()));
break;

View File

@@ -16,9 +16,9 @@ public class AidaConfiguration {
@Bean(value = "IntelligentCurtainApis")
public Docket gxyd5aThemeApis() {
Contact contact = new Contact("Mr.Y","","136");
Contact contact = new Contact("Mr.Y", "", "136");
Docket docket=new Docket(DocumentationType.SWAGGER_2)
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.description("aida接口文档")
.contact(contact)

View File

@@ -3,11 +3,12 @@ package com.ai.da.common.context;
import com.ai.da.model.vo.AuthPrincipalVo;
public class UserContext {
private static ThreadLocal<AuthPrincipalVo> userHolder= new ThreadLocal<AuthPrincipalVo>();
private static ThreadLocal<AuthPrincipalVo> userHolder = new ThreadLocal<AuthPrincipalVo>();
public static AuthPrincipalVo getUserHolder() {
return userHolder.get();
}
public static void delete() {
userHolder.remove();
}

View File

@@ -39,8 +39,8 @@ public enum CollectionLevel1TypeEnum {
return realName;
}
public static CollectionLevel1TypeEnum uploadOf(String realName){
public static CollectionLevel1TypeEnum uploadOf(String realName) {
return Stream.of(CollectionLevel1TypeEnum.values())
.filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
.filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
}

View File

@@ -6,5 +6,5 @@ package com.ai.da.common.enums;
* @create: 2020-01-14 17:33
**/
public enum ConditionType {
EQ,LIKE,BETWEEN;
EQ, LIKE, BETWEEN;
}

View File

@@ -16,19 +16,19 @@ public enum CurrentDesignPictureTypeEnum {
/**
* PIN
*/
PIN(1,"PIN"),
PIN(1, "PIN"),
/**
* USER_LIBRARY
*/
USER_LIBRARY(2,"userLibrary"),
USER_LIBRARY(2, "userLibrary"),
/**
* SYS_FILE
*/
SYS_FILE(3,"sysFile"),
SYS_FILE(3, "sysFile"),
/**
* noPIN
*/
NO_PIN(4,"noPIN");
NO_PIN(4, "noPIN");
private Integer code;
private String desc;
@@ -38,10 +38,11 @@ public enum CurrentDesignPictureTypeEnum {
this.desc = desc;
}
public static CurrentDesignPictureTypeEnum of(String name){
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v ->v.name().equals(name)).findFirst().orElse(null);
public static CurrentDesignPictureTypeEnum of(String name) {
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);
}
public static List<CurrentDesignPictureTypeEnum> ofList(List<Integer> codes){
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v ->codes.contains(v.code)).collect(Collectors.toList());
public static List<CurrentDesignPictureTypeEnum> ofList(List<Integer> codes) {
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v -> codes.contains(v.code)).collect(Collectors.toList());
}
}

View File

@@ -16,15 +16,15 @@ public enum CurrentDesignPrintPictureTypeEnum {
/**
* 空白
*/
NO(1,"空白"),
NO(1, "空白"),
/**
* PIN
*/
PIN(2,"PIN"),
PIN(2, "PIN"),
/**
* noPIN
*/
NO_PIN(3,"noPIN");
NO_PIN(3, "noPIN");
private Integer code;
private String desc;
@@ -33,7 +33,8 @@ public enum CurrentDesignPrintPictureTypeEnum {
this.code = code;
this.desc = desc;
}
public static List<CurrentDesignPrintPictureTypeEnum> ofList(List<Integer> codes){
return Stream.of(CurrentDesignPrintPictureTypeEnum.values()).filter(v ->codes.contains(v.code)).collect(Collectors.toList());
public static List<CurrentDesignPrintPictureTypeEnum> ofList(List<Integer> codes) {
return Stream.of(CurrentDesignPrintPictureTypeEnum.values()).filter(v -> codes.contains(v.code)).collect(Collectors.toList());
}
}

View File

@@ -8,17 +8,17 @@ public enum GenerateModeEnum {
/**
* 通过文本生成
*/
TEXT(1,"text"),
TEXT(1, "text"),
/**
* 通过图片生成
*/
IMAGE(2,"image"),
IMAGE(2, "image"),
/**
* 通过文本和图片生成
*/
TEXT_IMAGE(2,"text-image");
TEXT_IMAGE(2, "text-image");
private Integer code;
private String value;

View File

@@ -39,8 +39,8 @@ public enum LibraryLevel1TypeEnum {
return realName;
}
public static LibraryLevel1TypeEnum uploadOf(String realName){
public static LibraryLevel1TypeEnum uploadOf(String realName) {
return Stream.of(LibraryLevel1TypeEnum.values())
.filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
.filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
}

View File

@@ -30,9 +30,10 @@ public enum LibraryTopTypeEnum {
public String getRealName() {
return realName;
}
public static LibraryTopTypeEnum uploadOf(String realName){
public static LibraryTopTypeEnum uploadOf(String realName) {
return Stream.of(LibraryTopTypeEnum.values())
.filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
.filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
}

View File

@@ -17,7 +17,7 @@ public enum LoginTypeEnum {
*/
PASSWORD;
public static LoginTypeEnum of(String name){
return Stream.of(LoginTypeEnum.values()).filter(v ->v.name().equals(name)).findFirst().orElse(null);
public static LoginTypeEnum of(String name) {
return Stream.of(LoginTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);
}
}

View File

@@ -8,14 +8,14 @@ public enum ModelNameEnum {
/**
* 使用模型0
*/
MODEL_0("0","model_0");
MODEL_0("0", "model_0");
private String code;
private String modelName;
ModelNameEnum(String code,String modelName) {
ModelNameEnum(String code, String modelName) {
this.code = code;
this.modelName = modelName;
}

View File

@@ -9,7 +9,7 @@ import java.util.stream.Stream;
**/
public enum OperationTypeEnum {
/**
*登入
* 登入
*/
LOGIN,
/**
@@ -25,7 +25,7 @@ public enum OperationTypeEnum {
*/
FORGET_PWD;
public static OperationTypeEnum of(String name){
return Stream.of(OperationTypeEnum.values()).filter(v ->v.name().equals(name)).findFirst().orElse(null);
public static OperationTypeEnum of(String name) {
return Stream.of(OperationTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);
}
}

View File

@@ -6,5 +6,5 @@ package com.ai.da.common.enums;
* @create: 2020-01-14 17:33
**/
public enum OrderType {
DESC,ASC;
DESC, ASC;
}

View File

@@ -36,7 +36,7 @@ public enum PythonToJavaApiOperationTypeEnum {
return realName;
}
public static PythonToJavaApiOperationTypeEnum uploadOf(String realName){
return Stream.of(PythonToJavaApiOperationTypeEnum.values()).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
public static PythonToJavaApiOperationTypeEnum uploadOf(String realName) {
return Stream.of(PythonToJavaApiOperationTypeEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
}

View File

@@ -27,7 +27,7 @@ public enum SingleOverallEnum {
return realName;
}
public static SingleOverallEnum of(String realName){
return Stream.of(SingleOverallEnum.values()).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
public static SingleOverallEnum of(String realName) {
return Stream.of(SingleOverallEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
}

View File

@@ -40,7 +40,7 @@ public enum SwitchCategoryEnum {
return realName;
}
public static SwitchCategoryEnum of(String realName){
return Stream.of(SwitchCategoryEnum.values()).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
public static SwitchCategoryEnum of(String realName) {
return Stream.of(SwitchCategoryEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
}

View File

@@ -9,11 +9,11 @@ import java.util.stream.Stream;
**/
public enum SysFileLevel1TypeEnum {
IMAGES("Images","images"),
IMAGES("Images", "images"),
ICON_C("Iconc","iconc"),
ICON_C("Iconc", "iconc"),
ACCESSORIES("Accessories","accessories");
ACCESSORIES("Accessories", "accessories");
private String realName;
/**
@@ -34,7 +34,7 @@ public enum SysFileLevel1TypeEnum {
return uploadPathName;
}
public static SysFileLevel1TypeEnum uploadOf(String uploadPathName){
return Stream.of(SysFileLevel1TypeEnum.values()).filter(v ->v.getUploadPathName().equals(uploadPathName)).findFirst().orElse(null);
public static SysFileLevel1TypeEnum uploadOf(String uploadPathName) {
return Stream.of(SysFileLevel1TypeEnum.values()).filter(v -> v.getUploadPathName().equals(uploadPathName)).findFirst().orElse(null);
}
}

View File

@@ -14,27 +14,27 @@ public enum SysFileLevel2TypeEnum {
/**
* ICON
*/
ICON("Icon","icon"),
ICON("Icon", "icon"),
BAG("Bag","bag"),
BAG("Bag", "bag"),
EARRINGS("Earring","earring"),
EARRINGS("Earring", "earring"),
HAIRSTYLE("Hairstyle","hairstyle"),
HAIRSTYLE("Hairstyle", "hairstyle"),
SHOES("Shoes","shoes"),
SHOES("Shoes", "shoes"),
BODY("Body","body"),
BODY("Body", "body"),
BLOUSE("Blouse","blouse"),
BLOUSE("Blouse", "blouse"),
DRESS("Dress","dress"),
DRESS("Dress", "dress"),
OUTWEAR("Outwear","outwear"),
OUTWEAR("Outwear", "outwear"),
SKIRT("Skirt","skirt"),
SKIRT("Skirt", "skirt"),
TROUSERS("Trousers","trousers");
TROUSERS("Trousers", "trousers");
private String realName;
/**
@@ -55,21 +55,24 @@ public enum SysFileLevel2TypeEnum {
return uploadPathName;
}
public static SysFileLevel2TypeEnum uploadOf(String uploadPathName){
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v ->v.getUploadPathName().equals(uploadPathName)).findFirst().orElse(null);
}
public static SysFileLevel2TypeEnum realNameOf(String realName){
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
public static SysFileLevel2TypeEnum uploadOf(String uploadPathName) {
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v -> v.getUploadPathName().equals(uploadPathName)).findFirst().orElse(null);
}
public static SysFileLevel2TypeEnum realNameOfPython(String realName){
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
public static SysFileLevel2TypeEnum realNameOf(String realName) {
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
public static List<String> ofPython(){
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getRealName).collect(Collectors.toList());
public static SysFileLevel2TypeEnum realNameOfPython(String realName) {
return Stream.of(BLOUSE, DRESS, OUTWEAR, SKIRT, TROUSERS).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
}
public static List<String> ofPythonPath(){
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getUploadPathName).collect(Collectors.toList());
public static List<String> ofPython() {
return Stream.of(BLOUSE, DRESS, OUTWEAR, SKIRT, TROUSERS).map(SysFileLevel2TypeEnum::getRealName).collect(Collectors.toList());
}
public static List<String> ofPythonPath() {
return Stream.of(BLOUSE, DRESS, OUTWEAR, SKIRT, TROUSERS).map(SysFileLevel2TypeEnum::getUploadPathName).collect(Collectors.toList());
}
public static final List<String> ACCESSORIES_LIST = Arrays.asList(

View File

@@ -16,23 +16,24 @@ public class TokenQuery {
private static final String GENERATE_USER_DOMAIN = "https://www.szsige.com";
public static JSONObject getToken(String session) {
String url = GET_TOKEN_DOMAIN + TokenApis.GET_TOKEN.getUrl()+ session;
String url = GET_TOKEN_DOMAIN + TokenApis.GET_TOKEN.getUrl() + session;
log.info("获取用户token接口请求url:" + url);
HttpResponse httpResponse = HttpUtil.createPost(url).execute();
log.info("获取用户token接口响应" + httpResponse);
if(httpResponse.isOk() && StrUtil.isNotEmpty(httpResponse.body())){
if (httpResponse.isOk() && StrUtil.isNotEmpty(httpResponse.body())) {
return JSONObject.parseObject(httpResponse.body());
}
return null;
}
public static JSONObject generateUser(Map<String, Object> param,String token) {
public static JSONObject generateUser(Map<String, Object> param, String token) {
HttpResponse httpResponse = HttpUtil.createPost(GENERATE_USER_DOMAIN + TokenApis.GENERATE_USER.getUrl())
.body(JSONObject.toJSONString(param!=null?param:new HashMap<>()))
.header("Authorization", "Bearer "+token)
.body(JSONObject.toJSONString(param != null ? param : new HashMap<>()))
.header("Authorization", "Bearer " + token)
.header("X-Promiss", "9672233956")
.execute();
log.info("生成用户信息接口响应:" + httpResponse);
if(httpResponse.isOk() && StrUtil.isNotEmpty(httpResponse.body())){
if (httpResponse.isOk() && StrUtil.isNotEmpty(httpResponse.body())) {
return JSONObject.parseObject(httpResponse.body());
}
return null;

View File

@@ -17,7 +17,7 @@ import java.util.List;
@Data
@NoArgsConstructor
@ApiModel("分页响应结果")
public class PageBaseResponse<T>{
public class PageBaseResponse<T> {
@ApiModelProperty("页码")
private long page;
@ApiModelProperty("每页数量")
@@ -30,7 +30,6 @@ public class PageBaseResponse<T>{
private List<T> content;
public PageBaseResponse(List<T> list, long page, long size, long total, long pages) {
this.page = page;
this.size = size;
@@ -39,7 +38,7 @@ public class PageBaseResponse<T>{
this.content = list;
}
public static <T> PageBaseResponse<T> success(IPage<T> page){
return new PageBaseResponse<>(page.getRecords() , page.getCurrent(), page.getSize(), page.getTotal(), page.getPages());
public static <T> PageBaseResponse<T> success(IPage<T> page) {
return new PageBaseResponse<>(page.getRecords(), page.getCurrent(), page.getSize(), page.getTotal(), page.getPages());
}
}

View File

@@ -31,9 +31,8 @@ public class PageResponse<T> extends Response<List<T>> {
private List<T> content;
public PageResponse(Response<List<T>> response, long page, long size, long total, long pages) {
if(response != null) {
if (response != null) {
this.setData(response.getData());
this.setErrCode(response.getErrCode());
this.setErrMsg(response.getErrMsg());
@@ -45,8 +44,8 @@ public class PageResponse<T> extends Response<List<T>> {
this.content = response.getData();
}
public static <T> PageResponse<T> success(IPage<T> page){
public static <T> PageResponse<T> success(IPage<T> page) {
Response<List<T>> response = success(page.getRecords());
return new PageResponse<>(response , page.getCurrent(), page.getSize(), page.getTotal(), page.getPages());
return new PageResponse<>(response, page.getCurrent(), page.getSize(), page.getTotal(), page.getPages());
}
}

View File

@@ -27,28 +27,27 @@ public class Response<T> implements Serializable {
@ApiModelProperty("数据结果")
private T data;
public static <T> Response<T> success(){
public static <T> Response<T> success() {
return success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), null);
}
public static <T> Response<T> success(String msg){
public static <T> Response<T> success(String msg) {
return success(ResultEnum.SUCCESS.getCode(), msg, null);
}
public static <T> Response<T> success(T data){
public static <T> Response<T> success(T data) {
return success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), data);
}
public static <T> Response<T> success(int code, T data){
public static <T> Response<T> success(int code, T data) {
return success(code, ResultEnum.SUCCESS.getMsg(), data);
}
public static <T> Response<T> success(int code, String msg, T data){
public static <T> Response<T> success(int code, String msg, T data) {
return getResponse(code, msg, data);
}
public static <T> Response<T> fail(String msg) {
return fail(ResultEnum.FAIL.getCode(), msg);
}
@@ -85,7 +84,7 @@ public class Response<T> implements Serializable {
return getResponse(code, msg, data);
}
private static <T> Response<T> getResponse(int code, String msg, T data){
private static <T> Response<T> getResponse(int code, String msg, T data) {
return new Response<>(code, msg, data);
}

View File

@@ -13,17 +13,16 @@ public enum ResultEnum {
ERROR(false, -1, "system error!"),
PARAMETER_ERROR(false, -2, "parameter error!"),
NO_LOGIN(false,-100,"User not logged in"),
NO_PERMISSION(false,-200,"No access"),
ACCOUNT_LOCK(false,-300,"Account frozen");
NO_LOGIN(false, -100, "User not logged in"),
NO_PERMISSION(false, -200, "No access"),
ACCOUNT_LOCK(false, -300, "Account frozen");
private int code;
private String msg;
private boolean isOK;
ResultEnum(boolean isOK, int code, String msg){
ResultEnum(boolean isOK, int code, String msg) {
this.isOK = isOK;
this.code = code;
this.msg = msg;

View File

@@ -43,6 +43,6 @@ public class UserLoginFailureHandler implements AuthenticationFailureHandler {
log.error("登录失败:", e);
response = Response.fail("登录失败!");
}
JSONResponseUtils.build(httpServletResponse,response);
JSONResponseUtils.build(httpServletResponse, response);
}
}

View File

@@ -41,10 +41,10 @@ public class AuthenticationFilter extends OncePerRequestFilter {
private SecurityProperties properties;
private static final List<String> FILTER_URL =
Arrays.asList("/favicon.ico","/doc.html","api/account/login","api/account/preLogin","api/account/sendEmail",
"/webjars/","/swagger-resources","/v2/api-docs","api/account/resetPwd",
Arrays.asList("/favicon.ico", "/doc.html", "api/account/login", "api/account/preLogin", "api/account/sendEmail",
"/webjars/", "/swagger-resources", "/v2/api-docs", "api/account/resetPwd",
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
"/api/third/party/addUser","/api/third/party/editUser","/api/element/initDefaultSysFile",
"/api/third/party/addUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
"/api/python/chatStream",
"/api/python/flush"
);
@@ -53,16 +53,16 @@ public class AuthenticationFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {
String requestURI = httpServletRequest.getRequestURI();
if(calculateUrl(requestURI)){
if (calculateUrl(requestURI)) {
StopWatch stopWatch = new StopWatch();
HttpServletRequest wrappedRequest = httpServletRequest;
HttpServletResponse wrappedResponse = httpServletResponse;
try{
try {
stopWatch.start();
if ((httpServletRequest.getContentType() == null && httpServletRequest.getContentLength() > 0) || (httpServletRequest.getContentType() != null && !httpServletRequest.getContentType().contains("application/json"))) {
extracted(wrappedRequest);
filterChain.doFilter(wrappedRequest, wrappedResponse);
}else {
} else {
wrappedRequest = new MultiReadHttpServletRequest(httpServletRequest);
wrappedResponse = new MultiReadHttpServletResponse(httpServletResponse);
extracted(wrappedRequest);
@@ -74,14 +74,16 @@ public class AuthenticationFilter extends OncePerRequestFilter {
} finally {
stopWatch.stop();
}
}else {
} else {
filterChain.doFilter(httpServletRequest, httpServletResponse);
}
}
private Boolean calculateUrl(String requestURI ){
String filterUrl = FILTER_URL.stream().filter(url ->requestURI.contains(url)).findFirst().orElse(null);
return null == filterUrl ? Boolean.TRUE :Boolean.FALSE;
private Boolean calculateUrl(String requestURI) {
String filterUrl = FILTER_URL.stream().filter(url -> requestURI.contains(url)).findFirst().orElse(null);
return null == filterUrl ? Boolean.TRUE : Boolean.FALSE;
}
private void extracted(HttpServletRequest request) throws AuthenticationException {
String jwtToken = request.getHeader(properties.getJwtTokenHeader());
log.debug("后台检查令牌:{}", jwtToken);
@@ -91,7 +93,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
}
// 检查token
boolean validate = jwtTokenHelper.validateToken(jwtToken);
if(validate){
if (validate) {
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(jwtToken);
if (principal == null) {
throw new RuntimeException("TOKEN已过期请重新登录");

View File

@@ -31,7 +31,7 @@ public class JWTTokenHelper {
private static final String ISSUER = "DWJ";
private static final String AUTHORITIES = "authorities";
public String createToken(AuthPrincipalVo principal){
public String createToken(AuthPrincipalVo principal) {
String token = Jwts.builder()
.setId(String.valueOf(principal.getId()))
.setSubject(JSONObject.toJSONString(principal))
@@ -45,24 +45,24 @@ public class JWTTokenHelper {
return token;
}
public boolean validateToken(String token){
public boolean validateToken(String token) {
Claims claims = parser(token);
if (MapUtil.isEmpty(claims)){
if (MapUtil.isEmpty(claims)) {
return false;
}
return true;
}
public AuthPrincipalVo parserToUser(String token){
public AuthPrincipalVo parserToUser(String token) {
String subject = parser(token).getSubject();
if(StrUtil.isNotEmpty(subject)){
if (StrUtil.isNotEmpty(subject)) {
return JSONObject.parseObject(subject, AuthPrincipalVo.class);
}
return null;
}
public Claims parser(String token) {
token = token.replaceAll(securityProperties.getJwtTokenPrefix(),"");
token = token.replaceAll(securityProperties.getJwtTokenPrefix(), "");
return Jwts.parser().setSigningKey(securityProperties.getJwtSecret()).parseClaimsJws(token).getBody();
}
}

View File

@@ -23,16 +23,17 @@ public class AccessLimitUtils {
* @param interfaceName
* @return
*/
public static void validate(String interfaceName,Integer count) {
Integer useCount= LocalCacheUtils.getAidaInterfaceCurrentLimitingCache(interfaceName);
if(useCount >count){
public static void validate(String interfaceName, Integer count) {
Integer useCount = LocalCacheUtils.getAidaInterfaceCurrentLimitingCache(interfaceName);
if (useCount > count) {
//系统繁忙
throw new BusinessException("system busy !");
}else{
useCount ++;
LocalCacheUtils.setAidaInterfaceCurrentLimitingCache(interfaceName,useCount);
} else {
useCount++;
LocalCacheUtils.setAidaInterfaceCurrentLimitingCache(interfaceName, useCount);
}
}
/**
* 校验过后 接口完毕 去掉限流
*
@@ -40,9 +41,9 @@ public class AccessLimitUtils {
* @return
*/
public static void validateOut(String interfaceName) {
Integer useCount= LocalCacheUtils.getAidaInterfaceCurrentLimitingCache(interfaceName);
useCount --;
LocalCacheUtils.setAidaInterfaceCurrentLimitingCache(interfaceName,useCount);
Integer useCount = LocalCacheUtils.getAidaInterfaceCurrentLimitingCache(interfaceName);
useCount--;
LocalCacheUtils.setAidaInterfaceCurrentLimitingCache(interfaceName, useCount);
}
}

View File

@@ -54,11 +54,11 @@ public class ConvertUtil {
return sb.toString();
}
public static String lowerCaseFirstLetter(String str){
if(StrUtil.isNotBlank(str)){
public static String lowerCaseFirstLetter(String str) {
if (StrUtil.isNotBlank(str)) {
str = str.trim();
String result = str.substring(0, 1).toLowerCase();
if(str.length() > 1){
if (str.length() > 1) {
result += str.substring(1);
}
return result;

View File

@@ -12,11 +12,13 @@ import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
@Slf4j
public class DateUtil {
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String YYYYMM = "yyyyMM";
public static final String YYYY_MM_DD = "yyyyMMdd";
/**
* LocalDate -> Date
*/
@@ -25,13 +27,15 @@ public class DateUtil {
}
/**
* LocalDateTime -> Date
* LocalDateTime -> Date
*/
public static Date asDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* date 装 String
*
* @param date
* @param formatter
* @return
@@ -43,21 +47,23 @@ public class DateUtil {
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zoneId);
return dateTimeFormatter.format(localDateTime);
}
/**
* 根据时区获取时间
*
* @param timeZone "Asia/Tokyo"
* @return
*/
public static Date getByTimeZone(String timeZone) {
String dateStr = dateToStr(new Date(),YYYY_MM_DD_HH_MM_SS);
String dateStr = dateToStr(new Date(), YYYY_MM_DD_HH_MM_SS);
SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
// 设置时区
sdf.setTimeZone(TimeZone.getTimeZone(timeZone));
Date date = null;
try{
Date date = null;
try {
date = sdf.parse(dateStr);
}catch (ParseException parseException){
log.error("时间转换异常!",parseException);
} catch (ParseException parseException) {
log.error("时间转换异常!", parseException);
}
return date;
}

View File

@@ -129,53 +129,56 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
/**
* 获取文件尺寸
*/
public static FileVO getFileSize(MultipartFile file) {
public static FileVO getFileSize(MultipartFile file) {
int width = 0;
int height = 0;
try{
try {
// 图片对象
BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
// 宽度
width = bufferedImage.getWidth();
width = bufferedImage.getWidth();
// 高度
height = bufferedImage.getHeight();
}catch (IOException ioException){
height = bufferedImage.getHeight();
} catch (IOException ioException) {
log.error("获取文件尺寸异常###{}", ExceptionUtil.stacktraceToString(ioException));
}
return new FileVO(height,width);
return new FileVO(height, width);
}
/**
* 获取文件尺寸
*/
public static FileVO getFileSize(InputStream inputStream) {
public static FileVO getFileSize(InputStream inputStream) {
int width = 0;
int height = 0;
try{
try {
// 图片对象
BufferedImage bufferedImage = ImageIO.read(inputStream);
// 宽度
width = bufferedImage.getWidth();
// 高度
height = bufferedImage.getHeight();
}catch (IOException ioException){
} catch (IOException ioException) {
log.error("获取文件尺寸异常###{}", ExceptionUtil.stacktraceToString(ioException));
}
return new FileVO(height,width);
return new FileVO(height, width);
}
/**
* 获取远程文件流
*/
public static InputStream getOriginFile(String path) {
public static InputStream getOriginFile(String path) {
try{
try {
//远程
URL url = new URL(path);
return url.openStream();
}catch (IOException ioException){
log.error("获取文件尺寸异常###{}###path##{}", ExceptionUtil.stacktraceToString(ioException),path);
} catch (IOException ioException) {
log.error("获取文件尺寸异常###{}###path##{}", ExceptionUtil.stacktraceToString(ioException), path);
throw new BusinessException("get file is failed!");
}
}
/**
* 将文件名解析成文件的上传路径
*/
@@ -183,7 +186,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
String suffix = getExtensionName(file.getOriginalFilename());
String nowStr = format.format(date)+"-" ;
String nowStr = format.format(date) + "-";
try {
String fileName = file.getOriginalFilename();
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
@@ -204,6 +207,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
return null;
}
/**
* 将文件名解析成文件的上传路径
*/
@@ -211,7 +215,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
String suffix = getExtensionName(file.getOriginalFilename());
String nowStr = format.format(date)+"-" ;
String nowStr = format.format(date) + "-";
try {
String fileName = file.getOriginalFilename();
String path = filePath + fileName;
@@ -242,6 +246,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
return false;
}
/**
* 获取指定文件夹下所有文件,不含文件夹里的文件
*
@@ -249,7 +254,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
* @return
*/
public static List<File> getAllFile(String dirFilePath) {
if (StrUtil.isBlank(dirFilePath)){
if (StrUtil.isBlank(dirFilePath)) {
return null;
}
return getAllFile(new File(dirFilePath));
@@ -263,11 +268,11 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
*/
public static List<File> getAllFile(File dirFile) {
// 如果文件夹不存在或着不是文件夹,则返回 null
if (Objects.isNull(dirFile) || !dirFile.exists() || dirFile.isFile()){
if (Objects.isNull(dirFile) || !dirFile.exists() || dirFile.isFile()) {
return null;
}
File[] childrenFiles = dirFile.listFiles();
if (Objects.isNull(childrenFiles) || childrenFiles.length == 0){
if (Objects.isNull(childrenFiles) || childrenFiles.length == 0) {
return null;
}
List<File> files = new ArrayList<>();
@@ -280,7 +285,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
else {
// 如果是文件夹,则将其内部文件添加进结果集合
List<File> cFiles = getAllFile(childFile);
if (Objects.isNull(cFiles) || cFiles.isEmpty()){
if (Objects.isNull(cFiles) || cFiles.isEmpty()) {
continue;
}
files.addAll(cFiles);

View File

@@ -14,10 +14,11 @@ import java.io.IOException;
@Slf4j
public class ImageUtil {
static BufferedImage bufferedImage;
static int r,g,b; // 分别用来存放获取的RGB值
static int heigth,width;
static int r, g, b; // 分别用来存放获取的RGB值
static int heigth, width;
static int id = 0;
public static void find(){
public static void find() {
// 读取要操作的图片,这里的图片路径请改成自己要处理的图片
try {
bufferedImage = ImageIO.read(new File("D:\\programManager\\private\\curtain\\curtain\\WechatIMG170.png"));
@@ -27,16 +28,16 @@ public class ImageUtil {
// 获取图片的宽和高;
heigth = bufferedImage.getHeight();
width = bufferedImage.getHeight();
System.out.println("heigth = "+heigth +", width ="+width);
System.out.println("heigth = " + heigth + ", width =" + width);
// 采用行优先遍历,先遍历宽
for (int y = 0; y < heigth; y++) {
for (int x = 0; x < width; x++) {
id++;
Color color = new Color(bufferedImage.getRGB(x,y));
Color color = new Color(bufferedImage.getRGB(x, y));
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
System.out.println("此时的id为 "+ id+ " R = "+ r + ", G = "+g+", B ="+b);
System.out.println("此时的id为 " + id + " R = " + r + ", G = " + g + ", B =" + b);
}
}
}

View File

@@ -25,25 +25,26 @@ public final class LocalCacheUtils {
* token
*/
private static LoadingCache<String, String> tokenCache = loadTokenCache();
/**
*
*缓存接口这里是LoadingCacheLoadingCache在缓存项不存在时可以自动加载缓存
* 缓存接口这里是LoadingCacheLoadingCache在缓存项不存在时可以自动加载缓存
*/
private static LoadingCache<String, String> loadTokenCache(){
LoadingCache<String, String> tokenCache = CacheBuilder.newBuilder()
private static LoadingCache<String, String> loadTokenCache() {
LoadingCache<String, String> tokenCache = CacheBuilder.newBuilder()
.concurrencyLevel(10)
.expireAfterWrite(24*100, TimeUnit.HOURS)
.expireAfterWrite(24 * 100, TimeUnit.HOURS)
.initialCapacity(100)
.maximumSize(10000)
.recordStats()
.build(new CacheLoader<String, String>() {
@Override
public String load(String key) throws Exception {
return "null";
}
@Override
public String load(String key) throws Exception {
return "null";
}
});
return tokenCache;
}
/**
* 邮箱,短信验证码
*/
@@ -51,7 +52,7 @@ public final class LocalCacheUtils {
//设置并发级别为5并发级别是指可以同时写缓存的线程数
.concurrencyLevel(10)
//设置写缓存后10分钟过期,防止跨洲发送慢失效问题
.expireAfterWrite(60*30, TimeUnit.SECONDS)
.expireAfterWrite(60 * 30, TimeUnit.SECONDS)
//刷新机制 每隔一定时间刷新缓存loader 只有调用get具体的操作才生效(懒加载) 不设置则不刷新
// .refreshAfterWrite(60, TimeUnit.SECONDS)
//设置缓存容器的初始容量为100
@@ -75,7 +76,7 @@ public final class LocalCacheUtils {
//设置并发级别为5并发级别是指可以同时写缓存的线程数
.concurrencyLevel(10)
//设置写缓存后一天过期
.expireAfterWrite(60*60*24, TimeUnit.SECONDS)
.expireAfterWrite(60 * 60 * 24, TimeUnit.SECONDS)
//设置缓存容器的初始容量为100
.initialCapacity(100)
//设置缓存最大容量50000超过50000之后就会按照LRU最近虽少使用算法来移除缓存项
@@ -96,7 +97,7 @@ public final class LocalCacheUtils {
//设置并发级别为5并发级别是指可以同时写缓存的线程数
.concurrencyLevel(10)
//设置写缓存后一天过期
.expireAfterWrite(60*60*24, TimeUnit.SECONDS)
.expireAfterWrite(60 * 60 * 24, TimeUnit.SECONDS)
//设置缓存容器的初始容量为100
.initialCapacity(100)
//设置缓存最大容量50000超过50000之后就会按照LRU最近虽少使用算法来移除缓存项
@@ -118,7 +119,7 @@ public final class LocalCacheUtils {
//设置并发级别为5并发级别是指可以同时写缓存的线程数
.concurrencyLevel(10)
//设置写缓存后一天过期
.expireAfterWrite(60*60*24, TimeUnit.SECONDS)
.expireAfterWrite(60 * 60 * 24, TimeUnit.SECONDS)
//设置缓存容器的初始容量为15000
.initialCapacity(15000)
//设置缓存最大容量50000超过50000之后就会按照LRU最近虽少使用算法来移除缓存项
@@ -133,27 +134,27 @@ public final class LocalCacheUtils {
}
});
/**
/**
* design文件进度统计
*/
private static LoadingCache<Long, List<String>> designProcessCache = CacheBuilder.newBuilder()
//设置并发级别为10并发级别是指可以同时写缓存的线程数
.concurrencyLevel(10)
//设置写缓存后5分钟过期
.expireAfterWrite(60*5, TimeUnit.SECONDS)
//设置缓存容器的初始容量为100
.initialCapacity(5)
//设置缓存最大容量50000超过50000之后就会按照LRU最近虽少使用算法来移除缓存项
.maximumSize(100)
//设置要统计缓存的命中率
.recordStats()
//build方法中可以指定CacheLoader在缓存不存在时通过CacheLoader的实现自动加载缓存
.build(new CacheLoader<Long, List<String>>() {
@Override
public List<String> load(Long key) throws Exception {
return Collections.EMPTY_LIST;
}
});
//设置并发级别为10并发级别是指可以同时写缓存的线程数
.concurrencyLevel(10)
//设置写缓存后5分钟过期
.expireAfterWrite(60 * 5, TimeUnit.SECONDS)
//设置缓存容器的初始容量为100
.initialCapacity(5)
//设置缓存最大容量50000超过50000之后就会按照LRU最近虽少使用算法来移除缓存项
.maximumSize(100)
//设置要统计缓存的命中率
.recordStats()
//build方法中可以指定CacheLoader在缓存不存在时通过CacheLoader的实现自动加载缓存
.build(new CacheLoader<Long, List<String>>() {
@Override
public List<String> load(Long key) throws Exception {
return Collections.EMPTY_LIST;
}
});
/**
* aida 接口限流(先粗暴做)
@@ -162,7 +163,7 @@ public final class LocalCacheUtils {
//设置并发级别为5并发级别是指可以同时写缓存的线程数
.concurrencyLevel(20)
//设置写缓存后30天过期
.expireAfterWrite(60*60*24*30, TimeUnit.SECONDS)
.expireAfterWrite(60 * 60 * 24 * 30, TimeUnit.SECONDS)
//设置缓存容器的初始容量为100
.initialCapacity(5)
//设置缓存最大容量50000超过50000之后就会按照LRU最近虽少使用算法来移除缓存项
@@ -176,8 +177,10 @@ public final class LocalCacheUtils {
return 0;
}
});
/**
* 添加token本地缓存
*
* @param key
* @param value
*/
@@ -187,6 +190,7 @@ public final class LocalCacheUtils {
/**
* 获取token本地缓存
*
* @param key
* @return
*/
@@ -202,8 +206,10 @@ public final class LocalCacheUtils {
}
return null;
}
/**
* 删除token本地缓存(登出)
*
* @param key
* @return
*/
@@ -214,8 +220,10 @@ public final class LocalCacheUtils {
log.error("delTokenCache方法错误", e);
}
}
/**
* 添加验证码本地缓存
*
* @param key
* @param value
*/
@@ -225,6 +233,7 @@ public final class LocalCacheUtils {
/**
* 获取验证码本地缓存
*
* @param key
* @return
*/
@@ -240,8 +249,10 @@ public final class LocalCacheUtils {
}
return null;
}
/**
* 添加系统文本地缓存
*
* @param key
* @param sysFile
*/
@@ -251,6 +262,7 @@ public final class LocalCacheUtils {
/**
* 获取系统文件本地缓存
*
* @param key
* @return
*/
@@ -263,8 +275,10 @@ public final class LocalCacheUtils {
}
return null;
}
/**
* 清除所有系统文件本地缓存
*
* @return
*/
public static void clearAllSysFileCache() {
@@ -274,8 +288,10 @@ public final class LocalCacheUtils {
log.error("clearAllSysFileCache方法错误", e);
}
}
/**
* 添加系统文本地缓存,通过类型
*
* @param level1Type
* @param sysFileList
*/
@@ -285,6 +301,7 @@ public final class LocalCacheUtils {
/**
* 获取系统文件本地缓存
*
* @param level2Type
* @return
*/
@@ -296,8 +313,10 @@ public final class LocalCacheUtils {
}
return null;
}
/**
* 清除所有系统文件本地缓存
*
* @return
*/
public static void clearAllSysFileCacheByLevel2Type() {
@@ -307,8 +326,10 @@ public final class LocalCacheUtils {
log.error("clearAllSysFileCacheByLevel2Type方法错误", e);
}
}
/**
* 添加系统文件范围最大最小值本地缓存
*
* @param key
* @param value
*/
@@ -318,6 +339,7 @@ public final class LocalCacheUtils {
/**
* 获取系统文件范围最大最小值本地缓存
*
* @param key
* @return
*/
@@ -333,8 +355,10 @@ public final class LocalCacheUtils {
}
return null;
}
/**
* 清除所有系统文件范围最大最小值本地缓存
*
* @return
*/
public static void clearAllMaxMinValueCache() {
@@ -344,8 +368,10 @@ public final class LocalCacheUtils {
log.error("clearAllMaxMinValueCache方法错误", e);
}
}
/**
* 添加系design文件进度统计
*
* @param key
* @param value
*/
@@ -355,6 +381,7 @@ public final class LocalCacheUtils {
/**
* 获取design文件进度统计
*
* @param key
* @return
*/
@@ -367,8 +394,10 @@ public final class LocalCacheUtils {
}
return null;
}
/**
* 进度统计完后 删除进度
*
* @param key
* @return
*/
@@ -382,6 +411,7 @@ public final class LocalCacheUtils {
/**
* 设置本次接口流量数
*
* @param key
* @param value
*/
@@ -391,6 +421,7 @@ public final class LocalCacheUtils {
/**
* 获取本次接口流量数
*
* @param key
* @return
*/

View File

@@ -58,6 +58,7 @@ public class MD5Utils {
}
return md5;
}
/**
* MD5加密文件
*

View File

@@ -37,6 +37,7 @@ import java.util.stream.Collectors;
public class MinioUtil {
@Autowired
private MinioClient minioClient;
/**
* description: 判断bucket是否存在不存在则创建
*
@@ -55,6 +56,7 @@ public class MinioUtil {
/**
* 创建存储bucket
*
* @param bucketName 存储bucket名称
* @return Boolean
*/
@@ -72,6 +74,7 @@ public class MinioUtil {
/**
* 删除存储bucket
*
* @param bucketName 存储bucket名称
* @return Boolean
*/
@@ -86,6 +89,7 @@ public class MinioUtil {
}
return true;
}
/**
* description: 上传文件
*
@@ -93,7 +97,6 @@ public class MinioUtil {
* @param path
* @param multipartFile
* @return: java.lang.String
*/
public List<String> uploadBatch(String bucketName, String path, MultipartFile[] multipartFile) {
List<String> names = new ArrayList<>(multipartFile.length);
@@ -138,7 +141,6 @@ public class MinioUtil {
* @param path
* @param file
* @return: java.lang.String
*/
public String upload(String bucketName, String path, MultipartFile file) {
String fileName = file.getOriginalFilename();
@@ -292,6 +294,7 @@ public class MinioUtil {
/**
* 查看文件对象
*
* @param bucketName 存储bucket名称
* @return 存储bucket内文件对象信息
*/
@@ -316,8 +319,9 @@ public class MinioUtil {
/**
* 批量删除文件对象
*
* @param bucketName 存储bucket名称
* @param objects 对象名称集合
* @param objects 对象名称集合
*/
public Iterable<Result<DeleteError>> removeObjects(String bucketName, List<String> objects) {
List<DeleteObject> dos = objects.stream().map(e -> new DeleteObject(e)).collect(Collectors.toList());
@@ -372,7 +376,7 @@ public class MinioUtil {
public String getPresignedUrl(String path, int expiry) {
if (LocalCacheUtils.getPresignedUrlCache(path) != null) {
return LocalCacheUtils.getPresignedUrlCache(path);
}else {
} else {
if (!path.contains("/")) {
throw new BusinessException("The path is error!");
}
@@ -387,21 +391,22 @@ public class MinioUtil {
/**
* 将桶名、文件名从url中分离出来
* @param url 带桶名、文件名的url
*
* @param url 带桶名、文件名的url
* @param expiry 图片过期时间
* @return 可以直接访问的minio图片地址
*/
public String splitThenGetPreviewUrl(String url,int expiry){
public String splitThenGetPreviewUrl(String url, int expiry) {
String[] parts = url.split("/");
String bucketName = parts[0];
StringBuilder fileName = new StringBuilder();
for (int i = 1; i < parts.length; i++){
for (int i = 1; i < parts.length; i++) {
fileName.append(parts[i]);
if (i != parts.length -1){
if (i != parts.length - 1) {
fileName.append("/");
}
}
return getPresignedUrl(bucketName, String.valueOf(fileName),expiry);
return getPresignedUrl(bucketName, String.valueOf(fileName), expiry);
}
public boolean doesObjectExist(String bucketName, String objectName) {

View File

@@ -45,24 +45,20 @@ public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
finally {
} finally {
if (inputStream != null) {
try {
inputStream.close();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
if (reader != null) {
try {
reader.close();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
@@ -72,6 +68,7 @@ public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
/**
* 复制输入流
*
* @param inputStream 请求输入流
* @return 复制出来的输入流
*/
@@ -84,8 +81,7 @@ public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
byteArrayOutputStream.write(buffer, 0, len);
}
byteArrayOutputStream.flush();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());

View File

@@ -1,4 +1,5 @@
package com.ai.da.common.utils;
import java.util.*;
import java.lang.reflect.Field;

View File

@@ -5,10 +5,10 @@ public class PantoneUtils {
public static int[] rgbToHsv(int[] rgb) {
//切割rgb数组
int red = rgb[0];
int green= rgb[1];
int green = rgb[1];
int blue = rgb[2];
float r = (float) red / 255;
float r = (float) red / 255;
float g = (float) green / 255;
float b = (float) blue / 255;
@@ -21,7 +21,7 @@ public class PantoneUtils {
hsv[0] = 60 * (
(hsv[2] == min) ? Float.NaN :
(hsv[2] == r) ? (g - b) / (hsv[2] - min) + ((g < b) ? 6 : 0) :
(hsv[2] == g) ? (b - r) / (hsv[2] - min) + 2:
(hsv[2] == g) ? (b - r) / (hsv[2] - min) + 2 :
(r - g) / (hsv[2] - min) + 4
);

View File

@@ -35,16 +35,17 @@ public class RandomsUtil {
* @param randomEnd
*/
public static String generateVerifyCode(Long randomStart, Long randomEnd) {
return String.valueOf(RandomUtil.randomLong(randomStart,randomEnd));
return String.valueOf(RandomUtil.randomLong(randomStart, randomEnd));
}
/**
* 生成随机系统图片
*
* @param randomStart 可以等于
* @param randomEnd 小于最大值
* @param randomEnd 小于最大值
*/
public static Long randomSysFile(Long randomStart, Long randomEnd) {
return RandomUtil.randomLong(randomStart,randomEnd);
return RandomUtil.randomLong(randomStart, randomEnd);
}

View File

@@ -13,36 +13,36 @@ import java.util.concurrent.TimeUnit;
**/
public final class RedisCacheUtils {
private static RedisTemplate<String, Object> getRedisTemplate(){
private static RedisTemplate<String, Object> getRedisTemplate() {
return SpringUtils.getBean("redisTemplate");
}
private static <T> RedisTemplate<String, T> getRedisTemplate(Class<T> clazz){
private static <T> RedisTemplate<String, T> getRedisTemplate(Class<T> clazz) {
return SpringUtils.getBean("redisTemplate");
}
private static <T> RedisTemplate<String, List<T>> getListRedisTemplate(Class<T> clazz){
private static <T> RedisTemplate<String, List<T>> getListRedisTemplate(Class<T> clazz) {
return SpringUtils.getBean("redisTemplate");
}
public static <T> T get(String key, Class<T> clazz){
public static <T> T get(String key, Class<T> clazz) {
return getRedisTemplate(clazz).opsForValue().get(key);
}
public static <T> List<T> getList(String key, Class<T> clazz){
public static <T> List<T> getList(String key, Class<T> clazz) {
return getListRedisTemplate(clazz).opsForValue().get(key);
}
public static void set(String key, Object value){
public static void set(String key, Object value) {
getRedisTemplate().opsForValue().set(key, value);
}
public static void set(String key, Object value, long time, TimeUnit unit){
public static void set(String key, Object value, long time, TimeUnit unit) {
getRedisTemplate().opsForValue().set(key, value, time, unit);
}
public static boolean delete(String key){
if(StrUtil.isNotEmpty(key)){
public static boolean delete(String key) {
if (StrUtil.isNotEmpty(key)) {
return Boolean.TRUE.equals(getRedisTemplate().delete(key));
}
return false;

View File

@@ -10,17 +10,16 @@ public class RequestInfoUtil {
* @param request
* @return java.lang.String
* @version 1.0
*
*
* <p>
* <p>
* 使用了ng等代理服务器要在ng加以下配置
* location / {
* proxy_pass http://127.0.0.1:10678;
* proxy_set_header Host $host;
* proxy_set_header X-Real-IP $remote_addr;
* proxy_set_header REMOTE-HOST $remote_addr;
* proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
* }
* proxy_pass http://127.0.0.1:10678;
* proxy_set_header Host $host;
* proxy_set_header X-Real-IP $remote_addr;
* proxy_set_header REMOTE-HOST $remote_addr;
* proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
* }
*/
public static String getIpAddress(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");

View File

@@ -59,6 +59,7 @@ public class RsaDecryptUtils {
/**
* 解密
*
* @param args
* @throws NoSuchAlgorithmException
*/

View File

@@ -8,15 +8,15 @@ public class SecurityContextUtils {
public static AuthPrincipalVo getCurrentUser() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication != null && authentication.getPrincipal() != null){
return (AuthPrincipalVo) authentication.getPrincipal();
if (authentication != null && authentication.getPrincipal() != null) {
return (AuthPrincipalVo) authentication.getPrincipal();
}
return null;
}
public static Long getCurrentUserId() {
AuthPrincipalVo currentUser = getCurrentUser();
if(currentUser != null){
if (currentUser != null) {
return currentUser.getId();
}
return null;
@@ -24,7 +24,7 @@ public class SecurityContextUtils {
public static String getCurrentUsername() {
AuthPrincipalVo currentUser = getCurrentUser();
if(currentUser != null){
if (currentUser != null) {
return currentUser.getUsername();
}
return null;

View File

@@ -65,8 +65,8 @@ public class SendEmailUtil {
public static Long BIND_MAILBOX_TEMPLATE_ID = 45619L;
public static Boolean send(String receiverAddress,String ip,Long templateId,String verifyCode) {
try{
public static Boolean send(String receiverAddress, String ip, Long templateId, String verifyCode) {
try {
// 实例化一个认证对象入参需要传入腾讯云账户secretIdsecretKey,此处还需注意密钥对的保密
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
@@ -85,30 +85,31 @@ public class SendEmailUtil {
req.setDestination(new String[]{receiverAddress});
String subject = templateId == LOGIN_TEMPLATE_ID ? LOGIN_SUBJECT :
templateId == UPDATE_PWD_TEMPLATE_ID ? FORGET_PWD_SUBJECT :
templateId == EXCEPTION_ID_TEMPLATE_ID ? EXCEPTION_ID_SUBJECT :BIND_MAILBOX_SUBJECT;
templateId == EXCEPTION_ID_TEMPLATE_ID ? EXCEPTION_ID_SUBJECT : BIND_MAILBOX_SUBJECT;
req.setSubject(subject);
req.setTemplate(contractTemplate(templateId, verifyCode,ip));
req.setTemplate(contractTemplate(templateId, verifyCode, ip));
// 返回的resp是一个SendEmailResponse的实例与请求对象对应
SendEmailResponse resp = client.SendEmail(req);
// 输出json格式的字符串回包
log.info("短信发送结果res###{}",SendEmailResponse.toJsonString(resp));
return Boolean.TRUE;
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
return Boolean.TRUE;
} catch (TencentCloudSDKException e) {
log.info("邮件发送失败###{}",e.toString());
log.info("邮件发送失败###{}", e.toString());
throw new BusinessException(e.getMessage());
}
}
private static Template contractTemplate(Long templateId,String verifyCode,String ip){
private static Template contractTemplate(Long templateId, String verifyCode, String ip) {
Template template = new Template();
template.setTemplateID(templateId);
JSONObject jsonObject = new JSONObject();
if(templateId == EXCEPTION_ID_TEMPLATE_ID ){
jsonObject.put("exceptionIp",ip);
jsonObject.put("loginTime",DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS));
}else{
jsonObject.put("code",verifyCode);
if (templateId == EXCEPTION_ID_TEMPLATE_ID) {
jsonObject.put("exceptionIp", ip);
jsonObject.put("loginTime", DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS));
} else {
jsonObject.put("code", verifyCode);
}
template.setTemplateData(jsonObject.toJSONString());
return template;

View File

@@ -27,18 +27,18 @@ public class SpringUtils implements ApplicationContextAware {
}
public static <T> T getBean(String beanName) {
if(applicationContext.containsBean(beanName)){
if (applicationContext.containsBean(beanName)) {
return (T) applicationContext.getBean(beanName);
}else{
} else {
return null;
}
}
public static <T> Map<String, T> getBeansOfType(Class<T> baseType){
public static <T> Map<String, T> getBeansOfType(Class<T> baseType) {
return applicationContext.getBeansOfType(baseType);
}
public static ApplicationContext getApplicationContext(){
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}

View File

@@ -30,10 +30,11 @@ public class AccountController {
public Response<AccountPreLoginVO> preLogin(@Valid @RequestBody AccountPreLoginDTO accountDTO) {
return Response.success(accountService.preLogin(accountDTO));
}
@ApiOperation(value = "登入")
@PostMapping("/login")
public Response<AccountLoginVO> login(@Valid @RequestBody AccountLoginDTO accountDTO, HttpServletRequest request) {
return Response.success(accountService.login(accountDTO,request));
return Response.success(accountService.login(accountDTO, request));
}
@ApiOperation(value = "绑定邮箱")
@@ -57,13 +58,13 @@ public class AccountController {
@ApiOperation(value = "登出")
@PostMapping("/logout")
public Response<Boolean> logout(@Valid @RequestBody AccountLogoutDTO accountLogoutDTO) {
return Response.success( accountService.logout(accountLogoutDTO));
return Response.success(accountService.logout(accountLogoutDTO));
}
@ApiOperation(value = "是否登入")
@PostMapping("/isLogin")
public Response<Boolean> isLogin(@Valid @RequestBody AccountLogoutDTO accountLogoutDTO) {
return Response.success( accountService.isLogin(accountLogoutDTO));
return Response.success(accountService.isLogin(accountLogoutDTO));
}
}

View File

@@ -42,6 +42,7 @@ public class DesignController {
public Response<DesignCollectionVO> reDesignCollection(@Valid @RequestBody ReDesignCollectionDTO reDesignDTO) {
return Response.success(designService.reDesignCollection(reDesignDTO));
}
@ApiOperation(value = "designItem list,刷新用")
@GetMapping("/designItemList")
public Response<DesignCollectionVO> designItemList(@ApiParam("designId") @RequestParam("designId") Long designId) {

View File

@@ -30,9 +30,10 @@ public class DesignDetailController {
@PostMapping("/generateHighDesign")
public Response<String> generateHighDesign(@Valid @RequestBody GenerateHighDesignDTO generateHighDesignDTO) {
Response response = new Response();
response.setData(designService. generateHighDesign(generateHighDesignDTO));
response.setData(designService.generateHighDesign(generateHighDesignDTO));
return response;
}
@ApiOperation(value = "删除高级design图片")
@PostMapping("/deleteHighDesign")
public Response<Boolean> deleteHighDesign(@Valid @RequestBody GenerateHighDesignDTO generateHighDesignDTO) {
@@ -40,11 +41,12 @@ public class DesignDetailController {
response.setData(designService.deleteHighDesign(generateHighDesignDTO));
return response;
}
@ApiOperation(value = "查询design详情")
@GetMapping("/getDetail")
public Response<DesignItemDetailVO> getDetail(@ApiParam("designItemId") @RequestParam("designItemId") Long designItemId,
@ApiParam("designPythonOutfitId") @RequestParam(value = "designPythonOutfitId",required = false) Long designPythonOutfitId) {
return Response.success(designService.detail(designPythonOutfitId,designItemId));
@ApiParam("designPythonOutfitId") @RequestParam(value = "designPythonOutfitId", required = false) Long designPythonOutfitId) {
return Response.success(designService.detail(designPythonOutfitId, designItemId));
}
@ApiOperation(value = "切换系统的element")
@@ -52,18 +54,19 @@ public class DesignDetailController {
public Response<GetNextSysElementVO> getNextSysElement(@ApiParam("要切换的系统element 类型") @RequestParam("type") String type,
@ApiParam("要切换的系统element id") @RequestParam("id") Long id,
@ApiParam("操作类型 PREV 上一步 NEXT 下一步") @RequestParam("operateType") String operateType) {
return Response.success(designItemService.getNextSysElement(id,type,operateType));
return Response.success(designItemService.getNextSysElement(id, type, operateType));
}
@ApiOperation(value = "单个design")
@PostMapping("/designSingle")
public Response<DesignSingleVO> designSingle(@Valid @RequestBody DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO ) {
public Response<DesignSingleVO> designSingle(@Valid @RequestBody DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
return Response.success(designItemService.designSingleIncludeLayers(designSingleIncludeLayersDTO));
}
@ApiOperation(value = "print打点")
@PostMapping("/printDot")
public Response<String> printDot(@Valid @RequestBody DesignSingleDTO designSingleDTO ) {
Response<String> response =new Response();
public Response<String> printDot(@Valid @RequestBody DesignSingleDTO designSingleDTO) {
Response<String> response = new Response();
String url = designItemService.printDot(designSingleDTO);
response.setData(url);
return response;

View File

@@ -53,7 +53,7 @@ public class ElementController {
@RequestParam(value = "level1Type") String level1Type,
@ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
@RequestParam(value = "timeZone") String timeZone) {
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()), "Please select a file!");
return Response.success(collectionElementService.upload(
new CollectionElementUploadDTO(file, level1Type, timeZone, MD5Utils.encryptFile(file))));
}
@@ -95,6 +95,7 @@ public class ElementController {
public Response<List<PantoneVO>> getRgbByHsvBatch(@RequestBody @Valid List<GetRgbByHsvBatchDTO> rgbByHsvBatch) {
return Response.success(panToneService.getRgbByHsvBatch(rgbByHsvBatch));
}
@ApiOperation(value = "刷新历史数据")
@PostMapping("/refreshHistoryData")
public Response<Boolean> refreshHistoryData() {

View File

@@ -30,20 +30,20 @@ public class GenerateController {
@ApiOperation("自动识别sketch的caption")
@PostMapping("/caption")
public Response<GenerateCaptionVO> generateCaption(@RequestParam Long sketchElementId){
public Response<GenerateCaptionVO> generateCaption(@RequestParam Long sketchElementId) {
return Response.success(generateService.generateCaption(sketchElementId));
}
@ApiOperation("通过文字、图片生成图片")
@PostMapping("/sketchAndPrint")
public Response<GenerateCollectionVO> generateThroughImageText(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO){
public Response<GenerateCollectionVO> generateThroughImageText(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) {
return Response.success(generateService.generateThroughImageText(generateThroughImageTextDTO));
}
@ApiOperation("喜欢生成的图片")
@PostMapping("/like")
public Response<GenerateLikeVO> like(@Valid @RequestBody GenerateLikeDTO generateLikeDTO){
public Response<GenerateLikeVO> like(@Valid @RequestBody GenerateLikeDTO generateLikeDTO) {
return Response.success(generateService.generateLike(generateLikeDTO));
}
@@ -51,7 +51,7 @@ public class GenerateController {
@GetMapping("/dislike")
public Response<Boolean> dislike(@ApiParam("generateDetailId") @RequestParam Long generateDetailId,
@ApiParam("timeZone") @RequestParam String timeZone) {
return Response.success(generateService.generateDislike(generateDetailId,timeZone));
return Response.success(generateService.generateDislike(generateDetailId, timeZone));
}
}

View File

@@ -57,31 +57,31 @@ public class LibraryController {
@ApiOperation(value = "Library分页列表")
@PostMapping("/queryLibraryPage")
public Response<PageBaseResponse<QueryLibraryPageVO>> queryLibraryPage(@Valid @RequestBody QueryLibraryPageDTO query) {
return Response.success(libraryService.queryLibraryPage(CopyUtil.copyObject(query,QueryLibraryPageServiceDTO.class)));
return Response.success(libraryService.queryLibraryPage(CopyUtil.copyObject(query, QueryLibraryPageServiceDTO.class)));
}
@ApiOperation(value = "Library分页列表(查询top和bottom)")
@PostMapping("/queryLibraryTopAndBottomPage")
public Response<PageBaseResponse<QueryLibraryPageVO>> queryLibraryTopAndBottomPage(@Valid @RequestBody QueryLibraryTopPageDTO query) {
return Response.success(libraryService.queryLibraryPage(CopyUtil.copyObject(query,QueryLibraryPageServiceDTO.class)));
return Response.success(libraryService.queryLibraryPage(CopyUtil.copyObject(query, QueryLibraryPageServiceDTO.class)));
}
@ApiOperation(value = "Library文件上传")
@PostMapping("/upload")
public Response<LibraryUpdateVo> upload(@RequestParam("file") MultipartFile file,
@ApiParam("一级类型 Moodboard Printboard Sketchboard MarketingSketch Models")
@RequestParam(value = "level1Type") String level1Type,
@RequestParam(value = "level1Type") String level1Type,
@ApiParam("二级类型 争对 Sketchboard; 有 Outwear Dress Blouse Skirt Trousers")
@RequestParam(value = "level2Type",required = false) String level2Type,
@RequestParam(value = "level2Type", required = false) String level2Type,
@ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
@RequestParam(value = "timeZone") String timeZone,
@RequestParam(value = "timeZone") String timeZone,
@RequestParam(value = "modelType") String modelType,
@RequestParam(value = "sex") String sex,
@RequestParam(value = "checkMd5") Integer checkMd5) {
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
Integer high =null;
Integer width =null;
if(level1Type.equals(LibraryLevel1TypeEnum.MODELS.getRealName())){
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()), "Please select a file!");
Integer high = null;
Integer width = null;
if (level1Type.equals(LibraryLevel1TypeEnum.MODELS.getRealName())) {
if (StringUtils.isEmpty(modelType)) {
throw new BusinessException("modelType can't be null");
}
@@ -100,14 +100,16 @@ public class LibraryController {
return Response.success(libraryUpdateVo);
}
}
return Response.success(libraryService.upload(new LibraryUploadDTO(file, level1Type,level2Type,
timeZone, md5,high,width,modelType,sex)));
return Response.success(libraryService.upload(new LibraryUploadDTO(file, level1Type, level2Type,
timeZone, md5, high, width, modelType, sex)));
}
@ApiOperation(value = "保存或者编辑template打点")
@PostMapping("/saveOrEditTemplatePoint")
public Response<LibraryModelPointVO> saveOrEditTemplatePoint(@Valid @RequestBody LibraryModelPointDTO libraryModelPoint) {
return Response.success(libraryModelPointService.saveOrEditTemplatePoint(libraryModelPoint));
}
@ApiOperation(value = "批量Library修改用户文件名")
@PostMapping("/batchUpdateLibraryName")
public Response<Boolean> batchUpdateLibraryName(@Valid @RequestBody LibraryUpdateDTO libraryUpdateDTO) {
@@ -119,7 +121,7 @@ public class LibraryController {
@PostMapping("/batchDeleteLibrary")
public Response<Boolean> batchDeleteLibrary(@Valid @RequestBody LibraryDeleteDTO deleteDTO) {
List<Library> librarys = libraryService.getByIds(deleteDTO.getLibraryIds());
Assert.notEmpty(librarys,"librarys does not exist!");
Assert.notEmpty(librarys, "librarys does not exist!");
libraryService.removeBatchByIds(deleteDTO.getLibraryIds());
for (Library library : librarys) {
if (library.getUrl().startsWith(sysImage)) {
@@ -133,10 +135,10 @@ public class LibraryController {
@ApiOperation(value = "Models打点预览")
@PostMapping("/modelsDot")
public Response<String> modelsDot(@ApiParam("file") @RequestPart(value = "file",required = false) MultipartFile file,
@ApiParam("models对象")@RequestPart("models") ModelsDotDTO modelsDotDTO) {
if(Objects.nonNull(file)){
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
public Response<String> modelsDot(@ApiParam("file") @RequestPart(value = "file", required = false) MultipartFile file,
@ApiParam("models对象") @RequestPart("models") ModelsDotDTO modelsDotDTO) {
if (Objects.nonNull(file)) {
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()), "Please select a file!");
AuthPrincipalVo userInfo = UserContext.getUserHolder();
//需要宽高和地址参数design
FileVO fileVO = FileUtil.getFileSize(file);
@@ -147,18 +149,18 @@ public class LibraryController {
String uploadPath = minioUtil.upload("aida-tmp", path, file);
String minioPath = libraryService.processMannequins(uploadPath);
modelsDotDTO.setTemplateUrl(minioPath);
}else{
Assert.notNull(modelsDotDTO.getLibraryId(),"libraryId cannot be empty!");
Assert.notNull(modelsDotDTO.getTemplateId(),"templateId cannot be empty!");
} else {
Assert.notNull(modelsDotDTO.getLibraryId(), "libraryId cannot be empty!");
Assert.notNull(modelsDotDTO.getTemplateId(), "templateId cannot be empty!");
LibraryModelPoint modelPoint = libraryModelPointService.getById(modelsDotDTO.getTemplateId());
Assert.notNull(modelPoint,"template does not exist!");
Assert.notNull(modelPoint, "template does not exist!");
Library library = libraryService.getById(modelsDotDTO.getLibraryId());
Assert.notNull(library,"library does not exist!");
Assert.notNull(library, "library does not exist!");
modelsDotDTO.setHigh(library.getHigh());
modelsDotDTO.setWidth(library.getWidth());
modelsDotDTO.setTemplateUrl(library.getUrl());
}
Response<String> response =new Response();
Response<String> response = new Response();
log.info("Models打点预览入参####{}", JSON.toJSONString(modelsDotDTO));
String url = libraryModelPointService.modelsDot(modelsDotDTO);
response.setData(minioUtil.getPresignedUrl(url, 24 * 60));
@@ -174,14 +176,14 @@ public class LibraryController {
private String calculateTempFileUrl(Long userId) {
String rootPath = fileProperties.getSys().getPath();
String day = DateUtil.dateToStr(new Date(), DateUtil.YYYYMM);
return rootPath + day + File.separator + "tmp" + File.separator + userId + File.separator+ UUID.randomUUID().toString();
return rootPath + day + File.separator + "tmp" + File.separator + userId + File.separator + UUID.randomUUID().toString();
}
private String calculateTempFileUrlNew(Long userId) {
return userId.toString();
}
private String calculateTemplateUrl(File uploadFile){
private String calculateTemplateUrl(File uploadFile) {
String linuxDomain = fileProperties.getLinuxDomain();
if (!StringUtils.isEmpty(linuxDomain)) {
//linux 系统

View File

@@ -51,7 +51,7 @@ public class PythonController {
@PostMapping("/saveGeneratePicture")
public Response<String> upload(@RequestParam("file") MultipartFile file,
@ApiParam("操作类型 generatePrint ->生成印花 " +
"designCollection ->设计collection generateAdvancedDesign ->生成高级design"+
"designCollection ->设计collection generateAdvancedDesign ->生成高级design" +
"generateSketch -> 生成草图")
@RequestParam(value = "operateType") String operateType) {
return Response.success(pythonService.upload(file, operateType));
@@ -60,10 +60,10 @@ public class PythonController {
@ApiOperation(value = "python服务保存多张图片到java服务")
@PostMapping("/saveMultiGeneratePicture")
public Response<List<String>> uploadMultiple(@RequestParam("files") MultipartFile[] files,
@ApiParam("操作类型 generatePrint ->生成印花 " +
"designCollection ->设计collection generateAdvancedDesign ->生成高级design"+
"generateSketch -> 生成草图")
@RequestParam(value = "operateType") String operateType) {
@ApiParam("操作类型 generatePrint ->生成印花 " +
"designCollection ->设计collection generateAdvancedDesign ->生成高级design" +
"generateSketch -> 生成草图")
@RequestParam(value = "operateType") String operateType) {
return Response.success(pythonService.upload(files, operateType));
}

View File

@@ -58,32 +58,32 @@ public class SavedCollectionController {
QueryWrapper<UserLikeGroup> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", authPrincipalVo.getId());
if(!StringUtils.isEmpty(query.getCollectionName())){
if (!StringUtils.isEmpty(query.getCollectionName())) {
queryWrapper.like("name", query.getCollectionName());
}
if(Objects.nonNull(query.getStartDate())){
if (Objects.nonNull(query.getStartDate())) {
queryWrapper.ge("update_date", new Date(query.getStartDate()));
}
if(Objects.nonNull(query.getEndDate())){
if (Objects.nonNull(query.getEndDate())) {
queryWrapper.le("update_date", new Date(query.getEndDate()));
}
queryWrapper.orderByDesc("id");
IPage<UserLikeGroup> page = userLikeGroupService.getBaseMapper().selectPage(
new Page<>(query.getPage(), query.getSize()), queryWrapper);
if(CollectionUtils.isEmpty(page.getRecords())){
if (CollectionUtils.isEmpty(page.getRecords())) {
return Response.success(PageBaseResponse.success(new Page<>()));
}
List<Long> groupIds = page.getRecords().stream().map(UserLikeGroup::getId).collect(Collectors.toList());
List<UserLikeVO> groupDetails = userLikeService.getGroupDetails(groupIds);
Assert.notEmpty(groupDetails,"History detail does not exist!");
Map<Long,List<UserLikeVO>> groupDetailMap = groupDetails.stream()
Assert.notEmpty(groupDetails, "History detail does not exist!");
Map<Long, List<UserLikeVO>> groupDetailMap = groupDetails.stream()
.collect(Collectors.groupingBy(UserLikeVO::getUserLikeGroupId));
Account account = accountService.getById(authPrincipalVo.getId());
Account account = accountService.getById(authPrincipalVo.getId());
IPage<UserLikeGroupVO> convert = page.convert((Function<UserLikeGroup, UserLikeGroupVO>) group -> {
if(group != null){
UserLikeGroupVO userLikeGroupVO = CopyUtil.copyObject(group,UserLikeGroupVO.class);
userLikeGroupVO.setUpdateDate(group.getUpdateDate().getTime());
if (group != null) {
UserLikeGroupVO userLikeGroupVO = CopyUtil.copyObject(group, UserLikeGroupVO.class);
userLikeGroupVO.setUpdateDate(group.getUpdateDate().getTime());
userLikeGroupVO.setAuthor(account.getUserName());
//count 和detail
List<UserLikeVO> details = groupDetailMap.get(group.getId());
@@ -91,7 +91,7 @@ public class SavedCollectionController {
detail.setUrl(minioUtil.getPresignedUrl(detail.getUrl(), 24 * 60));
}
userLikeGroupVO.setGroupDetails(details);
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 :details.size());
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size());
return userLikeGroupVO;
}
return null;
@@ -110,7 +110,7 @@ public class SavedCollectionController {
@PostMapping("/updateUserGroupName")
public Response<HistoryUpdateVO> updateUserGroupName(@Valid @RequestBody HistoryUpdateDTO historyUpdateDTO) {
return Response.success(userLikeGroupService.updateUserGroupName(historyUpdateDTO.getUserGroupId()
,historyUpdateDTO.getUserGroupName(),historyUpdateDTO.getTimeZone()));
, historyUpdateDTO.getUserGroupName(), historyUpdateDTO.getTimeZone()));
}
@ApiOperation(value = "History删除用户分组")
@@ -124,7 +124,7 @@ public class SavedCollectionController {
@ApiOperation(value = "History choose")
@GetMapping("/choose")
public Response<UserLikeChooseVO> choose(
@ApiParam("用户分组id") @RequestParam("userGroupId") Long userGroupId) {
@ApiParam("用户分组id") @RequestParam("userGroupId") Long userGroupId) {
return Response.success(userLikeGroupService.choose(userGroupId));
}

View File

@@ -34,7 +34,7 @@ public class ThirdPartyController {
@ApiOperation(value = "Edit user information")
@PostMapping("/editUser")
public Response<Boolean> editUser( @RequestBody AccountEditDTO accountEditDTO) {
public Response<Boolean> editUser(@RequestBody AccountEditDTO accountEditDTO) {
return Response.success(accountService.editUser(accountEditDTO));
}

View File

@@ -27,7 +27,7 @@ import java.io.FileNotFoundException;
import java.util.List;
/**
* 控制器
* 控制器
*
* @author SHAHAIBO
* @since 2023-08-01
@@ -39,90 +39,90 @@ import java.util.List;
@Api(value = "", tags = "接口")
public class WorkspaceController {
@Resource
private WorkspaceService workspaceService;
@Resource
private WorkspaceService workspaceService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入workspace")
public Response<Workspace> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
Workspace detail = workspaceService.getByIdNew(id);
return Response.success(detail);
}
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入workspace")
public Response<Workspace> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
Workspace detail = workspaceService.getByIdNew(id);
return Response.success(detail);
}
/**
* 分页
*/
@PostMapping("/list")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入workspace")
public Response<WorkspaceVO> list(@Valid @RequestBody WorkspaceDTO query) {
WorkspaceVO response = workspaceService.getPage(query);
return Response.success(response);
}
/**
* 分页
*/
@PostMapping("/list")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入workspace")
public Response<WorkspaceVO> list(@Valid @RequestBody WorkspaceDTO query) {
WorkspaceVO response = workspaceService.getPage(query);
return Response.success(response);
}
/**
* 新增或编辑
*/
@PostMapping("/saveOrUpdate")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "新增或编辑", notes = "传入workspace")
public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) {
return Response.success(workspaceService.saveOrUpdate(workspace));
}
/**
* 删除
*/
@DeleteMapping("/remove")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "删除", notes = "传入id")
public Response<List<Long>> remove(@Valid @RequestBody List<Workspace> workspaceList) {
return Response.success(workspaceService.delete(workspaceList));
}
@GetMapping("/enumValues")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "获取枚举类值")
public Response<List<BizJson>> enumValues(@RequestParam("enumName") String enumName) {
List<BizJson> bizJsonList = workspaceService.getEnumValues(enumName);
return Response.success(bizJsonList);
}
@GetMapping("/getMannequins")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "获取模特")
public Response<List<ModelsVO>> getMannequins(@RequestParam("sex") String sex) {
List<ModelsVO> modelsVO = workspaceService.getMannequins(sex);
return Response.success(modelsVO);
}
/**
* 新增或编辑
*/
@PostMapping("/saveOrUpdate")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "新增或编辑", notes = "传入workspace")
public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) {
return Response.success(workspaceService.saveOrUpdate(workspace));
}
@PostMapping("system_file_copy")
@ApiOperationSupport(order = 7)
/**
* 删除
*/
@DeleteMapping("/remove")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "删除", notes = "传入id")
public Response<List<Long>> remove(@Valid @RequestBody List<Workspace> workspaceList) {
return Response.success(workspaceService.delete(workspaceList));
}
@GetMapping("/enumValues")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "获取枚举类值")
public Response<List<BizJson>> enumValues(@RequestParam("enumName") String enumName) {
List<BizJson> bizJsonList = workspaceService.getEnumValues(enumName);
return Response.success(bizJsonList);
}
@GetMapping("/getMannequins")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "获取模特")
public Response<List<ModelsVO>> getMannequins(@RequestParam("sex") String sex) {
List<ModelsVO> modelsVO = workspaceService.getMannequins(sex);
return Response.success(modelsVO);
}
@PostMapping("system_file_copy")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "minio数据迁移")
public Response<Boolean> systemFileCopy() {
workspaceService.systemFileCopy();
return Response.success(true);
}
workspaceService.systemFileCopy();
return Response.success(true);
}
@PostMapping("moveFile")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "增加一级性别路径")
public Response<Boolean> moveFile() {
workspaceService.moveFile();
return Response.success(true);
}
@PostMapping("moveFile")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "增加一级性别路径")
public Response<Boolean> moveFile() {
workspaceService.moveFile();
return Response.success(true);
}
@PostMapping("maleDataInsert")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "男装数据入库入minio")
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
workspaceService.maleDataInsert();
return Response.success(true);
}
@PostMapping("maleDataInsert")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "男装数据入库入minio")
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
workspaceService.maleDataInsert();
return Response.success(true);
}
}

View File

@@ -15,13 +15,13 @@ import java.util.List;
*/
public interface TDesignPythonOutfitDetailMapper extends CommonMapper<TDesignPythonOutfitDetail> {
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfitDetail
* @return
*/
List<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfitDetail
* @return
*/
List<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
}

View File

@@ -5,6 +5,7 @@ import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.entity.TDesignPythonOutfit;
import com.ai.da.model.vo.TDesignPythonOutfitVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
@@ -15,13 +16,13 @@ import java.util.List;
*/
public interface TDesignPythonOutfitMapper extends CommonMapper<TDesignPythonOutfit> {
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfit
* @return
*/
List<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage page, TDesignPythonOutfitVO tDesignPythonOutfit);
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfit
* @return
*/
List<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage page, TDesignPythonOutfitVO tDesignPythonOutfit);
}

View File

@@ -8,20 +8,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* Mapper 接口
* Mapper 接口
*
* @author SHAHAIBO
* @since 2023-08-01
*/
public interface WorkspaceMapper extends CommonMapper<Workspace> {
/**
* 自定义分页
*
* @param page
* @param workspace
* @return
*/
List<WorkspaceVO> selectWorkspacePage(IPage page, WorkspaceVO workspace);
/**
* 自定义分页
*
* @param page
* @param workspace
* @return
*/
List<WorkspaceVO> selectWorkspacePage(IPage page, WorkspaceVO workspace);
}

View File

@@ -33,7 +33,6 @@ public class Collection implements Serializable {
/**
* 用户ID
*
*/
private Long accountId;

View File

@@ -33,7 +33,6 @@ public class CollectionElement implements Serializable {
/**
* 用户ID
*
*/
private Long accountId;
/**

View File

@@ -31,7 +31,6 @@ public class DesignHistory implements Serializable {
private Long id;
/**
* 用户ID
*
*/
private Long accountId;

View File

@@ -58,7 +58,7 @@ public class DesignItem implements Serializable {
*/
private String highDesignUrl;
/**
* 是否like 0 否 1是
* 是否like 0 否 1是
*/
@TableField("is_like")
private Byte hasLike;

View File

@@ -53,7 +53,4 @@ public class GenerateDetail {
private Date updateDate;
}

View File

@@ -33,7 +33,6 @@ public class Library implements Serializable {
/**
* 用户ID
*
*/
private Long accountId;

View File

@@ -66,7 +66,7 @@ public class PanTone implements Serializable {
private Integer s;
/**
*V
* V
*/
private Integer v;
}

View File

@@ -44,19 +44,16 @@ public class SysFile implements Serializable {
/**
* 名字
*
*/
private String name;
/**
* md5值
*
*/
private String md5;
/**
* 路径 绝对路径
*
*/
private String url;
@@ -73,7 +70,7 @@ public class SysFile implements Serializable {
public SysFile() {
}
public SysFile(String level1Type, String level2Type, String name, String md5, String url,Date createDate) {
public SysFile(String level1Type, String level2Type, String name, String md5, String url, Date createDate) {
this.level1Type = level1Type;
this.level2Type = level2Type;
this.name = name;

View File

@@ -19,5 +19,5 @@ public class DesignAttributeRetrievalDTO {
private List<String> libraryUrls = Lists.newArrayList();
@ApiModelProperty("sysFile图片 数组")
private List<String> sysFileUrlS= Lists.newArrayList();
private List<String> sysFileUrlS = Lists.newArrayList();
}

View File

@@ -57,4 +57,4 @@ public class DesignCollectionDTO {
private String processId;
}
}

View File

@@ -7,7 +7,7 @@ import javax.validation.constraints.NotBlank;
import java.util.List;
@Data
public class DesignSingleItemDTO {
public class DesignSingleItemDTO {
@NotBlank(message = "id cannot be empty!")
@ApiModelProperty("切换图片对应的id")

View File

@@ -17,7 +17,7 @@ public class EmailSendDTO {
@NotBlank(message = "operationType cannot be empty")
@ApiModelProperty("操作类型 LOGIN 注册 FORGET_PWD 忘记密码 BIND_MAILBOX 绑定邮箱")
private String operationType;
@ApiModelProperty("异常ip")
private String ip;

View File

@@ -15,7 +15,7 @@ public class LibraryDeleteDTO {
@NotEmpty(message = "libraryIds cannot be empty!")
@Size(max = 100,min = 1)
@Size(max = 100, min = 1)
@ApiModelProperty("libraryId数组")
private List<Long> libraryIds;

View File

@@ -15,7 +15,7 @@ import java.util.List;
public class LibraryUpdateDTO {
@NotEmpty(message = "libraryIds cannot be empty!")
@Size(max = 100,min = 1)
@Size(max = 100, min = 1)
@ApiModelProperty("libraryId数组")
private List<Long> libraryIds;

View File

@@ -15,6 +15,6 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class WorkspaceDTO extends PageQueryBaseVo {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
}

View File

@@ -11,7 +11,8 @@ public class BizJson implements Serializable {
private static final long serialVersionUID = 1L;
public BizJson() {}
public BizJson() {
}
public BizJson(String name, String key, String value) {
this.name = name;

View File

@@ -13,8 +13,7 @@ public enum FemalePosition implements IEnumDisplay {
BLOUSE("Blouse"),
DRESS("Dress"),
TROUSERS("Trousers"),
SKIRT("Skirt")
;
SKIRT("Skirt");
private String value;

View File

@@ -11,8 +11,7 @@ public enum MalePosition implements IEnumDisplay {
TOPS("Tops"),
BOTTOMS("Bottoms"),
OUTWEAR("Outwear")
;
OUTWEAR("Outwear");
private String value;

View File

@@ -10,8 +10,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
public enum MannequinType implements IEnumDisplay {
SYSTEM("System"),
LIBRARY("Library")
;
LIBRARY("Library");
private String value;

View File

@@ -11,8 +11,7 @@ public enum ModelType implements IEnumDisplay {
SYSTEM("System"),
LIBRARY("Library")
;
LIBRARY("Library");
private String value;

View File

@@ -41,5 +41,4 @@ public class DesignLibraryModelPointVO implements Serializable {
private String templateUrl;
}

View File

@@ -22,10 +22,10 @@ public class DesignSinglePrint {
private List<Double> location;
@ApiModelProperty("印花大小")
@Range(max = 1,message = "印花缩放值需用大于等于0小于等于1的数表示")
@Range(max = 1, message = "印花缩放值需用大于等于0小于等于1的数表示")
private Double scale;
@Range(min = -360,max = 360,message = "印花旋转角度范围为-360° ~ 360°")
@Range(min = -360, max = 360, message = "印花旋转角度范围为-360° ~ 360°")
@ApiModelProperty("印花角度")
private Double angle;

View File

@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
@AllArgsConstructor
@Data
@ApiModel("HistoryUpdateVO-响应")

View File

@@ -46,5 +46,5 @@ public class LibraryUpdateVo implements Serializable {
@ApiModelProperty("校验md5")
private Boolean checkMd5;
}

View File

@@ -28,7 +28,6 @@ public class LibraryVo implements Serializable {
/**
* 用户ID
*
*/
private Long accountId;
/**

View File

@@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
@NoArgsConstructor
@Data
@ApiModel("潘通-响应")

View File

@@ -30,7 +30,6 @@ public class SysFileVO implements Serializable {
/**
* md5值
*
*/
private String md5;

View File

@@ -16,6 +16,6 @@ import io.swagger.annotations.ApiModel;
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "TDesignPythonOutfitDetailVO对象", description = "design item详情表")
public class TDesignPythonOutfitDetailVO extends TDesignPythonOutfitDetail {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
}

View File

@@ -17,6 +17,6 @@ import io.swagger.annotations.ApiModel;
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "TDesignPythonOutfitVO对象", description = "design item表 存对应design的8张图片")
public class TDesignPythonOutfitVO extends TDesignPythonOutfit {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
}

View File

@@ -31,13 +31,13 @@ public class ValidateElementVO {
//用于存储generate 生成collection
List<CollectionElement> generateCollectionElements = Lists.newArrayList();
//存储template打点数据
DesignLibraryModelPointVO designLibraryModelPoint =null;
DesignLibraryModelPointVO designLibraryModelPoint = null;
//存储本次design已经使用的上衣和下衣的的MD5list 去重用
List<String> hasUseMd5List = Lists.newArrayList() ;
List<String> hasUseMd5List = Lists.newArrayList();
//存储本次design已经使用的系统上衣下衣的id
List<Long> sysFileIds = Lists.newArrayList() ;
List<Long> sysFileIds = Lists.newArrayList();
//存储本次design剩余的没有Pin的print
Long noPinPrintNum ;
Long noPinPrintNum;
//透传print参数用,存储本地Print对象
DesignPythonItemPrint designPythonItemPrint;
//透传print参数用

View File

@@ -62,7 +62,7 @@ public class PythonService {
*/
public String generatePrint(List<String> printPath) {
//限流校验
AccessLimitUtils.validate("generatePrint",2);
AccessLimitUtils.validate("generatePrint", 2);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -156,7 +156,7 @@ public class PythonService {
String path = calculateFileUrl(operationType);
for (MultipartFile file : files) {
File generateFile = FileUtil.upload2(file, path);
Assert.notNull(generateFile,"An error occurred while processing the file, please try again later");
Assert.notNull(generateFile, "An error occurred while processing the file, please try again later");
String linuxDomain = fileProperties.getLinuxDomain();
if (!StringUtils.isEmpty(linuxDomain)) {
@@ -409,7 +409,7 @@ public class PythonService {
if (Objects.nonNull(skirt)) {
items.add(skirt);
}
}else {
} else {
// 男装逻辑
DesignPythonItem top = calculatePythonItemTop(pinData, elementVO, designPictureType);
if (Objects.nonNull(top)) {
@@ -494,7 +494,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
bottom = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
bottom.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -524,7 +524,7 @@ public class PythonService {
DesignPythonItem.BOTTOMS, elementVO.getHasUseMd5List());
if (StringUtils.isEmpty(libraryVo)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
bottom = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
bottom.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -547,7 +547,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
bottom = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
bottom.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -578,7 +578,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary(noPinData, elementVO.getHasUseMd5List());
if (Objects.isNull(collectionElement)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleBottoms(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
bottom = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
bottom.setBusinessId(sysFileVO.getId());
} else {
@@ -661,7 +661,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
top = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
top.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -691,7 +691,7 @@ public class PythonService {
DesignPythonItem.TOPS, elementVO.getHasUseMd5List());
if (StringUtils.isEmpty(libraryVo)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
top = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
top.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -714,7 +714,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
top = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
top.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -745,7 +745,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary(noPinData, elementVO.getHasUseMd5List());
if (Objects.isNull(collectionElement)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileMaleTops(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
top = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
top.setBusinessId(sysFileVO.getId());
} else {
@@ -864,7 +864,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
skirt = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
skirt.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -894,7 +894,7 @@ public class PythonService {
DesignPythonItem.SKIRT_TROUSERS, elementVO.getHasUseMd5List());
if (StringUtils.isEmpty(libraryVo)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
skirt = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
skirt.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -917,7 +917,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
skirt = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
skirt.setBusinessId(sysFileVO.getId());
//添加已使用的md5
@@ -948,7 +948,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary(noPinData, elementVO.getHasUseMd5List());
if (Objects.isNull(collectionElement)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileSkirt(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
skirt = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
skirt.setBusinessId(sysFileVO.getId());
} else {
@@ -1033,7 +1033,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
DesignPythonItem item = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
item.setBusinessId(sysFileVO.getId());
items.add(item);
@@ -1065,7 +1065,7 @@ public class PythonService {
DesignPythonItem.OUTWEAR_DRESS_BLOUSE, elementVO.getHasUseMd5List());
if (StringUtils.isEmpty(libraryVo)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
DesignPythonItem item = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
item.setBusinessId(sysFileVO.getId());
items.add(item);
@@ -1090,7 +1090,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
DesignPythonItem item = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
item.setBusinessId(sysFileVO.getId());
items.add(item);
@@ -1122,7 +1122,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary(noPinData, elementVO.getHasUseMd5List());
if (Objects.isNull(collectionElement)) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(),elementVO.getSysFileIds(), elementVO.getModelSex());
SysFileVO sysFileVO = getRandomSysFileOutwear(elementVO.getSysFileVo(), elementVO.getSysFileIds(), elementVO.getModelSex());
DesignPythonItem item = coverToDesignPythonItem(null, sysFileVO.getLevel2Type(), sysFileVO.getUrl(), elementVO);
item.setBusinessId(sysFileVO.getId());
items.add(item);
@@ -1194,7 +1194,7 @@ public class PythonService {
Map<String, List<Integer>> body_point = Maps.newHashMap();
if (Objects.nonNull(designLibraryModelPointOld)) {
DesignLibraryModelPointVO designLibraryModelPoint =
CopyUtil.copyObject(designLibraryModelPointOld,DesignLibraryModelPointVO.class);
CopyUtil.copyObject(designLibraryModelPointOld, DesignLibraryModelPointVO.class);
//自己的template是6个点
body_point.put("shoulder_left", resolve(designLibraryModelPoint.getShoulderLeft()));
body_point.put("shoulder_right", resolve(designLibraryModelPoint.getShoulderRight()));
@@ -1224,7 +1224,7 @@ public class PythonService {
private List<Integer> resolve(List<BigDecimal> list) {
List<Integer> integerList = Lists.newArrayList();
list.forEach(l ->{
list.forEach(l -> {
integerList.add(new Integer(l.intValue()));
});
return integerList;
@@ -1283,41 +1283,41 @@ public class PythonService {
private SysFileVO getRandomSysFileOutwear(List<SysFileVO> sysFileVo, List<Long> sysFileIds, String modelSex) {
Long randomIndex = RandomsUtil.randomSysFile(0L, 3L);
if(CollectionUtils.isEmpty(sysFileVo)){
if (CollectionUtils.isEmpty(sysFileVo)) {
return getRandomSysFileByLevel2Type(DesignPythonItem.OUTWEAR_DRESS_BLOUSE.get(randomIndex.intValue()), sysFileIds, modelSex);
}else{
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.OUTWEAR_DRESS_BLOUSE,sysFileVo, sysFileIds);
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.OUTWEAR_DRESS_BLOUSE, sysFileVo, sysFileIds);
}
}
private SysFileVO getRandomSysFileMaleTops(List<SysFileVO> sysFileVo, List<Long> sysFileIds, String modelSex) {
Long randomIndex = RandomsUtil.randomSysFile(0L, 1L);
if(CollectionUtils.isEmpty(sysFileVo)){
if (CollectionUtils.isEmpty(sysFileVo)) {
return getRandomSysFileByLevel2Type(DesignPythonItem.TOPS.get(randomIndex.intValue()), sysFileIds, modelSex);
}else{
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.TOPS,sysFileVo, sysFileIds);
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.TOPS, sysFileVo, sysFileIds);
}
}
private SysFileVO getRandomSysFileMaleBottoms(List<SysFileVO> sysFileVo, List<Long> sysFileIds, String modelSex) {
Long randomIndex = RandomsUtil.randomSysFile(0L, 1L);
if(CollectionUtils.isEmpty(sysFileVo)){
if (CollectionUtils.isEmpty(sysFileVo)) {
return getRandomSysFileByLevel2Type(DesignPythonItem.BOTTOMS.get(randomIndex.intValue()), sysFileIds, modelSex);
}else{
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.BOTTOMS,sysFileVo, sysFileIds);
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.BOTTOMS, sysFileVo, sysFileIds);
}
}
private SysFileVO getRandomSysFileSkirt(List<SysFileVO> sysFileVo, List<Long> sysFileIds, String modelSex) {
Long randomIndex = RandomsUtil.randomSysFile(0L, 2L);
if(CollectionUtils.isEmpty(sysFileVo)){
if (CollectionUtils.isEmpty(sysFileVo)) {
return getRandomSysFileByLevel2Type(DesignPythonItem.SKIRT_TROUSERS.get(randomIndex.intValue()), sysFileIds, modelSex);
}else{
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.SKIRT_TROUSERS,sysFileVo, sysFileIds);
return getRandomSysFileByAttributeRetrieval(DesignPythonItem.SKIRT_TROUSERS, sysFileVo, sysFileIds);
}
}
@@ -1331,9 +1331,10 @@ public class PythonService {
sysFileIds.add(sysFileId);
return sysFileService.getById(sysFileId);
}
private SysFileVO getRandomSysFileByAttributeRetrieval(List<String> level2TypeList,List<SysFileVO> sysFileVo,List<Long> sysFileIds) {
private SysFileVO getRandomSysFileByAttributeRetrieval(List<String> level2TypeList, List<SysFileVO> sysFileVo, List<Long> sysFileIds) {
sysFileVo = sysFileVo.stream().filter(
f ->level2TypeList.contains(f.getLevel2Type()) && ( !sysFileIds.contains(f.getId())) )
f -> level2TypeList.contains(f.getLevel2Type()) && (!sysFileIds.contains(f.getId())))
.collect(Collectors.toList());
Long maxId = (long) sysFileVo.size();
Long minId = 0L;
@@ -1456,7 +1457,7 @@ public class PythonService {
*/
public Boolean design(DesignPythonObjects designPythonObjects) {
//限流校验
AccessLimitUtils.validate("design",5);
AccessLimitUtils.validate("design", 5);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -1509,7 +1510,7 @@ public class PythonService {
*/
public String generateHighDesign(String designPath) {
//限流校验
AccessLimitUtils.validate("generateHighDesign",2);
AccessLimitUtils.validate("generateHighDesign", 2);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -1550,6 +1551,7 @@ public class PythonService {
//生成失败
throw new BusinessException("system error!");
}
/**
* 生成 attribute_retrieval
*
@@ -1557,9 +1559,9 @@ public class PythonService {
* @param modelSex
* @return
*/
public DesignAttributeRetrievalDTO generateAttributeRetrieval(List<String> sketchUrlList, Long userId, String modelSex) {
public DesignAttributeRetrievalDTO generateAttributeRetrieval(List<String> sketchUrlList, Long userId, String modelSex) {
//限流校验
AccessLimitUtils.validate("generateAttributeRetrieval",4);
AccessLimitUtils.validate("generateAttributeRetrieval", 4);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -1603,34 +1605,35 @@ public class PythonService {
//生成失败
throw new BusinessException("system error!");
}
private static DesignAttributeRetrievalDTO resolveDesignAttributeRetrievalDTO(String bodyStr){
private static DesignAttributeRetrievalDTO resolveDesignAttributeRetrievalDTO(String bodyStr) {
DesignAttributeRetrievalDTO response = new DesignAttributeRetrievalDTO();
JSONObject jsonObject = JSON.parseObject(bodyStr);
JSONObject data = jsonObject.getJSONObject("data");
if (data != null) {
JSONObject jsonObjectSys = data.getJSONObject("sys_lib_dict");
if(null == jsonObjectSys || jsonObjectSys.size() == 0){
if (null == jsonObjectSys || jsonObjectSys.size() == 0) {
log.error("generateAttributeRetrieval异常###{}", "jsonObjectSys is empty!");
throw new BusinessException("system error!");
}
setUrls(jsonObjectSys,response.getSysFileUrlS());
setUrls(jsonObjectSys, response.getSysFileUrlS());
JSONObject jsonObjectLibrary = data.getJSONObject("user_lib_dict");
if(null == jsonObjectLibrary || jsonObjectLibrary.size() == 0){
if (null == jsonObjectLibrary || jsonObjectLibrary.size() == 0) {
log.error("generateAttributeRetrieval异常###{}", "jsonObjectLibrary is empty!");
throw new BusinessException("system error!");
}
setUrls(jsonObjectLibrary,response.getLibraryUrls());
setUrls(jsonObjectLibrary, response.getLibraryUrls());
return response;
}
throw new BusinessException("AttributeRetrieval response data is null");
}
private static void setUrls(JSONObject jsonObjectSys,List<String> urls){
private static void setUrls(JSONObject jsonObjectSys, List<String> urls) {
List<String> finalUrls = urls;
SysFileLevel2TypeEnum.ofPythonPath().forEach(path ->{
SysFileLevel2TypeEnum.ofPythonPath().forEach(path -> {
JSONArray array = jsonObjectSys.getJSONArray(path);
List<String> urlList = JSONObject.parseArray(JSON.toJSONString(array),String.class);
if(CollectionUtil.isNotEmpty(urlList)){
List<String> urlList = JSONObject.parseArray(JSON.toJSONString(array), String.class);
if (CollectionUtil.isNotEmpty(urlList)) {
finalUrls.addAll(urlList);
}
});
@@ -1658,6 +1661,7 @@ public class PythonService {
/**
* 组装和计算设计包括图层的单品的参数不需要priority
*
* @param designSingleDTO
* @param singleOverall
* @param switchCategory
@@ -1702,6 +1706,7 @@ public class PythonService {
/**
* 设计包括图层的单品,每次只针对一个单品
*
* @param designSingleIncludeLayersDTO
* @param designLibraryModelPoint
* @return
@@ -1731,16 +1736,15 @@ public class PythonService {
// bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
bodyPath = "aida-mannequins/model_1693218345.2714432.png";
}
response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(),bodyPath,pythonTAllInfoService.getImageIdByPath(bodyPath)));
response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(), bodyPath, pythonTAllInfoService.getImageIdByPath(bodyPath)));
return response;
}
private DesignPythonItemPrint resolveDesignSinglePrint(DesignSinglePrintDTO printObject, String clothesPath) {
// 没有印花时的参数设置
if (printObject.getIfSingle().equals(Boolean.FALSE) && CollectionUtil.isEmpty(printObject.getPrints())) {
return new DesignPythonItemPrint(new ArrayList<>(),false);
return new DesignPythonItemPrint(new ArrayList<>(), false);
}
DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
// if(StringUtils.isEmpty(printObject.getPath())){
@@ -1769,13 +1773,13 @@ public class PythonService {
// 设置印花的位置、大小、旋转角度
List<DesignSinglePrint> prints = printObject.getPrints();
prints.forEach(p -> {
p.getLocation().set(0,p.getLocation().get(0));
p.getLocation().set(1,p.getLocation().get(1));
p.getLocation().set(0, p.getLocation().get(0));
p.getLocation().set(1, p.getLocation().get(1));
Integer priority = p.getPriority();
location.add(priority - 1, p.getLocation());
scale.add(priority - 1,p.getScale());
angle.add(priority - 1,p.getAngle());
paths.add(priority - 1,p.getMinIOPath());
scale.add(priority - 1, p.getScale());
angle.add(priority - 1, p.getAngle());
paths.add(priority - 1, p.getMinIOPath());
// log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO));
});
print.setLocation(location);
@@ -1808,6 +1812,7 @@ public class PythonService {
/**
* 设计包括图层的单品不用指定save_name和priority
*
* @param singleOverall
* @param switchCategory
* @param designLibraryModelPoint
@@ -1939,7 +1944,7 @@ public class PythonService {
// log.info("PythonService##responseBodyStr###{}", response.body().string());
// log.info("PythonService##responseBodyJson###{}", JSON.toJSONString(response.body()));
String responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject responseObject = JSON.parseObject(responseBody);
return responseObject;
} catch (IOException ioException) {
log.error("PythonService##design异常###{}", ExceptionUtil.getThrowableList(ioException));
@@ -1956,9 +1961,9 @@ public class PythonService {
if (response.isSuccessful()) {
try {
String responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject responseObject = JSON.parseObject(responseBody);
return responseObject;
}catch (IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@@ -1968,10 +1973,9 @@ public class PythonService {
}
public String generateSketchCaption(String url) {
public String generateSketchCaption(String url) {
//限流校验
AccessLimitUtils.validate("generateSketchCaption",5);
AccessLimitUtils.validate("generateSketchCaption", 5);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -1981,7 +1985,7 @@ public class PythonService {
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, url);
Request request = new Request.Builder()
.url(accessPythonIp+":2828/aida/interrogator")
.url(accessPythonIp + ":2828/aida/interrogator")
.method("POST", body)
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
.addHeader("Content-Type", "application/json")
@@ -2011,9 +2015,9 @@ public class PythonService {
throw new BusinessException("system error!");
}
public List<String> generateSketchOrPrint(Long userId,String url,String category, String text, int mode, String modelName) {
public List<String> generateSketchOrPrint(Long userId, String url, String category, String text, int mode, String modelName) {
//限流校验
AccessLimitUtils.validate("generateSketchOrPrint",5);
AccessLimitUtils.validate("generateSketchOrPrint", 5);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -2025,10 +2029,10 @@ public class PythonService {
content.put("user_id", userId);
content.put("image_url", url);
content.put("category", category);
content.put("mode",mode);
content.put("mode", mode);
content.put("str", text);
content.put("version",modelName);
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content,SerializerFeature.WriteMapNullValue));
content.put("version", modelName);
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content, SerializerFeature.WriteMapNullValue));
Request request = new Request.Builder()
// .url(accessPythonIp + ":2828/aida/diffusion")
// .url("http://18.167.251.121:9992")
@@ -2040,7 +2044,7 @@ public class PythonService {
Response response = null;
String bodyString = null;
try {
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content,SerializerFeature.WriteMapNullValue));
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content, SerializerFeature.WriteMapNullValue));
response = client.newCall(request).execute();
bodyString = response.body().string();
// bodyString = "{\n" +
@@ -2073,7 +2077,7 @@ public class PythonService {
throw new BusinessException("Generate Exception! Code : " + jsonObject.get("code"));
}
public Response sendPostToModel(String content,String portAndRoute,String functionName){
public Response sendPostToModel(String content, String portAndRoute, String functionName) {
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
@@ -2096,15 +2100,15 @@ public class PythonService {
response = client.newCall(request).execute();
// bodyString = response.body().string();
} catch (IOException ioException) {
log.error("PythonService##"+ functionName +"异常###{}", ExceptionUtil.getThrowableList(ioException));
log.error("PythonService##" + functionName + "异常###{}", ExceptionUtil.getThrowableList(ioException));
}
return response;
}
private List<String> setGenerateImageList(JSONObject jsonObject){
List<String> imageUrlList = JSONObject.parseArray(jsonObject.get("list").toString(),String.class);
if (imageUrlList.isEmpty()){
log.error("PythonService##generateSketchOrPrint异常###{}","diffusion response list is null");
private List<String> setGenerateImageList(JSONObject jsonObject) {
List<String> imageUrlList = JSONObject.parseArray(jsonObject.get("list").toString(), String.class);
if (imageUrlList.isEmpty()) {
log.error("PythonService##generateSketchOrPrint异常###{}", "diffusion response list is null");
// todo 如果这里返回为空,是判断出错还是返回给前端空
throw new BusinessException("The data returned on the python side is empty");
}
@@ -2116,7 +2120,7 @@ public class PythonService {
HashMap<String, List<OutfitDetailPythonItem>> layers = new HashMap<>();
HashMap<String, HashMap<String, List<OutfitDetailPythonItem>>> content = new HashMap<>();
layers.put("layers", layersDetail);
content.put("0",layers);
content.put("0", layers);
String jsonString = JSON.toJSONString(content, SerializerFeature.WriteNullStringAsEmpty);
// todo 添加限流
@@ -2128,7 +2132,7 @@ public class PythonService {
if (Objects.isNull(response) || Objects.isNull(response.body())) {
log.error("PythonService##composeLayers异常###{}", "response or body is empty!");
throw new BusinessException("generate exception!");
}else {
} else {
bodyString = response.body().string();
}
JSONObject jsonObject = JSON.parseObject(bodyString);
@@ -2141,7 +2145,7 @@ public class PythonService {
throw new BusinessException("composeLayers Exception!");
}
private String getCompositeImage(JSONObject jsonObject){
private String getCompositeImage(JSONObject jsonObject) {
JSONObject item0 = jsonObject.getJSONObject("0");
return item0.getString("synthesis_url");
}

View File

@@ -34,6 +34,6 @@ public class DesignPythonBasic {
private Double scale_earrings;
private Map<String, List<Integer>> body_point_test = Maps.newHashMap();
private Map<String, List<Integer>> body_point_test = Maps.newHashMap();
}

View File

@@ -53,7 +53,7 @@ public class DesignPythonItem {
*/
private String body_mask_path;
/**
* python_t_all_info image_id
* python_t_all_info image_id
*/
private Long imageId;
@@ -72,7 +72,7 @@ public class DesignPythonItem {
public static List<String> OUTWEAR_DRESS_BLOUSE = Arrays.asList(CollectionLevel2TypeEnum.OUTWEAR.getRealName(),
CollectionLevel2TypeEnum.DRESS.getRealName(),CollectionLevel2TypeEnum.BLOUSE.getRealName());
CollectionLevel2TypeEnum.DRESS.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
public static List<String> SKIRT_TROUSERS = Arrays.asList(
CollectionLevel2TypeEnum.SKIRT.getRealName(), CollectionLevel2TypeEnum.TROUSERS.getRealName());
@@ -85,7 +85,7 @@ public class DesignPythonItem {
public static List<String> SYS_HAIRSTYLE_SHOES_BODY = Arrays.asList(
SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), SysFileLevel2TypeEnum.SHOES.getRealName(),
SysFileLevel2TypeEnum.EARRINGS.getRealName(),SysFileLevel2TypeEnum.BODY.getRealName());
SysFileLevel2TypeEnum.EARRINGS.getRealName(), SysFileLevel2TypeEnum.BODY.getRealName());
public static List<String> SYS_HAIRSTYLE_SHOES = Arrays.asList(
SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), SysFileLevel2TypeEnum.SHOES.getRealName(),

View File

@@ -41,7 +41,7 @@ public class DesignPythonItemPrint {
@ApiModelProperty("print的旋转角度 传 [0.2, 0.2]")
private List<Double> print_angle_list;
@JSONField(name="IfSingle")
@JSONField(name = "IfSingle")
public Boolean getIfSingle() {
return IfSingle;
}

View File

@@ -4,6 +4,7 @@ import com.ai.da.mapper.entity.Library;
import lombok.Data;
import java.util.List;
@Data
public class DesignPythonObjects {
private String process_id;

View File

@@ -22,7 +22,7 @@ public interface AccountLoginLogService extends IService<AccountLoginLog> {
* @param accountId
* @return
*/
Boolean saveLoginLog(String ip ,Long accountId);
Boolean saveLoginLog(String ip, Long accountId);
/**
* 根据账户查询

View File

@@ -20,18 +20,23 @@ public interface AccountService extends IService<Account> {
/**
* 账户预先登入
*
* @param accountDTO
* @return
*/
AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO);
/**
* 账户登入
*
* @param accountLoginDTO
* @return
*/
AccountLoginVO login(AccountLoginDTO accountLoginDTO, HttpServletRequest request);
/**
* 绑定邮箱
*
* @param accountBindEmailDTO
* @return
*/
@@ -39,38 +44,49 @@ public interface AccountService extends IService<Account> {
/**
* 忘记密码
*
* @param accountDTO
* @return
*/
Boolean forgetPwd(AccountRegisterDTO accountDTO);
/**
* 发送邮件
*
* @param emailSendDTO
* @return
*/
Boolean sendEmail(EmailSendDTO emailSendDTO);
/**
* 登出
*
* @param accountLogoutDTO
* @return
*/
Boolean logout(AccountLogoutDTO accountLogoutDTO);
/**
* 判断是否登出 Boolean为登入
*
* @param accountLogoutDTO
* @return
*/
Boolean isLogin(AccountLogoutDTO accountLogoutDTO);
/**
* 添加用户信息
*
* @param accountAddDTO
* @return
*/
Boolean addUser(AccountAddDTO accountAddDTO);
/**
* 编辑用户信息
*
* @param accountEditDTO
* @return
*/
Boolean editUser(AccountEditDTO accountEditDTO) ;
Boolean editUser(AccountEditDTO accountEditDTO);
}

View File

@@ -31,6 +31,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void delete(Long id);
/**
* 删除元素图片
*
@@ -38,6 +39,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void batchDelete(List<Long> ids);
/**
* 生产印花图片
*
@@ -45,6 +47,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
CollectionGeneratePrintVO generatePrint(CollectionGeneratePrintDTO generatePrintDTO);
/**
* 保存印花图片
*
@@ -52,14 +55,17 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
Boolean savePrint(CollectionSavePrintDTO savePrintDTO);
/**
* 通过element保存library
*
* @param elements
* @return
*/
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone, String modelSex);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements, String timeZone);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements, String timeZone, String modelSex);
/**
* 校验element
*
@@ -67,6 +73,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
ValidateElementVO validateElement(DesignCollectionDTO designDTO);
/**
* 编辑
*
@@ -74,6 +81,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void editSketchBoardsElement(ValidateElementVO elementVO, List<CollectionSketchDTO> sketchBoards);
/**
* 编辑
*
@@ -81,6 +89,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void editPrintBoardsElement(ValidateElementVO elementVO, List<DesignCollectionPrintElementDTO> printBoards);
/**
* 关联element和collection
*
@@ -88,7 +97,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @param collectionId
* @return
*/
void relationCollection(List<Long> elementIds,Long collectionId);
void relationCollection(List<Long> elementIds, Long collectionId);
/**
* 保存颜色板
@@ -107,22 +116,24 @@ public interface CollectionElementService extends IService<CollectionElement> {
*/
List<CollectionElement> getByCollectionId(Long collectionId);
List<CollectionElement> getByOnlyCollectionId(Long collectionId);
List<CollectionElement> getByOnlyCollectionId(Long collectionId);
DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
DesignLibraryModelPointVO calculateTemplatePointTemplate(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
/**
* 刷新历史数据
*/
void refreshHistoryData() ;
void refreshHistoryData();
/**
* 当level2Type发生改变时修改levelType
*
* @param elementId
* @param level2Type
* @return
*/
CollectionElement editLevel2Type(Long elementId,String level2Type);
CollectionElement editLevel2Type(Long elementId, String level2Type);
}

Some files were not shown because too many files have changed in this diff Show More