TASK: 全局异常处理,代码优化,测试数据库连接信息变更;

This commit is contained in:
shahaibo
2023-10-27 10:09:19 +08:00
parent 9fa605f83e
commit bedc640e13
27 changed files with 377 additions and 242 deletions

View File

@@ -1,8 +1,18 @@
package com.ai.da.common.config.exception;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.response.ResultEnum;
import com.ai.da.model.vo.AuthPrincipalVo;
import lombok.Data;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Objects;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
/**
* @author: dangweijian
* @description: 业务异常
@@ -15,14 +25,44 @@ public class BusinessException extends RuntimeException {
private String msg;
public BusinessException(ResultEnum resultEnum) {
super(resultEnum.getMsg());
this.code = resultEnum.getCode();
this.msg = resultEnum.getMsg();
this.msg = getMessageFromResource(resultEnum.getMsg(), getUserLocale());
}
public BusinessException(String msg) {
super(msg);
this.code = ResultEnum.FAIL.getCode();
this.msg = msg;
this.msg = getMessageFromResource(msg, getUserLocale());
}
public BusinessException(String msg, Integer code) {
this.code = code;
this.msg = getMessageFromResource(msg, getUserLocale());
}
public BusinessException(Throwable cause) {
this.code = ResultEnum.FAIL.getCode();
this.msg = getMessageFromResource(cause.getMessage(), getUserLocale());
}
private static Locale getUserLocale() {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
if (Objects.isNull(userInfo)) {
return new Locale("en");
}
return new Locale(userInfo.getLanguage());
}
private static String getMessageFromResource(String msg, Locale userLocale) {
try (InputStream inputStream = BusinessException.class.getClassLoader().getResourceAsStream("messages_" + userLocale.getLanguage() + ".properties")) {
if (inputStream != null) {
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
if (bundle.containsKey(msg)) {
return bundle.getString(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return msg; // 如果找不到对应的资源文件,返回原始的消息
}
}

View File

@@ -64,7 +64,8 @@ public class ExceptionCatch {
@ExceptionHandler(BindException.class)
public Response<String> bindExceptionHandler(BindException e) {
log.error("参数错误bind{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
return Response.fail(ResultEnum.FAIL.getCode(), e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
BusinessException businessException = new BusinessException(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
return Response.error(businessException.getCode(), businessException.getMsg());
}
/**
@@ -75,9 +76,10 @@ public class ExceptionCatch {
*/
@ResponseBody
@ExceptionHandler(MethodArgumentNotValidException.class)
public Response<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
public Response<String> handleValidationException(MethodArgumentNotValidException e) {
log.error("参数错误bind{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
return Response.fail(ResultEnum.FAIL.getCode(), e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
BusinessException businessException = new BusinessException(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
return Response.error(businessException.getCode(), businessException.getMsg());
}
//初始化,不可预知异常自定义错误编码

View File

@@ -7,7 +7,7 @@ import java.util.stream.Stream;
* @description: 操作类型 登入 忘记密码
* @create: 2022-8-10 17:33
**/
public enum OperationTypeEnum {
public enum AuthenticationOperationTypeEnum {
/**
* 登入
*/
@@ -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 AuthenticationOperationTypeEnum of(String name) {
return Stream.of(AuthenticationOperationTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);
}
}

View File

@@ -28,6 +28,8 @@ public enum SwitchCategoryEnum {
* 裤子
*/
TROUSERS("Trousers"),
TOPS("Tops"),
BOTTOMS("Bottoms"),
;
private String realName;

View File

@@ -11,6 +11,7 @@ import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
import com.tencentcloudapi.ses.v20201002.models.Template;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import java.util.Date;
@@ -96,7 +97,7 @@ public class SendEmailUtil {
return Boolean.TRUE;
} catch (TencentCloudSDKException e) {
log.info("邮件发送失败###{}", e.toString());
throw new BusinessException(e.getMessage());
throw new BusinessException("failed.to.send.mail");
}
}

View File

@@ -1,15 +1,16 @@
package com.ai.da.controller;
import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.response.Response;
import com.ai.da.model.dto.*;
import com.ai.da.model.vo.DesignCollectionVO;
import com.ai.da.model.vo.DesignLikeVO;
import com.ai.da.service.DesignService;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

View File

@@ -176,7 +176,7 @@ 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();
}
private String calculateTempFileUrlNew(Long userId) {

View File

@@ -45,6 +45,16 @@ public class Account implements Serializable {
*/
private String userPassword;
/**
* 语言
*/
private String language;
/**
* 城市
*/
private String country;
/**
* 账户有效期开始时间
*/

View File

@@ -11,15 +11,15 @@ import javax.validation.constraints.NotNull;
@ApiModel("绑定邮箱")
public class AccountBindEmailDTO {
@NotNull(message = "userId cannot be empty!")
@NotNull(message = "userId.cannot.be.empty")
@ApiModelProperty("用户id")
private Long userId;
@NotBlank(message = "Please input email!")
@NotBlank(message = "email.cannot.be.empty")
@ApiModelProperty("邮箱")
private String userEmail;
@NotBlank(message = "Please input the email verification code !")
@NotBlank(message = "emailVerifyCode.cannot.be.empty")
@ApiModelProperty("邮箱验证码")
private String emailVerifyCode;
}

View File

@@ -11,11 +11,11 @@ import javax.validation.constraints.NotNull;
@ApiModel("登入")
public class AccountLoginDTO {
@NotNull(message = "userId cannot be empty !")
@NotNull(message = "userId.cannot.be.empty")
@ApiModelProperty("userId")
private Long userId;
@NotBlank(message = "Please input email !")
@NotBlank(message = "email.cannot.be.empty")
@ApiModelProperty("邮箱")
private String email;
@@ -25,7 +25,7 @@ public class AccountLoginDTO {
@ApiModelProperty("密码")
private String password;
@NotBlank(message = "Please input loginType !")
@NotBlank(message = "loginType.cannot.be.empty")
@ApiModelProperty("登入类型 EMAIL - >邮箱 , PASSWORD ->密码")
private String loginType;

View File

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
@ApiModel("登出")
public class AccountLogoutDTO {
@NotNull(message = "userId cannot be empty !")
@NotNull(message = "userId.cannot.be.empty")
@ApiModelProperty("userId")
private Long userId;

View File

@@ -10,20 +10,20 @@ import javax.validation.constraints.NotBlank;
@ApiModel("预先登入")
public class AccountPreLoginDTO {
@NotBlank(message = "userName cannot be empty!")
@NotBlank(message = "userName.cannot.be.empty")
@ApiModelProperty("用户名")
private String userName;
/*新增字段*/
@NotBlank(message = "Please input email !")
@NotBlank(message = "email.cannot.be.empty")
@ApiModelProperty("邮箱")
private String email;
@NotBlank(message = "password cannot be empty!")
@NotBlank(message = "password.cannot.be.empty")
@ApiModelProperty("密码")
private String password;
@NotBlank(message = "operationType cannot be empty")
@NotBlank(message = "operationType.cannot.be.empty")
@ApiModelProperty("操作类型 LOGIN 注册 FORGET_PWD 忘记密码 BIND_MAILBOX 绑定邮箱")
private String operationType;

View File

@@ -10,15 +10,15 @@ import javax.validation.constraints.NotBlank;
@ApiModel("账户")
public class AccountRegisterDTO {
@NotBlank(message = "Please input email !")
@NotBlank(message = "email.cannot.be.empty")
@ApiModelProperty("邮箱")
private String email;
@NotBlank(message = "Please input password !")
@NotBlank(message = "password.cannot.be.empty")
@ApiModelProperty("密码")
private String password;
@NotBlank(message = "Please input the email verification code !")
@NotBlank(message = "emailVerifyCode.cannot.be.empty")
@ApiModelProperty("邮箱验证码")
private String emailVerifyCode;

View File

@@ -20,41 +20,49 @@ public class DesignCollectionDTO {
@ApiModelProperty("印花板图片 数组")
private List<DesignCollectionPrintElementDTO> printBoards;
@NotEmpty(message = "colorBoardRgbValues cannot be empty!")
@NotEmpty(message = "colorBoards.cannot.be.empty")
@ApiModelProperty("颜色板RGB值 数组")
private List<CollectionColorDTO> colorBoards;
@ApiModelProperty("手稿板图片id 数组")
private List<CollectionSketchDTO> sketchBoards;
@ApiModelProperty("市场手稿板图片id 数组")
private List<DesignCollectionElementDTO> marketingSketchs;
// 2023.10版本去除该入参
// @ApiModelProperty("市场手稿板图片id 数组")
// private List<DesignCollectionElementDTO> marketingSketchs;
@NotNull(message = "systemScale cannot be empty!")
@NotNull(message = "systemScale.cannot.be.empty")
@ApiModelProperty("系统取图比列")
private BigDecimal systemScale;
@NotBlank(message = "modelType.cannot.be.empty")
@ApiModelProperty("模特类型:System,Library")
private String modelType;
@NotBlank(message = "modelSex.cannot.be.empty")
@ApiModelProperty("模特性别")
private String modelSex;
@ApiModelProperty("templateId")
@NotNull(message = "templateId.cannot.be.empty")
@ApiModelProperty("模特ID")
private Long templateId;
@ApiModelProperty("mood版本id 没有传null")
private String moodTemplateId;
@NotBlank(message = "singleOverall cannot be empty!")
@NotBlank(message = "singleOverall.cannot.be.empty")
@ApiModelProperty("控制生成类型的参数两个选项outfit时候传 single , 另外一个传 overall")
private String singleOverall;
@ApiModelProperty("single模式下的类别选择参数 选项有outwear,dress,blouse,skirt,trousers")
private String switchCategory;
@NotBlank(message = "timeZone cannot be empty!")
@NotBlank(message = "timeZone.cannot.be.empty")
@ApiModelProperty("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
private String timeZone;
@NotBlank(message = "processId.cannot.be.empty")
@ApiModelProperty("python端design进程ID")
private String processId;
}

View File

@@ -10,11 +10,11 @@ import javax.validation.constraints.NotBlank;
@ApiModel("邮箱发送")
public class EmailSendDTO {
@NotBlank(message = "Please input email!")
@NotBlank(message = "email.cannot.be.empty")
@ApiModelProperty("邮箱")
private String email;
@NotBlank(message = "operationType cannot be empty")
@NotBlank(message = "operationType.cannot.be.empty")
@ApiModelProperty("操作类型 LOGIN 注册 FORGET_PWD 忘记密码 BIND_MAILBOX 绑定邮箱")
private String operationType;

View File

@@ -39,6 +39,16 @@ public class AuthPrincipalVo implements Serializable {
*/
private Integer status;
/**
* 语言
*/
private String language;
/**
* 城市
*/
private String country;
/**
* 角色
*/

View File

@@ -16,6 +16,7 @@ import com.ai.da.service.PythonTAllInfoService;
import com.ai.da.service.SysFileService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.collect.Lists;
@@ -1581,29 +1582,34 @@ public class PythonService {
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
String bodyStr = null;
Response response;
String bodyStr;
try {
log.info("generateAttributeRetrieval请求入参content###{}", JSON.toJSONString(content));
response = client.newCall(request).execute();
bodyStr = response.body().string();
} catch (IOException ioException) {
AccessLimitUtils.validateOut("generateAttributeRetrieval");
log.error("generateAttributeRetrieval异常###{}", ExceptionUtil.getThrowableList(ioException));
throw new BusinessException("attributeRetrieval.interface.exception");
}
//去除限流
AccessLimitUtils.validateOut("generateAttributeRetrieval");
if (Objects.isNull(response)) {
log.error("generateAttributeRetrieval异常###{}", "response or body is empty!");
throw new BusinessException("system error!");
}
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(response));
Boolean result = jsonObject.getBoolean("successful");
if (result) {
if (response.isSuccessful()) {
try {
if (Objects.nonNull(response.body())) {
bodyStr = response.body().string();
return resolveDesignAttributeRetrievalDTO(bodyStr);
}
log.info("attribute_retrieval失败###{}", bodyStr);
//生成失败
throw new BusinessException("system error!");
throw new BusinessException("attributeRetrieval.interface.exception");
} catch (JSONException | IOException e) {
log.error("generateAttributeRetrieval异常###{}", e.getMessage());
throw new BusinessException("attributeRetrieval.interface.exception");
}
}
log.error("generateAttributeRetrieval异常###{}", response);
//生成失败
throw new BusinessException("attributeRetrieval.interface.exception");
}
private static DesignAttributeRetrievalDTO resolveDesignAttributeRetrievalDTO(String bodyStr) {
@@ -1612,20 +1618,20 @@ public class PythonService {
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.isEmpty()) {
log.error("generateAttributeRetrieval异常###{}", "jsonObjectSys is empty!");
throw new BusinessException("system error!");
throw new BusinessException("attributeRetrieval.interface.exception");
}
setUrls(jsonObjectSys, response.getSysFileUrlS());
JSONObject jsonObjectLibrary = data.getJSONObject("user_lib_dict");
if (null == jsonObjectLibrary || jsonObjectLibrary.size() == 0) {
if (null == jsonObjectLibrary || jsonObjectLibrary.isEmpty()) {
log.error("generateAttributeRetrieval异常###{}", "jsonObjectLibrary is empty!");
throw new BusinessException("system error!");
throw new BusinessException("attributeRetrieval.interface.exception");
}
setUrls(jsonObjectLibrary, response.getLibraryUrls());
return response;
}
throw new BusinessException("AttributeRetrieval response data is null");
throw new BusinessException("attributeRetrieval.interface.exception");
}
private static void setUrls(JSONObject jsonObjectSys, List<String> urls) {
@@ -1918,7 +1924,7 @@ public class PythonService {
public JSONObject designNew(DesignPythonObjects designPythonObjects) {
// todo 限流校验
// AccessLimitUtils.validate("design",5);
AccessLimitUtils.validate("design",5);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -1937,39 +1943,34 @@ public class PythonService {
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
Response response;
String responseBody;
try {
response = client.newCall(request).execute();
// log.info("PythonService##response###{}", response);
// 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);
return responseObject;
} catch (IOException ioException) {
AccessLimitUtils.validateOut("design");
log.error("PythonService##design异常###{}", ExceptionUtil.getThrowableList(ioException));
throw new BusinessException("design.interface.exception");
}
//去除限流
// AccessLimitUtils.validateOut("design");
if (Objects.isNull(response)) {
log.error("PythonService##design异常###{}", "response or body is empty!");
throw new BusinessException("system error!");
}
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(response));
log.info("PythonService##jsonObject###{}", jsonObject);
Boolean result = jsonObject.getBoolean("successful");
AccessLimitUtils.validateOut("design");
if (response.isSuccessful()) {
try {
String responseBody = response.body().string();
if (Objects.nonNull(response.body())) {
responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
log.info("PythonService##responseObject###{}", responseObject);
return responseObject;
} catch (IOException e) {
throw new RuntimeException(e);
}
throw new BusinessException("design.interface.exception");
} catch (IOException | JSONException e) {
log.error("PythonService##design异常###{}", e.getMessage());
throw new BusinessException("design.interface.exception");
}
}
log.info("PythonService##design异常jsonObject###{}", jsonObject);
log.error("PythonService##design异常response###{}", response);
//生成失败
throw new BusinessException("generate design exception!");
throw new BusinessException("design.interface.exception");
}

View File

@@ -74,9 +74,15 @@ public class DesignPythonItem {
public static List<String> OUTWEAR_DRESS_BLOUSE = Arrays.asList(CollectionLevel2TypeEnum.OUTWEAR.getRealName(),
CollectionLevel2TypeEnum.DRESS.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
public static List<String> DRESS_BLOUSE = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
CollectionLevel2TypeEnum.BLOUSE.getRealName());
public static List<String> SKIRT_TROUSERS = Arrays.asList(
CollectionLevel2TypeEnum.SKIRT.getRealName(), CollectionLevel2TypeEnum.TROUSERS.getRealName());
public static List<String> OUTERWEAR = Arrays.asList(
"OuterWear");
public static List<String> TOPS = Arrays.asList(
"Tops");

View File

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
@@ -28,6 +29,7 @@ public class AccountLoginLogServiceImpl extends ServiceImpl<AccountLoginLogMappe
AccountLoginLogMapper accountLoginLogMapper;
@Override
@Transactional
public Boolean saveLoginLog(String ip, Long accountId) {
AccountLoginLog accountLoginLog = new AccountLoginLog();
accountLoginLog.setAccountId(accountId);

View File

@@ -3,7 +3,7 @@ package com.ai.da.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.enums.LoginTypeEnum;
import com.ai.da.common.enums.OperationTypeEnum;
import com.ai.da.common.enums.AuthenticationOperationTypeEnum;
import com.ai.da.common.security.jwt.JWTTokenHelper;
import com.ai.da.common.utils.*;
import com.ai.da.mapper.AccountMapper;
@@ -51,41 +51,44 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Override
@Transactional
public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) {
log.info("aida预先登入accountDTO###{}", JSON.toJSONString(accountDTO));
Account account = getOneByUserName(accountDTO.getUserName());
Assert.isTrue(Objects.nonNull(account), "User does not exist!");
//用户有效期校验
validateUserValidaExpire(account);
if ("Third-000000".equals(account.getUserPassword())) {
account.setUserPassword(accountDTO.getPassword());
accountMapper.updateById(account);
} else {
Assert.isTrue(account.getUserPassword().equals(accountDTO.getPassword()), "Password error !");
if (!account.getUserPassword().equals(accountDTO.getPassword())) {
throw new BusinessException("password.error");
}
}
/*发送邮件*/
OperationTypeEnum operationTypeEnum = OperationTypeEnum.of(accountDTO.getOperationType());
AuthenticationOperationTypeEnum authenticationOperationTypeEnum = AuthenticationOperationTypeEnum.of(accountDTO.getOperationType());
log.info(account.getUserEmail());
log.info(accountDTO.getEmail());
Assert.isTrue(account.getUserEmail().equals(accountDTO.getEmail()), "Email error !");
Assert.notNull(operationTypeEnum, "Unknown operation type!");
if (!account.getUserEmail().equals(accountDTO.getEmail())) {
throw new BusinessException("email.error");
}
if (Objects.isNull(authenticationOperationTypeEnum)) {
throw new BusinessException("unknown.authentication.operation.type");
}
String randomVerifyCode = RandomsUtil.generateVerifyCode(100000L, 999999L);
LocalCacheUtils.setVerifyCodeCache(
accountDTO.getOperationType() + "_" + accountDTO.getEmail(), randomVerifyCode);
Boolean result = Boolean.FALSE;
switch (operationTypeEnum) {
switch (authenticationOperationTypeEnum) {
case LOGIN:
Assert.notNull(accountDTO, "Email not registered!");
result = SendEmailUtil.send(accountDTO.getEmail(), null,
SendEmailUtil.LOGIN_TEMPLATE_ID, randomVerifyCode);
break;
case FORGET_PWD:
Assert.notNull(accountDTO, "Email not registered!");
result = SendEmailUtil.send(accountDTO.getEmail(), null,
SendEmailUtil.UPDATE_PWD_TEMPLATE_ID, randomVerifyCode);
break;
case EXCEPTION_IP:
Assert.notNull(accountDTO, "Email not registered!");
result = SendEmailUtil.send(accountDTO.getEmail(), accountDTO.getIp(),
SendEmailUtil.EXCEPTION_ID_TEMPLATE_ID, randomVerifyCode);
break;
@@ -94,22 +97,26 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
SendEmailUtil.BIND_MAILBOX_TEMPLATE_ID, randomVerifyCode);
break;
default:
Assert.notNull(operationTypeEnum, "Unknown operation type!");
}
Assert.isTrue(result, "Failed to send mail");
if (!result) {
throw new BusinessException("failed.to.send.mail");
}
return new AccountPreLoginVO(account.getId());
}
@Transactional
@Override
public AccountLoginVO login(AccountLoginDTO accountLoginDTO, HttpServletRequest request) {
// Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getEmail()), "Please input a email !");
// Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getEmailVerifyCode()), "Please input the email verification code !");
log.info("aida确认登入###accountLoginDTO###{}", JSON.toJSONString(accountLoginDTO));
Account accountExist = getOneByEmail(accountLoginDTO.getEmail().trim());
Assert.notNull(accountExist, "User does not exist!");
LoginTypeEnum accountType = LoginTypeEnum.of(accountLoginDTO.getLoginType());
if (Objects.isNull(accountType) || accountType.equals(LoginTypeEnum.PASSWORD)) {
throw new BusinessException("Unknown login type!");
if (Objects.isNull(accountType)) {
throw new BusinessException("unknown.login.type");
}
if (!accountType.equals(LoginTypeEnum.EMAIL)) {
throw new BusinessException("error.login.type");
}
//用户有效期校验
validateUserValidaExpire(accountExist);
@@ -117,25 +124,23 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
Account account = null;
switch (accountType) {
case PASSWORD:
Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getPassword()), "Please input a password !");
account = getOneByUserName(accountLoginDTO.getUserName());
Assert.isTrue(Objects.nonNull(account), "User does not exist!");
Assert.isTrue(account.getUserPassword().equals(accountLoginDTO.getPassword()), "Password error !");
// Assert.isTrue(StringUtils.isBlank(
// LocalCacheUtils.getTokenCache(String.valueOf(account.getId()))),"该用户已登入");
// Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getPassword()), "Please input a password !");
// account = getOneByUserName(accountLoginDTO.getUserName());
// Assert.isTrue(Objects.nonNull(account), "User does not exist!");
// Assert.isTrue(account.getUserPassword().equals(accountLoginDTO.getPassword()), "Password error !");
// 走不到这边
break;
case EMAIL:
Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getEmail()), "Please input a email !");
Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getEmailVerifyCode()), "Please input the email verification code !");
account = getOneByEmail(accountLoginDTO.getEmail().trim());
if (Objects.isNull(account)) {
throw new BusinessException("Email not registered!");
}
//校验邮箱验证码
String verifyCode = LocalCacheUtils.getVerifyCodeCache(OperationTypeEnum.LOGIN.name() + "_" + accountLoginDTO.getEmail());
Assert.isTrue(StringUtils.isNotBlank(verifyCode), "The verification code has expired!");
String verifyCode = LocalCacheUtils.getVerifyCodeCache(AuthenticationOperationTypeEnum.LOGIN.name() + "_" + accountLoginDTO.getEmail());
if (StringUtils.isBlank(verifyCode)) {
throw new BusinessException("the.verification.code.has.expired");
}
if (!"921314".equals(accountLoginDTO.getEmailVerifyCode())) {
Assert.isTrue(verifyCode.equals(accountLoginDTO.getEmailVerifyCode()), "Verification code error!");
if (!verifyCode.equals(accountLoginDTO.getEmailVerifyCode())) {
throw new BusinessException("verification.code.error");
}
}
break;
default:
@@ -147,7 +152,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
//用户已登入
response.setToken(token);
} else {
response.setToken(createAccountToken(account.getId(), account.getUserName()));
response.setToken(createAccountToken(account));
}
response.setUserId(account.getId());
//判断是否常用ip 不是则发邮件提示
@@ -158,10 +163,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
private void validateUserValidaExpire(Account account) {
Long currentTime = new Date().getTime();
if (Objects.nonNull(account.getValidStartTime())) {
Assert.isTrue(currentTime >= account.getValidStartTime(), "User expired !");
if (currentTime < account.getValidStartTime()) {
throw new BusinessException("user.expired");
}
}
if (Objects.nonNull(account.getValidEndTime())) {
Assert.isTrue(currentTime <= account.getValidEndTime(), "User expired !");
if (currentTime > account.getValidEndTime()) {
throw new BusinessException("user.expired");
}
}
}
@@ -175,7 +184,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
//非常用ip,没有出现过
EmailSendDTO emailSendDTO = new EmailSendDTO();
emailSendDTO.setEmail(account.getUserEmail());
emailSendDTO.setOperationType(OperationTypeEnum.EXCEPTION_IP.name());
emailSendDTO.setOperationType(AuthenticationOperationTypeEnum.EXCEPTION_IP.name());
emailSendDTO.setIp(ip);
sendEmail(emailSendDTO);
}
@@ -185,28 +194,34 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
accountLoginLogService.saveLoginLog(ip, account.getId());
}
private String createAccountToken(Long userId, String userName) {
String token = LocalCacheUtils.getTokenCache(String.valueOf(userId));
if (StringUtils.isNotBlank(token)) {
return token;
}
private String createAccountToken(Account account) {
AuthPrincipalVo principal = new AuthPrincipalVo();
principal.setId(userId);
principal.setUsername(userName);
principal.setId(account.getId());
principal.setUsername(account.getUserName());
principal.setLanguage(account.getLanguage());
principal.setCountry(account.getCountry());
String token2 = jwtTokenHelper.createToken(principal);
LocalCacheUtils.setTokenCache(String.valueOf(userId), token2);
LocalCacheUtils.setTokenCache(String.valueOf(account.getId()), token2);
return token2;
}
@Override
public Boolean bindEmail(AccountBindEmailDTO accountBindEmailDTO) {
Account account = getOneByUserId(accountBindEmailDTO.getUserId());
Assert.notNull(account, "User does not exist !");
Assert.isTrue(StringUtils.isBlank(account.getUserEmail()), "User has bound mailbox !");
Account account = baseMapper.selectById(accountBindEmailDTO.getUserId());
if (Objects.isNull(account)) {
throw new BusinessException("userName.does.not.exist");
}
if (StringUtils.isNotBlank(account.getUserEmail())) {
throw new BusinessException("user.has.bound.mailbox");
}
//校验邮箱验证码
String verifyCode = LocalCacheUtils.getVerifyCodeCache(OperationTypeEnum.BIND_MAILBOX.name() + "_" + accountBindEmailDTO.getUserEmail());
Assert.isTrue(StringUtils.isNotBlank(verifyCode), "The verification code has expired !");
Assert.isTrue(verifyCode.equals(accountBindEmailDTO.getEmailVerifyCode()), "Verification code error !");
String verifyCode = LocalCacheUtils.getVerifyCodeCache(AuthenticationOperationTypeEnum.BIND_MAILBOX.name() + "_" + accountBindEmailDTO.getUserEmail());
if (StringUtils.isBlank(verifyCode)) {
throw new BusinessException("the.verification.code.has.expired");
}
if (!verifyCode.equals(accountBindEmailDTO.getEmailVerifyCode())) {
throw new BusinessException("verification.code.error");
}
//绑定
updatePwdByUserId(accountBindEmailDTO.getUserEmail(), accountBindEmailDTO.getUserId());
return Boolean.TRUE;
@@ -216,44 +231,54 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Override
public Boolean forgetPwd(AccountRegisterDTO accountDTO) {
Account emailAccount = getOneByEmail(accountDTO.getEmail());
Assert.notNull(emailAccount, "Email not registered!");
//校验邮箱验证码
String verifyCode = LocalCacheUtils.getVerifyCodeCache(OperationTypeEnum.FORGET_PWD.name() + "_" + accountDTO.getEmail());
Assert.isTrue(StringUtils.isNotBlank(verifyCode), "The verification code has expired!");
Assert.isTrue(verifyCode.equals(accountDTO.getEmailVerifyCode()), "Verification code error!");
String verifyCode = LocalCacheUtils.getVerifyCodeCache(AuthenticationOperationTypeEnum.FORGET_PWD.name() + "_" + accountDTO.getEmail());
if (StringUtils.isBlank(verifyCode)) {
throw new BusinessException("the.verification.code.has.expired");
}
if (!verifyCode.equals(accountDTO.getEmailVerifyCode())) {
throw new BusinessException("verification.code.error");
}
updatePwdByEmail(accountDTO.getPassword(), accountDTO.getEmail());
return Boolean.TRUE;
}
private void updatePwdByEmail(String pwd, String email) {
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_email", email);
queryWrapper.lambda().eq(Account::getUserEmail, email);
Account accountNew = new Account();
accountNew.setUserPassword(pwd);
accountMapper.update(accountNew, queryWrapper);
}
private void updatePwdByUserId(String email, Long userId) {
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", userId);
Account accountNew = new Account();
accountNew.setUserEmail(email);
accountMapper.update(accountNew, queryWrapper);
accountNew.setId(userId);
accountMapper.updateById(accountNew);
}
private Account getOneByEmail(String email) {
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_email", email);
return accountMapper.selectOne(queryWrapper);
queryWrapper.lambda().eq(Account::getUserEmail, email);
queryWrapper.lambda().last("limit 1");
List<Account> accountList = accountMapper.selectList(queryWrapper);
if (CollectionUtil.isEmpty(accountList)) {
throw new BusinessException("email.does.not.exist");
}
return accountList.get(0);
}
private Account getOneByUserName(String userName) {
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_name", userName);
return accountMapper.selectOne(queryWrapper);
queryWrapper.lambda().eq(Account::getUserName, userName);
queryWrapper.lambda().last("limit 1");
List<Account> accountList = accountMapper.selectList(queryWrapper);
if (CollectionUtil.isEmpty(accountList)) {
throw new BusinessException("userName.does.not.exist");
}
return accountList.get(0);
}
private Account getOneByUserId(Long userId) {
@@ -265,27 +290,25 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Override
public Boolean sendEmail(EmailSendDTO emailSendDTO) {
OperationTypeEnum operationTypeEnum = OperationTypeEnum.of(emailSendDTO.getOperationType());
Assert.notNull(operationTypeEnum, "Unknown operation type!");
AuthenticationOperationTypeEnum authenticationOperationTypeEnum = AuthenticationOperationTypeEnum.of(emailSendDTO.getOperationType());
if (Objects.isNull(authenticationOperationTypeEnum)) {
throw new BusinessException("unknown.authentication.operation.type");
}
Account emailAccount = getOneByEmail(emailSendDTO.getEmail());
String randomVerifyCode = RandomsUtil.generateVerifyCode(100000L, 999999L);
LocalCacheUtils.setVerifyCodeCache(
emailSendDTO.getOperationType() + "_" + emailSendDTO.getEmail(), randomVerifyCode);
Boolean result = Boolean.FALSE;
switch (operationTypeEnum) {
switch (authenticationOperationTypeEnum) {
case LOGIN:
Assert.notNull(emailAccount, "Email not registered!");
result = SendEmailUtil.send(emailSendDTO.getEmail(), null,
SendEmailUtil.LOGIN_TEMPLATE_ID, randomVerifyCode);
break;
case FORGET_PWD:
Assert.notNull(emailAccount, "Email not registered!");
result = SendEmailUtil.send(emailSendDTO.getEmail(), null,
SendEmailUtil.UPDATE_PWD_TEMPLATE_ID, randomVerifyCode);
break;
case EXCEPTION_IP:
Assert.notNull(emailAccount, "Email not registered!");
result = SendEmailUtil.send(emailSendDTO.getEmail(), emailSendDTO.getIp(),
SendEmailUtil.EXCEPTION_ID_TEMPLATE_ID, randomVerifyCode);
break;
@@ -294,9 +317,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
SendEmailUtil.BIND_MAILBOX_TEMPLATE_ID, randomVerifyCode);
break;
default:
Assert.notNull(operationTypeEnum, "Unknown operation type!");
}
Assert.isTrue(result, "Failed to send mail");
if (!result) {
throw new BusinessException("failed.to.send.mail");
}
return Boolean.TRUE;
}

View File

@@ -11,7 +11,9 @@ import com.ai.da.mapper.CollectionElementMapper;
import com.ai.da.mapper.entity.*;
import com.ai.da.mapper.entity.Collection;
import com.ai.da.model.dto.*;
import com.ai.da.model.enums.MalePosition;
import com.ai.da.model.enums.ModelType;
import com.ai.da.model.enums.Sex;
import com.ai.da.model.vo.*;
import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonItem;
@@ -308,8 +310,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(moodBoardIds)) {
List<CollectionElement> MoodBoardElements = collectionElementMapper.selectBatchIds(moodBoardIds);
Assert.isTrue(CollectionUtil.isNotEmpty(MoodBoardElements)
&& MoodBoardElements.size() == moodBoardIds.size(), "get moodboard data is mismatch");
if (CollectionUtil.isEmpty(MoodBoardElements) || MoodBoardElements.size() != moodBoardIds.size()) {
throw new BusinessException("get.moodBoards.data.is.mismatch");
}
elementVO.setMoodBoardElements(MoodBoardElements);
usedElementIds.addAll(moodBoardIds);
}
@@ -348,7 +351,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//校验printboard
List<CollectionElement> printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds);
Assert.isTrue(CollectionUtil.isNotEmpty(printBoardElements)
&& printBoardElements.size() == printBoardIds.size(), "get printboard data is mismatch");
&& printBoardElements.size() == printBoardIds.size(), "get.printBoards.data.is.mismatch");
elementVO.setPrintBoardElements(printBoardElements);
usedElementIds.addAll(printBoardIds);
}
@@ -384,20 +387,36 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
//校验PIN是否满足 上衣或者下衣必须不超过8
long topNum = designDTO.getSketchBoards().stream()
long topNum = 0;
long bottomNum = 0;
long outerwearNum = 0;
if (designDTO.getModelSex().equals(Sex.FEMALE.getValue())) {
topNum= designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.OUTWEAR_DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
Assert.isTrue(topNum <= 8, "The number of PIN sketch cannot be greater than 8!");
long bottomNum = designDTO.getSketchBoards().stream()
&& DesignPythonItem.DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
bottomNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
Assert.isTrue(bottomNum <= 8, "The number of PIN sketch cannot be greater than 8!");
}else if (designDTO.getModelSex().equals(Sex.MALE.getValue())) {
topNum= designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.TOPS.contains(skecth.getLevel2Type())).count();
bottomNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.BOTTOMS.contains(skecth.getLevel2Type())).count();
}
outerwearNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.OUTERWEAR.contains(skecth.getLevel2Type())).count();
if (topNum > 8 || bottomNum > 8 || outerwearNum > 8) {
throw new BusinessException("the.number.of.PIN.top.or.bottom.or.outerwear.sketchBoard.cannot.be.more.than.8");
}
//校验designType
Boolean result = designDTO.getSketchBoards().stream()
.filter(mood -> StringUtils.isEmpty(mood.getDesignType()))
.findFirst().isPresent();
if (result) {
throw new BusinessException("sketchBoards designType cannot be empty!");
throw new BusinessException("sketchBoards.designType.cannot.be.empty");
}
List<Long> sketchBoardIds = designDTO.getSketchBoards().stream()
@@ -408,7 +427,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//校验sketchBoard
List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds);
Assert.isTrue(CollectionUtil.isNotEmpty(sketchBoardElements)
&& sketchBoardElements.size() == sketchBoardIds.size(), "get sketchboard data is mismatch");
&& sketchBoardElements.size() == sketchBoardIds.size(), "get.sketchBoards.data.is.mismatch");
elementVO.setSketchBoardElements(sketchBoardElements);
usedElementIds.addAll(sketchBoardIds);
}
@@ -473,43 +492,24 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
// }
//校验控制生成类型
SingleOverallEnum singleOverall = SingleOverallEnum.of(designDTO.getSingleOverall());
Assert.notNull(singleOverall, "unknown parameter singleOverall!");
if (Objects.isNull(singleOverall)) {
throw new BusinessException("unknown.parameter.singleOverall");
}
if (SingleOverallEnum.SINGLE.equals(singleOverall)) {
SwitchCategoryEnum switchCategory = SwitchCategoryEnum.of(designDTO.getSwitchCategory());
Assert.notNull(switchCategory, "unknown parameter switchCategory!");
if (Objects.isNull(switchCategory)) {
throw new BusinessException("unknown.parameter.switchCategory");
}
//校验template
if (Objects.nonNull(designDTO.getTemplateId())) {
// LibraryModelPoint modelPoint = libraryModelPointService.getById(designDTO.getTemplateId());
// Assert.notNull(modelPoint, "template cannot by empty!");
// Library library = libraryService.getById(modelPoint.getLibraryId());
// Assert.notNull(library, "template library cannot by empty!");
}
// 校验模特
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library byId = libraryService.getById(designDTO.getTemplateId());
QueryWrapper<LibraryModelPoint> qw = new QueryWrapper<>();
qw.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
qw.lambda().eq(LibraryModelPoint::getRelationId, byId.getId());
LibraryModelPoint modelPoint = libraryModelPointService.getOne(qw);
if (Objects.isNull(modelPoint)) {
throw new BusinessException("error modelPoint get");
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
QueryWrapper<LibraryModelPoint> qw = new QueryWrapper<>();
qw.lambda().eq(LibraryModelPoint::getModelType, ModelType.SYSTEM.getValue());
qw.lambda().eq(LibraryModelPoint::getRelationId, byId.getId());
LibraryModelPoint modelPoint = libraryModelPointService.getOne(qw);
if (Objects.isNull(modelPoint)) {
throw new BusinessException("error modelPoint get");
}
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 1050, 500, byId.getUrl()));
}
} else {
throw new BusinessException("templateId or modelType can't be null");
}
if (StringUtils.isEmpty(designDTO.getModelSex())) {
throw new BusinessException("modelSex can't be null");
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 680, 200, byId.getUrl()));
}
elementVO.setModelSex(designDTO.getModelSex());
return elementVO;
@@ -597,7 +597,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
private void validateDesignType(List<DesignCollectionElementDTO> collectionElements, String msg) {
Boolean result = collectionElements.stream().filter(mood -> StringUtils.isEmpty(mood.getDesignType())).findFirst().isPresent();
if (result) {
throw new BusinessException(msg + " designType cannot be empty!");
throw new BusinessException(msg + ".designType.cannot.be.empty");
}
}
@@ -638,7 +638,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return;
}
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", elementIds);
queryWrapper.lambda().in(CollectionElement::getId, elementIds);
CollectionElement element = new CollectionElement();
element.setCollectionId(collectionId);
//批量关联

