feat: 代码提交

dev
zhanglei 2026-07-03 10:18:14 +08:00
parent 0dceb829f8
commit e1578d9938
6 changed files with 40 additions and 8 deletions

View File

@ -34,7 +34,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(BizException.class)
public ResponseEntity<SingleResponse<Void>> handleBizException(BizException exception) {
String message = message("error." + exception.getCode(), exception.getMessage());
return response(HttpStatus.BAD_REQUEST, exception.getCode(), message);
return response(HttpStatus.OK, exception.getCode(), message);
}
@ExceptionHandler(MethodArgumentNotValidException.class)
@ -42,7 +42,7 @@ public class GlobalExceptionHandler {
MethodArgumentNotValidException exception) {
FieldError fieldError = exception.getBindingResult().getFieldError();
String fallback = fieldError == null ? null : fieldError.getDefaultMessage();
return response(HttpStatus.BAD_REQUEST, VALIDATION_ERROR_CODE,
return response(HttpStatus.OK, VALIDATION_ERROR_CODE,
message("validation.failed", fallback));
}
@ -50,20 +50,20 @@ public class GlobalExceptionHandler {
public ResponseEntity<SingleResponse<Void>> handleBindException(BindException exception) {
FieldError fieldError = exception.getBindingResult().getFieldError();
String fallback = fieldError == null ? null : fieldError.getDefaultMessage();
return response(HttpStatus.BAD_REQUEST, VALIDATION_ERROR_CODE,
return response(HttpStatus.OK, VALIDATION_ERROR_CODE,
message("validation.failed", fallback));
}
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<SingleResponse<Void>> handleConstraintViolation(
ConstraintViolationException exception) {
return response(HttpStatus.BAD_REQUEST, VALIDATION_ERROR_CODE,
return response(HttpStatus.OK, VALIDATION_ERROR_CODE,
message("validation.failed", exception.getMessage()));
}
@ExceptionHandler({HttpMessageNotReadableException.class, MissingServletRequestParameterException.class})
public ResponseEntity<SingleResponse<Void>> handleInvalidRequest(Exception exception) {
return response(HttpStatus.BAD_REQUEST, VALIDATION_ERROR_CODE,
return response(HttpStatus.OK, VALIDATION_ERROR_CODE,
message("request.invalid", exception.getMessage()));
}

View File

@ -1,5 +1,8 @@
package org.qinan.safetyeval.app.executor;
import com.jjb.saas.system.client.user.request.UserAddCmd;
import com.zcloud.gbscommon.utils.MD5;
import com.zcloud.gbscommon.utils.Sm2Util;
import org.qinan.safetyeval.client.api.AccountApi;
import org.qinan.safetyeval.client.co.AccountCO;
import org.qinan.safetyeval.client.dto.AccountAddCmd;
@ -12,9 +15,12 @@ import org.qinan.safetyeval.domain.query.AccountQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.AccountDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsUserFacadeClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* App
@ -27,8 +33,15 @@ public class AccountExecutor implements AccountApi {
@Lazy
@Autowired(required = false)
private AccountDomainService accountDomainService;
@Autowired
private GbsUserFacadeClient gbsUserFacadeClient;
@Value("${def.password:a123456}")
private String defPassword;
@Value("${def.publicKey:0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee}")
private String publicKey;
@Override
@Transactional(rollbackFor = Exception.class)
public SingleResponse<AccountCO> add(AccountAddCmd cmd) {
AccountEntity entity = new AccountEntity();
entity.setUserName(cmd.getUserName());
@ -37,8 +50,16 @@ public class AccountExecutor implements AccountApi {
entity.setPassword(cmd.getPassword());
entity.setProfileUrl(cmd.getProfileUrl());
entity.setType(cmd.getType());
AccountEntity result = accountDomainService.add(entity);
// 同步gbs用户
UserAddCmd userAddCmd = new UserAddCmd();
userAddCmd.setId(result.getId());
userAddCmd.setAccount(result.getAccount());
userAddCmd.setTenantId(result.getTenantId());
userAddCmd.setName(result.getUserName());
String encrypt = Sm2Util.encryptHex(MD5.md5(defPassword), publicKey);
userAddCmd.setPassword(encrypt);
gbsUserFacadeClient.add(userAddCmd);
return SingleResponse.success(toCO(result));
}

View File

@ -26,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -214,6 +213,7 @@ public class QualFilingExecutor implements QualFilingApi {
QualFilingDO qualFilingDO = qualFilingMapper.selectById(cmd.getFilingId());
QualFilingChangeAddCmd qualFilingChangeAddCmd = new QualFilingChangeAddCmd();
BeanUtils.copyProperties(qualFilingDO, qualFilingChangeAddCmd, "id");
qualFilingChangeAddCmd.setFilingId(qualFilingDO.getId());
cmdSync.setQualFilingChangeAddCmd(qualFilingChangeAddCmd);
// 备案承诺书
QualFilingCommitmentDO qualFilingCommitmentDO = qualFilingCommitmentMapper.selectOne(new LambdaQueryWrapper<QualFilingCommitmentDO>()

View File

@ -19,6 +19,8 @@ public class QualFilingChangeAddCmd {
@ApiModelProperty(value = "备案申请id")
private Long filingId;
private Long orgId;
@ApiModelProperty(value = "关联变更的id")
private Long changeFilingId;

View File

@ -23,6 +23,9 @@ public class SingleResponse<T> {
@ApiModelProperty(value = "响应消息")
private String message;
@ApiModelProperty(value = "错误响应消息")
private String errMessage;
@ApiModelProperty(value = "响应数据")
private T data;
@ -46,6 +49,7 @@ public class SingleResponse<T> {
response.setSuccess(false);
response.setCode(code);
response.setMessage(message);
response.setErrMessage(message);
return response;
}
}

View File

@ -2,7 +2,6 @@ package org.qinan.safetyeval.infrastructure.support;
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingExpertDO;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
@ -86,6 +85,8 @@ public final class InsertFieldDefaults {
LocalDateTime now = LocalDateTime.now();
Long userId = AuthUserContextAdapter.getCurrentUserId();
String userName = AuthUserContextAdapter.getCurrentUserName();
// 机构信息id
Long orgInfoId = ThreadLocalUserInfoAdapter.get();
setIfNull(dataObject, "updateTime", now);
if (userId != null) {
@ -94,6 +95,10 @@ public final class InsertFieldDefaults {
if (userName != null) {
setIfNull(dataObject, "updateName", userName);
}
if (orgInfoId != null) {
// 机构信息id
setIfNull(dataObject, "orgId", orgInfoId);
}
}
private static void setIfNull(Object target, String property, Object value) {