From 4ef5c982de6093632eaf44e924a32e977a9238de Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Wed, 26 Mar 2025 08:52:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/pojo/constant/DevValidMessage.java | 2 -- .../gather/device/pojo/param/PqDevParam.java | 33 ------------------- .../device/service/impl/PqDevServiceImpl.java | 28 +++++++++++----- .../pojo/constant/PqIcdPathValidMessage.java | 2 ++ .../gather/icd/pojo/param/PqIcdPathParam.java | 2 ++ .../gather/plan/pojo/param/AdPlanParam.java | 27 --------------- .../pojo/constant/PqScriptValidMessage.java | 6 ++++ .../script/pojo/param/PqScriptParam.java | 11 ++++--- .../source/pojo/param/PqSourceParam.java | 2 -- .../service/impl/PqSourceServiceImpl.java | 28 ---------------- .../njcn/gather/system/log/aop/LogAdvice.java | 2 +- .../user/pojo/enums/UserResponseEnum.java | 4 ++- .../user/controller/SysUserController.java | 20 ++--------- .../user/user/service/ISysUserService.java | 13 +------- .../user/service/impl/SysUserServiceImpl.java | 28 +++++++--------- 15 files changed, 54 insertions(+), 154 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java b/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java index df0fe7a6..5980494f 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java @@ -85,8 +85,6 @@ public interface DevValidMessage { String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空,请检查standardTime参数"; String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误,请检查scriptType参数"; - String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误,请检查scriptType参数"; - String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误,请检查scriptType参数"; String DEV_LEVEL_NOT_BLANK = "设备等级不能为空,请检查devLevel参数"; diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java b/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java index f59f7ab9..63a1c562 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java @@ -22,8 +22,6 @@ import java.util.List; public class PqDevParam { @ApiModelProperty(value = "名称", required = true) - //@NotBlank(message = DevValidMessage.NAME_NOT_BLANK) - //@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR) private String name; @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true) @@ -37,13 +35,9 @@ public class PqDevParam { private String devType; @ApiModelProperty(value = "设备厂家,字典表", required = true) - //@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK) - //@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR) private String manufacturer; @ApiModelProperty(value = "出厂日期", required = true) - //@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL) - //@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR) private String createDate; @ApiModelProperty(value = "设备序列号", required = true) @@ -51,11 +45,9 @@ public class PqDevParam { private String createId; @ApiModelProperty(value = "固件版本", required = true) - //@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK) private String hardwareVersion; @ApiModelProperty(value = "软件版本", required = true) - //@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK) private String softwareVersion; @ApiModelProperty(value = "通讯协议", required = true) @@ -123,9 +115,6 @@ public class PqDevParam { @ApiModelProperty("icdId") private String icdId; -// -// @ApiModelProperty("power") -// private String power; @ApiModelProperty("预投计划") private String preinvestmentPlan; @@ -141,26 +130,6 @@ public class PqDevParam { @NotBlank(message = DevValidMessage.ID_NOT_BLANK) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR) private String id; - -// @ApiModelProperty("检测状态") -// @Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR) -// @Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR) -// private Integer checkState; -// -// @ApiModelProperty("检测结果") -// @Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR) -// @Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR) -// private Integer checkResult; -// -// @ApiModelProperty("报告状态") -// @Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR) -// @Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR) -// private Integer reportState; -// -// @ApiModelProperty("归档状态") -// @Min(value = 0, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR) -// @Max(value = 1, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR) -// private Integer documentState; } /** @@ -170,7 +139,6 @@ public class PqDevParam { @EqualsAndHashCode(callSuper = true) public static class QueryParam extends BaseParam { @ApiModelProperty("名称") -// @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR) private String name; @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)") @@ -180,7 +148,6 @@ public class PqDevParam { private String manufacturer; @ApiModelProperty("检测计划ID") - //@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR) private String planId; @ApiModelProperty("检测状态列表") diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java index 1ff50e1b..d4993d86 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java @@ -32,6 +32,7 @@ import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.monitor.pojo.po.PqMonitor; import com.njcn.gather.monitor.service.IPqMonitorService; import com.njcn.gather.storage.service.DetectionDataDealService; +import com.njcn.gather.system.cfg.pojo.enums.SceneEnum; import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.service.ISysTestConfigService; import com.njcn.gather.system.dictionary.pojo.po.DictData; @@ -591,13 +592,16 @@ public class PqDevServiceImpl extends ServiceImpl implements @Override public void exportDev(PqDevParam.QueryParam queryParam) { String currrentScene = sysTestConfigService.getCurrrentScene(); - switch (currrentScene) { - case "0": + SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene); + switch (sceneEnum) { + case PROVINCE_PLATFORM: this.exportProvinceDev(queryParam); break; - case "1": + case LEAVE_FACTORY_TEST: this.exportCNDev(queryParam); break; + case SELF_TEST: + break; default: break; } @@ -606,13 +610,16 @@ public class PqDevServiceImpl extends ServiceImpl implements @Override public void downloadTemplate() { String currrentScene = sysTestConfigService.getCurrrentScene(); - switch (currrentScene) { - case "0": + SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene); + switch (sceneEnum) { + case PROVINCE_PLATFORM: this.downloadProvinceDevTemplate(); break; - case "1": + case LEAVE_FACTORY_TEST: this.downloadCNDevTemplate(); break; + case SELF_TEST: + break; default: break; } @@ -622,13 +629,16 @@ public class PqDevServiceImpl extends ServiceImpl implements @Override public void importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response) { String currrentScene = sysTestConfigService.getCurrrentScene(); - switch (currrentScene) { - case "0": + SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene); + switch (sceneEnum) { + case PROVINCE_PLATFORM: this.importProvinceDev(file, patternId, planId, response); break; - case "1": + case LEAVE_FACTORY_TEST: this.importCNDev(file, patternId, planId, response); break; + case SELF_TEST: + break; default: break; } diff --git a/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java b/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java index 2cdac979..3aba9ad3 100644 --- a/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java @@ -9,4 +9,6 @@ public interface PqIcdPathValidMessage { String ID_FORMAT_ERROR = "id格式错误,请检查id参数"; String NAME_NOT_BLANK = "名称不能为空"; String PATH_NOT_BLANK = "icd存储路径不能为空"; + String NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号,长度为1-50个字符"; + String PATH_FORMAT_ERROR = "ICD路径格式错误"; } diff --git a/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java b/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java index 9c72cf61..b7f3b521 100644 --- a/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java +++ b/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java @@ -19,10 +19,12 @@ import javax.validation.constraints.Pattern; public class PqIcdPathParam { @ApiModelProperty(value = "名称", required = true) @NotBlank(message = PqIcdPathValidMessage.NAME_NOT_BLANK) + @Pattern(regexp = PatternRegex.ICD_NAME_REGEX, message = PqIcdPathValidMessage.NAME_FORMAT_ERROR) private String name; @ApiModelProperty(value = "存储路径", required = true) @NotBlank(message = PqIcdPathValidMessage.PATH_NOT_BLANK) + @Pattern(regexp = PatternRegex.ICD_PATH_REGEX, message = PqIcdPathValidMessage.PATH_FORMAT_ERROR) private String path; /** diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java index 73ec5163..4fb55e84 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java @@ -105,33 +105,6 @@ public class AdPlanParam { @NotBlank(message = DevValidMessage.ID_NOT_BLANK) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR) private String id; - - /** - * 检测状态,字典表(未检、检测中、检测完成) - */ -// @ApiModelProperty(value = "检测状态") -// @NotNull(message = DeviceValidMessage.TEST_STATE_NOT_NULL) -// @Min(value = 0, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR) -// @Max(value = 2, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR) -// private Integer testState; - - /** - * 报告生成状态,字典表(未生成、部分生成、全部生成) - */ -// @ApiModelProperty(value = "报告生成状态") -// @NotNull(message = DeviceValidMessage.REPORT_STATE_NOT_NULL) -// @Min(value = 0, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR) -// @Max(value = 2, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR) -// private Integer reportState; - - /** - * 检测结果,字典表(符合、不符合、/) - */ -// @ApiModelProperty(value = "检测结果") -// @NotNull(message = DeviceValidMessage.CHECK_RESULT_STATE_NOT_NULL) -// @Min(value = 0, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR) -// @Max(value = 2, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR) -// private Integer result; } @Data diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java b/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java index 02e1e2c7..8e692dbe 100644 --- a/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java @@ -8,4 +8,10 @@ public interface PqScriptValidMessage { String INDEX_NOT_NULL = "index不能为空"; String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空"; + + String NAME_FORMAT_ERROR = "脚本名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号,长度为1-50个字符"; + + String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误,请检查ratedVolt参数"; + + String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误,请检查ratedCurr参数"; } diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptParam.java b/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptParam.java index 15d8f2d9..7e3dd9a0 100644 --- a/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptParam.java +++ b/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptParam.java @@ -2,6 +2,7 @@ package com.njcn.gather.script.pojo.param; import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.gather.device.pojo.constant.DevValidMessage; +import com.njcn.gather.script.pojo.constant.PqScriptValidMessage; import com.njcn.gather.system.pojo.constant.SystemValidMessage; import com.njcn.web.pojo.annotation.DateTimeStrValid; import com.njcn.web.pojo.param.BaseParam; @@ -20,6 +21,7 @@ public class PqScriptParam { @ApiModelProperty("名称") @NotBlank(message = DevValidMessage.NAME_NOT_BLANK) + @Pattern(regexp = PatternRegex.SCRIPT_NAME_REGEX, message = PqScriptValidMessage.NAME_FORMAT_ERROR) private String name; @ApiModelProperty("类型") @@ -44,7 +46,6 @@ public class PqScriptParam { @ApiModelProperty("参照标准名称") @NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK) - //@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR) private String standardName; @@ -59,8 +60,8 @@ public class PqScriptParam { */ @ApiModelProperty("额定电压") @NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK) - @Min(value = 0, message = DevValidMessage.SCRIPT_VOLT_FORMAT_ERROR) - @Max(value = 380, message = DevValidMessage.SCRIPT_VOLT_FORMAT_ERROR) + @Min(value = 0, message = PqScriptValidMessage.SCRIPT_VOLT_FORMAT_ERROR) + @Max(value = 380, message = PqScriptValidMessage.SCRIPT_VOLT_FORMAT_ERROR) private Double ratedVolt; /** @@ -68,8 +69,8 @@ public class PqScriptParam { */ @ApiModelProperty("额定电流") @NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK) - @Min(value = 0, message = DevValidMessage.SCRIPT_CURR_FORMAT_ERROR) - @Max(value = 20, message = DevValidMessage.SCRIPT_CURR_FORMAT_ERROR) + @Min(value = 0, message = PqScriptValidMessage.SCRIPT_CURR_FORMAT_ERROR) + @Max(value = 20, message = PqScriptValidMessage.SCRIPT_CURR_FORMAT_ERROR) private Double ratedCurr; diff --git a/detection/src/main/java/com/njcn/gather/source/pojo/param/PqSourceParam.java b/detection/src/main/java/com/njcn/gather/source/pojo/param/PqSourceParam.java index bd5f88c8..73c1f3c2 100644 --- a/detection/src/main/java/com/njcn/gather/source/pojo/param/PqSourceParam.java +++ b/detection/src/main/java/com/njcn/gather/source/pojo/param/PqSourceParam.java @@ -51,8 +51,6 @@ public class PqSourceParam { @ApiModelProperty("源参数") private String parameter; -// @ApiModelProperty("源参数") -// private List parameterList; @Data public static class QueryParam extends BaseParam { diff --git a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java index 33e1ed44..ab7cc391 100644 --- a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java @@ -169,34 +169,6 @@ public class PqSourceServiceImpl extends ServiceImpl i .collect(Collectors.toList()); } -// private List filterTree(List tree, String keyword) { -// if (CollectionUtils.isEmpty(tree) || StrUtil.isBlank(keyword)) { -// return tree; -// } -// filter(tree, keyword); -// return tree; -// } - -// private void filter(List list, String keyword) { -// for (int i = list.size() - 1; i >= 0; i--) { -// SourceParam sourceParam = list.get(i); -// List children = sourceParam.getChildren(); -// if (!keyword.equals(sourceParam.getType())) { -// if (!CollectionUtils.isEmpty(children)) { -// filter(children, keyword); -// } -// if (CollectionUtils.isEmpty(sourceParam.getChildren())) { -// list.remove(i); -// } -// } -// else { -// if (!CollectionUtils.isEmpty(children)) { -// filter(children, keyword); -// } -// } -// } -// } - /** * 生成检测源名称(检测源类型+设备类型+数字) diff --git a/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java b/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java index 181d0166..20d8f241 100644 --- a/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java +++ b/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java @@ -121,7 +121,7 @@ public class LogAdvice implements ApplicationListener { if (apiOperation != null) { //注解上的描述 String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - sysLogAudit.setRemark(username + "用户:" + now + " " + apiOperation.value() + " " + resultStr); + sysLogAudit.setRemark(username + ":" + now + " " + apiOperation.value() + " " + resultStr); } //Object[] args = joinPoint.getArgs(); logQueue.add(sysLogAudit); diff --git a/user/src/main/java/com/njcn/gather/user/pojo/enums/UserResponseEnum.java b/user/src/main/java/com/njcn/gather/user/pojo/enums/UserResponseEnum.java index db81cf50..32608e06 100644 --- a/user/src/main/java/com/njcn/gather/user/pojo/enums/UserResponseEnum.java +++ b/user/src/main/java/com/njcn/gather/user/pojo/enums/UserResponseEnum.java @@ -22,7 +22,9 @@ public enum UserResponseEnum { COMPONENT_NOT_BLANK("A010011", "组件地址不能为空"), FUNCTION_PATH_FORMAT_ERROR("A010012", "路由地址格式错误"), SUPER_ADMIN_REPEAT("A010013","超级管理员已存在,请勿重复添加" ), - RSA_DECRYT_ERROR("A010014","RSA解密失败" ); + RSA_DECRYT_ERROR("A010014","RSA解密失败" ), + PASSWORD_SAME("A010015", "新密码不能与旧密码相同"), + OLD_PASSWORD_ERROR("A010016", "旧密码错误"); private String code; private String message; diff --git a/user/src/main/java/com/njcn/gather/user/user/controller/SysUserController.java b/user/src/main/java/com/njcn/gather/user/user/controller/SysUserController.java index e18e91cd..488a22f0 100644 --- a/user/src/main/java/com/njcn/gather/user/user/controller/SysUserController.java +++ b/user/src/main/java/com/njcn/gather/user/user/controller/SysUserController.java @@ -4,13 +4,10 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; -import com.njcn.common.pojo.constant.SecurityConstants; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; -import com.njcn.common.utils.JwtUtil; import com.njcn.common.utils.LogUtil; -import com.njcn.gather.user.pojo.constant.UserValidMessage; import com.njcn.gather.user.user.pojo.param.SysUserParam; import com.njcn.gather.user.user.pojo.po.SysUser; import com.njcn.gather.user.user.service.ISysUserService; @@ -22,11 +19,9 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.logging.log4j.util.Strings; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -120,21 +115,12 @@ public class SysUserController extends BaseController { public HttpResult updatePassword(@RequestBody @Validated SysUserParam.SysUserUpdatePasswordParam param) { String methodDescribe = getMethodDescribe("updatePassword"); LogUtil.njcnDebug(log, "{},用户id:{},用户旧密码:{},新密码:{}", methodDescribe, param.getId(), param.getOldPassword(), param.getNewPassword()); - if (param.getOldPassword().equals(param.getNewPassword())) { - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "新密码不能与旧密码相同", methodDescribe); - } - boolean result = sysUserService.oldPwdConfirm(param.getId(), param.getOldPassword()); + boolean result = sysUserService.updatePassword(param); if (!result) { - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "原密码错误", methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe); } else { - result = sysUserService.updatePassword(param.getId(), param.getNewPassword()); - if (!result) { - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "修改密码失败", methodDescribe); - } else { - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); - } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); } } - } diff --git a/user/src/main/java/com/njcn/gather/user/user/service/ISysUserService.java b/user/src/main/java/com/njcn/gather/user/user/service/ISysUserService.java index 251fcb51..9642992a 100644 --- a/user/src/main/java/com/njcn/gather/user/user/service/ISysUserService.java +++ b/user/src/main/java/com/njcn/gather/user/user/service/ISysUserService.java @@ -82,22 +82,11 @@ public interface ISysUserService extends IService { */ boolean updateUser(SysUserParam.SysUserUpdateParam updateUserParam); - /** - * 原密码确认 - * - * @param userId 用户ID - * @param oldPassword 原密码 - * @return 结果,true表示确认成功,false表示确认失败 - */ - boolean oldPwdConfirm(String userId, String oldPassword); - /** * 修改密码 - * @param userId - * @param newPassword * @return 结果,true表示修改成功,false表示修改失败 */ - boolean updatePassword(String userId, String newPassword); + boolean updatePassword(SysUserParam.SysUserUpdatePasswordParam param); /** * 批量删除用户 diff --git a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java index ea7e26d4..d68576d8 100644 --- a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java +++ b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java @@ -144,28 +144,22 @@ public class SysUserServiceImpl extends ServiceImpl impl return this.updateById(sysUser); } - @Override - public boolean oldPwdConfirm(String userId, String oldPassword) { - SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, userId).one(); - if (ObjectUtil.isNotNull(user)) { - String secretkey = Sm4Utils.globalSecretKey; - Sm4Utils sm4 = new Sm4Utils(secretkey); - if (sm4.encryptData_ECB(oldPassword).equals(user.getPassword())) { - return true; - } - } - return false; - } - @Override @Transactional - public boolean updatePassword(String userId, String newPassword) { - SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, userId).one(); + public boolean updatePassword(SysUserParam.SysUserUpdatePasswordParam param) { + if (param.getOldPassword().equals(param.getNewPassword())) { + throw new BusinessException(UserResponseEnum.PASSWORD_SAME); + } + SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, param.getId()).one(); if (ObjectUtil.isNotNull(user)) { String secretkey = Sm4Utils.globalSecretKey; Sm4Utils sm4 = new Sm4Utils(secretkey); - user.setPassword(sm4.encryptData_ECB(newPassword)); - return this.updateById(user); + if (sm4.encryptData_ECB(param.getOldPassword()).equals(user.getPassword())) { + user.setPassword(sm4.encryptData_ECB(param.getNewPassword())); + return this.updateById(user); + }else { + throw new BusinessException(UserResponseEnum.OLD_PASSWORD_ERROR); + } } return false; }