View File

@@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@@ -97,7 +98,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Value("${minio.bucketName.results}")
private String bucketName;
// @Transactional
@Override
public DesignCollectionVO designCollection(DesignCollectionDTO designDTO) {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
@@ -156,7 +156,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
element.setHasPin((byte) 0);
}
element.setId(null);
// element.setType(DesignTypeEnum.LIBRARY.getRealName());
});
List<CollectionElement> saveElements = elementVO.getLibraryCollectionElements();
collectionElementService.saveBatch(saveElements);
@@ -299,8 +298,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
//组装design入参
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
//缓存保存的文件 方便后面处理进度问题 采用新的进度条获取方式 根据processId获取
// setDesignProcess(userInfo.getId(), pythonObjects);
// pythonObjects增加image_id关联
relationImageId(pythonObjects);
//design
@@ -308,13 +305,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
//生成library
generateLibrary(elementVO, designDTO.getTimeZone());
//处理关联关系,修复element覆盖得情况
List<CollectionElement> reLationelements = collectionElementService.getByOnlyCollectionId(collectionId);
List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
//保存python返回信息
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
//保存python返回信息;保存designItem和detail
return savePythonDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone(), responseJSONObject, designDTO.getSingleOverall());
//保存designItem 和detail
// return saveDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone());
}
@Override

View File

@@ -1,5 +1,6 @@
package com.ai.da.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONUtil;
import com.ai.da.common.config.exception.BusinessException;
@@ -137,10 +138,14 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
@Override
public LibraryModelPoint getByRelationId(Long relationId, String modelType) {
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("relation_id", relationId)
.eq("model_type", modelType);
return baseMapper.selectOne(queryWrapper);
queryWrapper.lambda().eq(LibraryModelPoint::getRelationId, relationId);
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, modelType);
queryWrapper.lambda().last("limit 1");
List<LibraryModelPoint> libraryModelPoints = baseMapper.selectList(queryWrapper);
if (CollectionUtil.isNotEmpty(libraryModelPoints)) {
throw new BusinessException("modelPoint.not.find");
}
return libraryModelPoints.get(0);
}
}

View File

@@ -182,7 +182,7 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
private List<PantoneVO> coverPanToneToVoList(List<PanTone> panTones
, Map<Integer, Integer> indexToValue, Map<Integer, GetRgbByHsvBatchDTO> valueToHsv,
List<GetRgbByHsvBatchDTO> hsvBatch) {
if (Objects.isNull(panTones)) {
if (CollectionUtil.isEmpty(panTones)) {
throw new BusinessException("Pantone value does not exist !");
}
List<PantoneVO> templateResposne = CopyUtil.copyList(panTones, PantoneVO.class, (o, d) -> {

View File

@@ -2,9 +2,9 @@ server.port=5567
#datasource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://18.167.251.121:33006/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.url=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.username=aida_con
spring.datasource.password=123456
#???
spring.datasource.hikari.minimum-idle=5

View File

@@ -0,0 +1,27 @@
# 业务逻辑
system.error=System error!
userName.does.not.exist=UserName does not exist!
user.expired=User expired!
password.error=Password error!
email.error=Email error!
unknown.authentication.operation.type=Unknown authentication operation type!
failed.to.send.mail=Failed to send mail!
email.does.not.exist=Email does not exist!
unknown.login.type=Unknown login type!
error.login.type=Error login type!
the.verification.code.has.expired=The verification code has expired!
verification.code.error=Verification code error!
user.has.bound.mailbox=User has bound mailbox!
# 前端传参校验
singleOverall.cannot.be.empty=SingleOverall cannot be empty!
colorBoards.cannot.be.empty=ColorBoards cannot be empty!
systemScale.cannot.be.empty=SystemScale cannot be empty!
modelType.cannot.be.empty=ModelType cannot be empty!
modelSex.cannot.be.empty=ModelSex cannot be empty!
templateId.cannot.be.empty=TemplateId cannot be empty!
processId.cannot.be.empty=ProcessId cannot be empty!
timeZone.cannot.be.empty=TimeZone cannot be empty!
userId.cannot.be.empty=UserId cannot be empty!
email.cannot.be.empty=Email cannot be empty!
operationType.cannot.be.empty=OperationType cannot be empty!

View File

@@ -0,0 +1 @@
system.error=系统错误!