Przeglądaj źródła

返参信息提示修改+迁移模块代码

small 2 lat temu
rodzic
commit
084756b723
22 zmienionych plików z 434 dodań i 258 usunięć
  1. 29 2
      sckw-auth/src/main/java/com/sckw/auth/controller/AuthController.java
  2. 45 0
      sckw-auth/src/main/java/com/sckw/auth/model/vo/req/UpdatePasswordReqVo.java
  3. 17 4
      sckw-auth/src/main/java/com/sckw/auth/service/IAuthService.java
  4. 26 3
      sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java
  5. 3 3
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/LoginFilter.java
  6. 7 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/constant/Global.java
  7. 10 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java
  8. 16 4
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteUserService.java
  9. 39 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/UpdatePasswordReqDto.java
  10. 11 8
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsDeptController.java
  11. 12 13
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java
  12. 18 16
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsMenuController.java
  13. 14 13
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsRoleController.java
  14. 13 50
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsUserController.java
  15. 11 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java
  16. 2 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EditRoleReqVo.java
  17. 1 4
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EntRegisterReqVo.java
  18. 18 15
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsDeptService.java
  19. 73 74
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java
  20. 16 18
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java
  21. 17 13
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java
  22. 36 18
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

+ 29 - 2
sckw-auth/src/main/java/com/sckw/auth/controller/AuthController.java

@@ -3,8 +3,10 @@ package com.sckw.auth.controller;
 import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
 import com.sckw.auth.model.vo.req.LoginReqVo;
 import com.sckw.auth.model.vo.req.RegisterReqVo;
+import com.sckw.auth.model.vo.req.UpdatePasswordReqVo;
 import com.sckw.auth.service.IAuthService;
 import com.sckw.core.exception.SystemException;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import jakarta.validation.Valid;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,7 +46,7 @@ public class AuthController {
     @PostMapping("/register")
     public HttpResult register(@Valid @RequestBody RegisterReqVo reqDto) throws SystemException {
         authService.register(reqDto);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_007);
     }
 
     /**
@@ -57,7 +59,32 @@ public class AuthController {
     @PostMapping("/forgetPassword")
     public HttpResult forgetPassword(@Valid @RequestBody ForgetPasswordReqVo reqDto) throws SystemException {
         authService.forgetPassword(reqDto);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_002);
     }
 
+    /**
+     * @param {password 旧密码、newPassword 新密码、account 账号}
+     * @description 修改密码
+     * @author zk
+     * @date 2023/06/02
+     **/
+    @PostMapping("/updatePassword")
+    public HttpResult updatePassword(@Valid @RequestBody UpdatePasswordReqVo reqVo) {
+        authService.updatePassword(reqVo);
+        return HttpResult.ok(HttpStatus.MSG_002);
+    }
+
+    /**
+     * @param id 主键ID
+     * @description 重置密码
+     * @author zk
+     * @date 2023/06/02
+     **/
+    @PostMapping("/resetPassword")
+    public HttpResult resetPassword(@RequestParam Long id) {
+        authService.resetPassword(id);
+        return HttpResult.ok(HttpStatus.MSG_001);
+    }
+
+
 }

+ 45 - 0
sckw-auth/src/main/java/com/sckw/auth/model/vo/req/UpdatePasswordReqVo.java

@@ -0,0 +1,45 @@
+package com.sckw.auth.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 修改密码
+ * @date 2023/7/3
+ */
+@Data
+public class UpdatePasswordReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -6273651661499793569L;
+
+    /**
+     * 账号
+     */
+    @NotBlank(message = "账号不能为空")
+    private String account;
+
+    /**
+     * 旧密码
+     */
+    @NotBlank(message = "密码不能为空")
+    private String password;
+
+    /**
+     * 新密码
+     */
+    @NotBlank(message = "新密码不能为空")
+    private String newPassword;
+
+    /**
+     * 系统类型(1运营端、2企业开户)
+     */
+    @NotNull(message = "系统类型不能为空")
+    private int systemType;
+
+}

+ 17 - 4
sckw-auth/src/main/java/com/sckw/auth/service/IAuthService.java

@@ -1,9 +1,6 @@
 package com.sckw.auth.service;
 
-import com.sckw.auth.model.vo.req.EntAuthenticationReqVo;
-import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
-import com.sckw.auth.model.vo.req.LoginReqVo;
-import com.sckw.auth.model.vo.req.RegisterReqVo;
+import com.sckw.auth.model.vo.req.*;
 import com.sckw.auth.model.vo.res.LoginResVo;
 import com.sckw.core.exception.SystemException;
 
@@ -34,4 +31,20 @@ public interface IAuthService {
      * @date: 2023/6/19
      */
     void forgetPassword(ForgetPasswordReqVo reqDto);
+
+    /**
+     * @param reqVo 修改密码入参
+     * @desc: 修改密码
+     * @author: czh
+     * @date: 2023/7/3
+     */
+    void updatePassword(UpdatePasswordReqVo reqVo);
+
+    /**
+     * @param id 用户id
+     * @desc: 重置密码
+     * @author: czh
+     * @date: 2023/7/3
+     */
+    void resetPassword(Long id);
 }

+ 26 - 3
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -5,18 +5,18 @@ import com.alibaba.fastjson.JSON;
 import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
 import com.sckw.auth.model.vo.req.LoginReqVo;
 import com.sckw.auth.model.vo.req.RegisterReqVo;
+import com.sckw.auth.model.vo.req.UpdatePasswordReqVo;
 import com.sckw.auth.model.vo.res.DeptInfoResVo;
 import com.sckw.auth.model.vo.res.EntInfoResVo;
 import com.sckw.auth.model.vo.res.LoginResVo;
 import com.sckw.auth.util.AsyncFactory;
-import com.sckw.core.model.enums.ApprovalEnum;
 import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.utils.StringUtils;
-import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.model.EntCertificateInfo;
 import com.sckw.core.web.model.LoginEntInfo;
 import com.sckw.core.web.model.LoginUserInfo;
 import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
+import com.sckw.system.api.model.dto.req.UpdatePasswordReqDto;
 import com.sckw.system.api.model.dto.req.UserLoginReqDto;
 import com.sckw.system.api.model.dto.res.KwsRoleResDto;
 import com.sckw.core.exception.SystemException;
@@ -72,7 +72,7 @@ public class AuthServiceImpl implements IAuthService {
         /*3、查询用户机构*/
         List<KwsUserDeptResDto> kwsUserDeptResDtos = remoteUserService.queryUserDeptByUserId(userId);
         if (CollectionUtils.isEmpty(kwsUserDeptResDtos)) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.USER_DEPT_NOT_EXISTS);
         }
 
         List<Long> deptIds = kwsUserDeptResDtos.stream().map(KwsUserDeptResDto::getDeptId).toList();
@@ -182,6 +182,18 @@ public class AuthServiceImpl implements IAuthService {
         remoteUserService.forgetPassword(forgetPasswordReqDto);
     }
 
+    @Override
+    public void updatePassword(UpdatePasswordReqVo reqVo) throws SystemException {
+        UpdatePasswordReqDto updatePassword = new UpdatePasswordReqDto();
+        BeanUtils.copyProperties(reqVo, updatePassword);
+        remoteUserService.updatePassword(updatePassword);
+    }
+
+    @Override
+    public void resetPassword(Long id) {
+        remoteUserService.resetPassword(id);
+    }
+
 
     static class AsyncProcess implements Runnable {
 
@@ -223,7 +235,18 @@ public class AuthServiceImpl implements IAuthService {
             }
             //单独存用户企业
             RedissonUtils.putString(Global.getFullUserEntKey(loginResVo.getSystemType(), loginResVo.getId()), JSON.toJSONString(entInfo), Global.PC_TOKEN_EXPIRE);
+
             //存企业信息
+            saveEntLoginInfo(entInfo);
+        }
+
+        /**
+         * @param entInfo 企业信息
+         * @desc: 存企业信息
+         * @author: czh
+         * @date: 2023/7/3
+         */
+        private void saveEntLoginInfo(EntInfoResVo entInfo) {
             LoginEntInfo loginEntInfo = new LoginEntInfo();
             loginEntInfo.setId(entInfo.getId());
             loginEntInfo.setFirmName(entInfo.getFirmName());

+ 3 - 3
sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/LoginFilter.java

@@ -91,7 +91,7 @@ public class LoginFilter implements Filter {
         String systemType = request.getHeader(RequestConstant.SYSTEM_TYPE);
         String userInfo = RedissonUtils.getString(Global.getFullUserLoginKey(Integer.parseInt(systemType), Long.parseLong(key), clientType));
         if (StringUtils.isBlank(userInfo)) {
-            throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.TOKEN_INVAILD);
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ACCOUNT_NOT_EXISTS);
         }
 
         //将redis里的用户信息存入内存中,避免业务操作多次从redis获取值*/
@@ -134,14 +134,14 @@ public class LoginFilter implements Filter {
         //正常不存在企业等信息为空还能走到这里的请求,因为只能访问放开的权限,如果有恶意请求,这里会过滤
         if (StringUtils.isBlank(enterpriseInfo)) {
             LoginUserHolder.remove();
-            throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
         }
 
         //企业资料审批状态校验
         LoginEntInfo loginEntInfo = JSON.parseObject(enterpriseInfo, LoginEntInfo.class);
         if (!loginEntInfo.getValid()) {
             LoginUserHolder.remove();
-            throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_INVAILD);
         }
 //        int approval = loginEntInfo.getApproval();
 //        if (approval == ApprovalEnum.NO.getCode() || approval == ApprovalEnum.PROCESS.getCode() || approval == ApprovalEnum.PASS.getCode()) {

+ 7 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/constant/Global.java

@@ -76,6 +76,9 @@ public class Global {
     /**ok*/
     public static final String OK = "OK";
 
+    /**忘记密码获取验证码*/
+    public static final String FORGET_SMS = "forget:";
+
     /**用户登录验证码*/
     public static final String USER_LOGIN_CAPTCHA = "userLoginCaptcha:";
 
@@ -242,4 +245,8 @@ public class Global {
         return REDIS_SYS_MENU_PREFIX + systemType + COLON + userId;
     }
 
+    /**完整的忘记密码获取验证码key*/
+    public static String getForgetKey(Integer systemType, String account) {
+        return FORGET_SMS + systemType + COLON + account;
+    }
 }

+ 10 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -35,6 +35,8 @@ public class HttpStatus {
     public static final String TOKEN_INVAILD = "无效token";
     public static final String TOKEN_ERROR = "非法token!";
     public static final String CAPCHA_ERROR = "验证码无效!";
+    public static final String ENT_EXISTS = "企业已存在,不可重复!";
+
 
 
     /**其他自定义状态码*/
@@ -114,7 +116,10 @@ public class HttpStatus {
     public static final String ACCOUNT_NOT_EXISTS = "用户信息不存在或已失效";
     public static final String ENT_NOT_EXISTS = "企业信息不存在或已失效";
     public static final String ENTCERTIFICATES_NOT_EXISTS = "未查询到企业资质信息";
+    public static final String ENTCERTIFICATES_INVAILD = "企业资质已失效";
     public static final String ROLE_NOT_EXISTS = "未查询到关联的角色";
+    public static final String USER_DEPT_NOT_EXISTS = "未查询到用户-机构关联信息";
+    public static final String MENU_NOT_EXISTS = "未查询菜单信息";
 
     /**自定义提示消息*/
     public static final String PASSWD_ERROR = "密码不正确";
@@ -126,4 +131,9 @@ public class HttpStatus {
     public static final String MSG_004 = "审批完成";
     public static final String MSG_005 = "更新成功";
     public static final String MSG_006 = "当前系统不允许绑定多个岗位!";
+    public static final String MSG_007 = "注册成功!";
+    public static final String MSG_008 = "删除成功!";
+    public static final String MSG_009 = "认证提交成功!";
+    public static final String MSG_010 = "绑定成功!";
+    public static final String MSG_011 = "当前企业还存在员工数据,不能删除!";
 }

+ 16 - 4
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteUserService.java

@@ -1,10 +1,7 @@
 package com.sckw.system.api;
 
 import com.sckw.core.exception.SystemException;
-import com.sckw.system.api.model.dto.req.EntAuthenticationReqDto;
-import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
-import com.sckw.system.api.model.dto.req.RegisterReqDto;
-import com.sckw.system.api.model.dto.req.UserLoginReqDto;
+import com.sckw.system.api.model.dto.req.*;
 import com.sckw.system.api.model.dto.res.*;
 import java.util.List;
 
@@ -128,4 +125,19 @@ public interface RemoteUserService {
      */
     List<EntCheckTrackResDto> checkTrackByEntId(Long entId);
 
+    /**
+     * @param updatePassword 修改密码入参
+     * @desc: 修改密码
+     * @author: czh
+     * @date: 2023/7/3
+     */
+    void updatePassword(UpdatePasswordReqDto updatePassword);
+
+    /**
+     * @param id 用户id
+     * @desc: 重置密码
+     * @author: czh
+     * @date: 2023/7/3
+     */
+    void resetPassword(Long id);
 }

+ 39 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/UpdatePasswordReqDto.java

@@ -0,0 +1,39 @@
+package com.sckw.system.api.model.dto.req;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 修改密码入参
+ * @date 2023/7/3
+ */
+@Data
+public class UpdatePasswordReqDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 610262871898122771L;
+
+    /**
+     * 账号
+     */
+    private String account;
+
+    /**
+     * 旧密码
+     */
+    private String password;
+
+    /**
+     * 新密码
+     */
+    private String newPassword;
+
+    /**
+     * 系统类型(1运营端、2企业开户)
+     */
+    private int systemType;
+
+}

+ 11 - 8
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsDeptController.java

@@ -1,5 +1,7 @@
 package com.sckw.system.controller;
 
+import com.sckw.core.exception.SystemException;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.model.KwsDept;
 import com.sckw.system.service.KwsDeptService;
@@ -27,7 +29,7 @@ public class KwsDeptController {
      * @date 2023/5/30
      **/
     @GetMapping("/detail")
-    public HttpResult selectByKey(Long id) throws Exception {
+    public HttpResult selectByKey(Long id) throws SystemException {
         KwsDept sysDict = kwsDeptService.selectByKey(id);
         return HttpResult.ok(sysDict);
     }
@@ -40,7 +42,7 @@ public class KwsDeptController {
      * @date 2023/5/30
      **/
     @PostMapping("/findDeptTree")
-    public HttpResult findPage(@RequestBody KwsDept params) throws Exception {
+    public HttpResult findPage(@RequestBody KwsDept params) throws SystemException {
         return HttpResult.ok(kwsDeptService.findTree(params));
     }
 
@@ -52,9 +54,9 @@ public class KwsDeptController {
      * @date 2023/5/30
      **/
     @PostMapping("/add")
-    public HttpResult add(@Valid @RequestBody KwsDept params) throws Exception {
+    public HttpResult add(@Valid @RequestBody KwsDept params) throws SystemException {
         kwsDeptService.add(params);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_003);
     }
 
     /**
@@ -65,8 +67,9 @@ public class KwsDeptController {
      * @date 2023/5/30
      **/
     @PostMapping("/update")
-    public HttpResult update(@RequestBody KwsDept params) throws Exception {
-        return kwsDeptService.update(params);
+    public HttpResult update(@RequestBody KwsDept params) throws SystemException {
+        kwsDeptService.update(params);
+        return HttpResult.ok(HttpStatus.MSG_005);
     }
 
     /**
@@ -77,9 +80,9 @@ public class KwsDeptController {
      * @date 2023/5/30
      **/
     @PostMapping("/dels")
-    public HttpResult del(@RequestParam String ids) throws Exception {
+    public HttpResult del(@RequestParam String ids) throws SystemException {
         kwsDeptService.deleteByKey(ids);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_008);
     }
 
 }

+ 12 - 13
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -3,7 +3,6 @@ package com.sckw.system.controller;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
-import com.sckw.system.model.KwsEntCheckTrack;
 import com.sckw.system.model.KwsEnterprise;
 import com.sckw.system.model.vo.req.*;
 import com.sckw.system.service.KwsEnterpriseService;
@@ -32,7 +31,7 @@ public class KwsEnterpriseController {
      * @date 2023/06/02
      **/
     @GetMapping("/detail")
-    public HttpResult selectByKey(Long id) throws Exception {
+    public HttpResult selectByKey(Long id) throws SystemException {
         return HttpResult.ok(kwsEntService.selectByKey(id));
     }
 
@@ -44,7 +43,7 @@ public class KwsEnterpriseController {
      * @date 2023/5/30
      **/
     @PostMapping("/findPage")
-    public HttpResult findPage(@RequestBody EntFindPageReqVo pageReqVo) throws Exception {
+    public HttpResult findPage(@RequestBody EntFindPageReqVo pageReqVo) throws SystemException {
         return HttpResult.ok(kwsEntService.findPage(pageReqVo));
     }
 
@@ -56,7 +55,7 @@ public class KwsEnterpriseController {
      * @date 2023/06/02
      **/
     @GetMapping("/certificate")
-    public HttpResult certificate(@RequestParam Long id) throws Exception {
+    public HttpResult certificate(@RequestParam Long id) throws SystemException {
         return HttpResult.ok(kwsEntService.certificate(id));
     }
 
@@ -69,7 +68,7 @@ public class KwsEnterpriseController {
     @PostMapping("/register")
     public HttpResult register(@Valid @RequestBody EntRegisterReqVo reqVo) {
         kwsEntService.register(reqVo);
-        return HttpResult.ok(HttpStatus.MSG_003);
+        return HttpResult.ok(HttpStatus.MSG_009);
     }
 
     /**
@@ -82,7 +81,7 @@ public class KwsEnterpriseController {
     @PostMapping("/addEntSettle")
     public HttpResult addEntSettle(@Valid @RequestBody AddEntSettleReqVo reqVo) throws SystemException {
         kwsEntService.addEntSettle(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_003);
     }
 
     /**
@@ -94,9 +93,9 @@ public class KwsEnterpriseController {
      **/
     @PostMapping("/add")
     @Deprecated
-    public HttpResult add(@RequestBody KwsEnterprise params) throws Exception {
+    public HttpResult add(@RequestBody KwsEnterprise params) throws SystemException {
         kwsEntService.add(params);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_003);
     }
 
     /**
@@ -107,7 +106,7 @@ public class KwsEnterpriseController {
      **/
     @Deprecated
     @PostMapping("/update")
-    public HttpResult update(@RequestBody KwsEnterpriseReqVo reqVo) throws Exception {
+    public HttpResult update(@RequestBody KwsEnterpriseReqVo reqVo) throws SystemException {
         kwsEntService.update(reqVo);
         return HttpResult.ok(HttpStatus.MSG_005);
     }
@@ -119,7 +118,7 @@ public class KwsEnterpriseController {
      * @date 2023/06/02
      **/
     @PostMapping("/updateCertificate")
-    public HttpResult updateCertificate(@RequestBody UpdateCertificateReqVo reqVo) throws Exception {
+    public HttpResult updateCertificate(@RequestBody UpdateCertificateReqVo reqVo) throws SystemException {
         kwsEntService.updateCertificate(reqVo);
         return HttpResult.ok(HttpStatus.MSG_005);
     }
@@ -134,7 +133,7 @@ public class KwsEnterpriseController {
      * @date 2023/06/02
      **/
     @PostMapping("/dels")
-    public HttpResult del(@RequestParam String ids) throws Exception {
+    public HttpResult del(@RequestParam String ids) throws SystemException {
         kwsEntService.deleteByKey(ids);
         return HttpResult.ok();
     }
@@ -160,7 +159,7 @@ public class KwsEnterpriseController {
      * @date 2023/06/02
      **/
     @GetMapping("/entCheck")
-    public HttpResult entCheck(@RequestParam Long entId) throws Exception {
+    public HttpResult entCheck(@RequestParam Long entId) throws SystemException {
         return HttpResult.ok(kwsEntService.entCheck(entId));
     }
 
@@ -174,7 +173,7 @@ public class KwsEnterpriseController {
     @PostMapping(value = "/freeze")
     public HttpResult freeze(@RequestBody FreezeReqVo reqVo) {
         kwsEntService.freeze(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_005);
     }
 
     /**

+ 18 - 16
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsMenuController.java

@@ -1,5 +1,7 @@
 package com.sckw.system.controller;
 
+import com.sckw.core.exception.SystemException;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.model.KwsMenu;
 import com.sckw.system.model.vo.req.FindMenuTreeReqVo;
@@ -23,25 +25,25 @@ public class KwsMenuController {
 
     /**
      * @param id 主键ID
-     * @return
-     * @description 根据主键查询
+     * @return KwsMenu
+     * @desc 根据主键查询
      * @author zk
      * @date 2023/5/30
      **/
     @GetMapping("/detail")
-    public HttpResult selectByKey(Long id) throws Exception {
+    public HttpResult selectByKey(Long id) throws SystemException {
         return HttpResult.ok(kwsMenuService.selectByKey(id));
     }
 
     /**
-     * @param params
-     * @return
-     * @description 分页查询
+     * @param reqVo 分页查询
+     * @return KwsMenuResVo
+     * @desc 分页查询
      * @author zk
      * @date 2023/5/30
      **/
     @PostMapping("/findMenuTree")
-    public HttpResult findTree(@RequestBody FindMenuTreeReqVo reqVo) throws Exception {
+    public HttpResult findTree(@RequestBody FindMenuTreeReqVo reqVo) throws SystemException {
         return HttpResult.ok(kwsMenuService.findTree(reqVo));
     }
 
@@ -55,23 +57,23 @@ public class KwsMenuController {
      * @date 2023/5/30
      **/
     @PostMapping("/add")
-    public HttpResult add(@Valid @RequestBody KwsMenu params) throws Exception {
+    public HttpResult add(@Valid @RequestBody KwsMenu params) throws SystemException {
         kwsMenuService.add(params);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_003);
     }
 
     /**
      * @param params {id:主键,clientType:终端类型、parentId:父级id、name:菜单名称、url:跳转地址、perms:权限标识、
      *               type:类型:0目录/1菜单/2按钮、icon:图标、sort:排序、level:层级、custom:是否定制、
      *               isMain:是否主账号、usingRoles:适用企业类型(1供应商,2采购商,34PL物流,43PL物流)}
-     * @return
-     * @description 更新
+     * @desc 更新
      * @author zk
      * @date 2023/5/30
      **/
     @PostMapping("/update")
-    public HttpResult update(@RequestBody KwsMenu params) throws Exception {
-        return kwsMenuService.update(params);
+    public HttpResult update(@RequestBody KwsMenu params) throws SystemException {
+        kwsMenuService.update(params);
+        return HttpResult.ok(HttpStatus.MSG_005);
     }
 
     /**
@@ -82,9 +84,9 @@ public class KwsMenuController {
      * @date 2023/5/30
      **/
     @PostMapping("/dels")
-    public HttpResult del(@RequestParam String ids) throws Exception {
+    public HttpResult del(@RequestParam String ids) throws SystemException {
         kwsMenuService.deleteByKey(ids);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_008);
     }
 
     /**
@@ -97,6 +99,6 @@ public class KwsMenuController {
     @PostMapping("/roleBindMeun")
     public HttpResult roleBindMenu(@Valid @RequestBody RoleBindMenuReqVo reqVo) {
         kwsMenuService.roleBindMenu(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_010);
     }
 }

+ 14 - 13
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsRoleController.java

@@ -2,8 +2,10 @@ package com.sckw.system.controller;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.model.KwsRole;
 import com.sckw.system.model.vo.req.EditRoleReqVo;
@@ -34,9 +36,8 @@ public class KwsRoleController {
      * @date 2023/5/30
      **/
     @GetMapping("/detail")
-    public HttpResult selectByKey(Long id) throws Exception {
-        KwsRole sysDict = kwsRoleService.selectByKey(id);
-        return HttpResult.ok(sysDict);
+    public HttpResult selectByKey(Long id) throws SystemException {
+        return HttpResult.ok(kwsRoleService.selectByKey(id));
     }
 
     /**
@@ -47,11 +48,11 @@ public class KwsRoleController {
      * @date 2023/5/30
      **/
     @PostMapping("/select")
-    public HttpResult select(@RequestBody HashMap params) throws Exception {
+    public HttpResult select(@RequestBody HashMap params) throws SystemException {
         // 设置分页参数
         PageHelper.startPage(PageResult.getPageNum(params), PageResult.getPageSize(params));
         List<KwsRole> list = kwsRoleService.findPage(params);
-        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo(list));
+        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));
         return HttpResult.ok(pageResult);
     }
 
@@ -63,9 +64,9 @@ public class KwsRoleController {
      * @date 2023/5/30
      **/
     @PostMapping("/add")
-    public HttpResult add(@RequestBody EditRoleReqVo reqVo) throws Exception {
+    public HttpResult add(@RequestBody EditRoleReqVo reqVo) throws SystemException {
         kwsRoleService.add(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_003);
     }
 
     /**
@@ -76,9 +77,9 @@ public class KwsRoleController {
      * @date 2023/5/30
      **/
     @PostMapping("/update")
-    public HttpResult update(@RequestBody EditRoleReqVo reqVo) throws Exception {
+    public HttpResult update(@RequestBody EditRoleReqVo reqVo) throws SystemException {
         kwsRoleService.update(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_005);
     }
 
     /**
@@ -89,9 +90,9 @@ public class KwsRoleController {
      * @date 2023/5/30
      **/
     @PostMapping("/dels")
-    public HttpResult del(@RequestParam String ids) throws Exception {
+    public HttpResult del(@RequestParam String ids) throws SystemException {
         kwsRoleService.deleteByKey(ids);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_008);
     }
 
     /**
@@ -102,8 +103,8 @@ public class KwsRoleController {
      * @date: 2023/6/13
      */
     @PostMapping("userBindRole")
-    public HttpResult userBindRole(@RequestBody UserBindRoleReqVo reqVo) throws Exception {
+    public HttpResult userBindRole(@RequestBody UserBindRoleReqVo reqVo) throws SystemException {
         kwsRoleService.userBindRole(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_010);
     }
 }

+ 13 - 50
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsUserController.java

@@ -2,14 +2,12 @@ package com.sckw.system.controller;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.model.KwsUser;
-import com.sckw.system.model.vo.req.CheckAccountValidReqVo;
-import com.sckw.system.model.vo.req.ForgetPasswordReqVo;
-import com.sckw.system.model.vo.req.UpdatePasswordReqVo;
 import com.sckw.system.model.vo.req.UserAddReqVo;
 import com.sckw.system.service.KwsUserService;
 import jakarta.validation.Valid;
@@ -37,7 +35,7 @@ public class KwsUserController {
      * @date 2023/5/30
      **/
     @GetMapping("/detail")
-    public HttpResult selectByKey(Long id) throws Exception {
+    public HttpResult selectByKey(Long id) throws SystemException {
         return HttpResult.ok(kwsUserService.selectByKey(id));
     }
 
@@ -48,7 +46,7 @@ public class KwsUserController {
      * @date 2023/5/30
      **/
     @PostMapping("/select")
-    public HttpResult findPage(@RequestBody HashMap params) throws Exception {
+    public HttpResult findPage(@RequestBody HashMap params) throws SystemException {
         // 设置分页参数
         PageHelper.startPage(PageResult.getPageNum(params), PageResult.getPageSize(params));
         List<KwsUser> list = kwsUserService.findPage(params);
@@ -63,7 +61,7 @@ public class KwsUserController {
      * @date 2023/5/30
      **/
     @PostMapping("/findList")
-    public HttpResult findList(@RequestBody KwsUser params) throws Exception {
+    public HttpResult findList(@RequestBody KwsUser params) throws SystemException {
         return HttpResult.ok(kwsUserService.findList(params));
     }
 
@@ -77,7 +75,7 @@ public class KwsUserController {
     @PostMapping("/add")
     public HttpResult add(@Valid @RequestBody UserAddReqVo reqVo) {
         kwsUserService.add(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_003);
     }
 
     /**
@@ -88,56 +86,21 @@ public class KwsUserController {
      * @date 2023/5/30
      **/
     @PostMapping("/update")
-    public HttpResult update(@RequestBody KwsUser params) throws Exception {
+    public HttpResult update(@RequestBody KwsUser params) throws SystemException {
         kwsUserService.update(params);
-        return HttpResult.ok();
-    }
-
-    /**
-     * @param id 主键ID
-     * @description 重置密码
-     * @author zk
-     * @date 2023/06/02
-     **/
-    @PostMapping("/resetPassword")
-    public HttpResult resetPassword(@RequestParam Long id) {
-        kwsUserService.resetPassword(id);
-        return HttpResult.ok(HttpStatus.MSG_001);
-    }
-
-    /**
-     * @param {password 旧密码、newPassword 新密码、account 账号}
-     * @description 修改密码
-     * @author zk
-     * @date 2023/06/02
-     **/
-    @PostMapping("/updatePassword")
-    public HttpResult updatePassword(@RequestBody UpdatePasswordReqVo reqVo) {
-        kwsUserService.updatePassword(reqVo);
-        return HttpResult.ok(HttpStatus.MSG_002);
-    }
-
-    /**
-     * @param  reqVo {account 账号、password 密码、captcha 验证码}
-     * @description 忘记密码
-     * @author zk
-     * @date 2023/06/02
-     **/
-    @PostMapping("/forgetPassword")
-    public HttpResult forgetPassword(@RequestBody ForgetPasswordReqVo reqVo) {
-        kwsUserService.forgetPassword(reqVo);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_005);
     }
 
     /**
-     * @param account 账号
+     * @param id
      * @description 注销账户
      * @author zk
      * @date 2023/06/02
      **/
     @GetMapping(value = "/closeAccount")
-    public HttpResult closeAccount(@RequestParam String account) {
-        return HttpResult.ok();
+    public HttpResult closeAccount(@RequestParam Long id) {
+        kwsUserService.closeAccount(id);
+        return HttpResult.ok(HttpStatus.MSG_008);
     }
 
     /**
@@ -147,9 +110,9 @@ public class KwsUserController {
      * @date 2023/5/30
      **/
     @PostMapping("/dels")
-    public HttpResult del(@RequestParam String ids) throws Exception {
+    public HttpResult del(@RequestParam String ids) throws SystemException {
         kwsUserService.deleteByKey(ids);
-        return HttpResult.ok();
+        return HttpResult.ok(HttpStatus.MSG_008);
     }
 
 

+ 11 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java

@@ -6,6 +6,7 @@ import com.sckw.core.utils.CollectionUtils;
 import com.sckw.system.api.RemoteUserService;
 import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
+import com.sckw.system.api.model.dto.req.UpdatePasswordReqDto;
 import com.sckw.system.api.model.dto.req.UserLoginReqDto;
 import com.sckw.system.api.model.dto.res.*;
 import com.sckw.system.dao.KwsUserLoginDao;
@@ -156,6 +157,16 @@ public class RemoteUserServiceImpl implements RemoteUserService {
         return BeanUtils.copyToList(kwsEntCheckTracks, EntCheckTrackResDto.class);
     }
 
+    @Override
+    public void updatePassword(UpdatePasswordReqDto updatePassword) {
+        kwsUserService.updatePassword(updatePassword);
+    }
+
+    @Override
+    public void resetPassword(Long id) {
+        kwsUserService.resetPassword(id);
+    }
+
     @Override
     public void register(RegisterReqDto reqDto) throws SystemException {
         kwsUserService.register(reqDto);

+ 2 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EditRoleReqVo.java

@@ -1,5 +1,6 @@
 package com.sckw.system.model.vo.req;
 
+import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
 
 import java.io.Serial;
@@ -26,6 +27,7 @@ public class EditRoleReqVo implements Serializable {
     /**
      * 当前单位id,可以是机构也可以是企业,目前产品设计是企业
      */
+    @NotBlank(message = "当前组织机构不能为空")
     private Long currentUnitId;
 
     /**

+ 1 - 4
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EntRegisterReqVo.java

@@ -22,6 +22,7 @@ public class EntRegisterReqVo implements Serializable {
     /**
      * 企业id
      */
+    @NotBlank(message = "企业不能为空")
     private Long entId;
 
     /**
@@ -29,10 +30,6 @@ public class EntRegisterReqVo implements Serializable {
      */
     private Long entPid;
 
-    /**
-     * 企业名称
-     */
-
     /**
      * 企业编号
      */

+ 18 - 15
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsDeptService.java

@@ -8,7 +8,6 @@ import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
-import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.system.dao.KwsDeptDao;
 import com.sckw.system.dao.KwsUserDeptDao;
 import com.sckw.system.model.KwsDept;
@@ -40,9 +39,10 @@ public class KwsDeptService {
     KwsUserDeptDao kwsUserDeptDao;
 
     /**
-     * 添加新纪录
-     * @param params
-     * @return
+     * @param params 新增入参
+     * @desc: 添加新纪录
+     * @author: czh
+     * @date: 2023/7/3
      */
     public void add(KwsDept params) {
         Long deptId = new IdWorker(1).nextId();
@@ -64,14 +64,16 @@ public class KwsDeptService {
     }
 
     /**
-     * 删除记录-根据主键
-     * @param ids
+     * @param ids 主键
+     * @desc: 删除记录-根据主键
+     * @author: czh
+     * @date: 2023/7/3
      */
-    public void deleteByKey(String ids) throws Exception {
+    public void deleteByKey(String ids) throws SystemException {
         List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         List<FindDeptUserPojo> findDeptUserPojoList = kwsDeptDao.findDeptUserByDeptIds(list);
         if (!CollectionUtils.isEmpty(findDeptUserPojoList)) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.USER_DEPT_NOT_EXISTS);
         }
         deleteDept(kwsDeptDao.selectByKeys(list));
     }
@@ -82,7 +84,7 @@ public class KwsDeptService {
      * @author: czh
      * @date: 2023/6/28
      */
-    public void deleteDept(List<KwsDept> kwsDepts) throws Exception {
+    public void deleteDept(List<KwsDept> kwsDepts) throws SystemException {
         if (CollectionUtils.isEmpty(kwsDepts)) {
             return;
         }
@@ -90,7 +92,7 @@ public class KwsDeptService {
         for (KwsDept kwsDept : kwsDepts) {
             kwsDept.setDelFlag(Global.YES);
             if (kwsDeptDao.update(kwsDept) <= 0) {
-                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
             }
         }
     }
@@ -101,9 +103,10 @@ public class KwsDeptService {
      * @return
      * @throws Exception
      */
-    public HttpResult update(KwsDept params) throws Exception {
-        int count = kwsDeptDao.update(params);
-        return count > 0 ? HttpResult.ok("更新成功!") : HttpResult.error();
+    public void update(KwsDept params) throws SystemException {
+        if(kwsDeptDao.update(params) <= 0){
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+        }
     }
 
     /**
@@ -112,7 +115,7 @@ public class KwsDeptService {
      * @return
      * @throws Exception
      */
-    public KwsDept selectByKey(Long key) throws Exception {
+    public KwsDept selectByKey(Long key) throws SystemException {
         return kwsDeptDao.selectByKey(key);
     }
 
@@ -122,7 +125,7 @@ public class KwsDeptService {
      * @return
      * @throws Exception
      */
-    public List<KwsDeptResVo> findTree(KwsDept params) throws Exception{
+    public List<KwsDeptResVo> findTree(KwsDept params) throws SystemException {
         //机构数据
         List<KwsDeptResVo> deptList = findList(params);
         //跟节点

+ 73 - 74
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -90,7 +90,8 @@ public class KwsEnterpriseService {
      * @author: czh
      * @date: 2023/6/19
      */
-    public void deleteByKey(String ids) throws Exception {
+    @Transactional(rollbackFor = {})
+    public void deleteByKey(String ids) throws SystemException {
         //校验,有员工还在企业下则不能删除
         List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         List<KwsEnterprise> kwsEnterprises = kwsEnterpriseDao.selectByKeys(list);
@@ -100,14 +101,14 @@ public class KwsEnterpriseService {
 
         List<FindEntUserPojo> findEntUserPojos = kwsEnterpriseDao.findUserByEntIds(list);
         if (!CollectionUtils.isEmpty(findEntUserPojos)) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_011);
         }
 
         /*1、删除企业*/
         for (KwsEnterprise kwsEnterprise : kwsEnterprises) {
             kwsEnterprise.setDelFlag(Global.YES);
             if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
-                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
             }
         }
 
@@ -134,76 +135,74 @@ public class KwsEnterpriseService {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
         }
 
-        /*2、更新企业类型*/
-        List<KwsEntType> kwsEntTypes = kwsEntTypeDao.findListByEntId(entId);
-        List<String> typeReqList = new ArrayList<>();
-        String entTypes = reqVo.getEntTypes();
-        if (StringUtils.isNotBlank(entTypes)) {
-            typeReqList = Arrays.stream(entTypes.split(",")).toList();
-        }
-
-        //若入参传来的type在表里面本来就有则不管,没有就新增
-        typeReqList.forEach(item -> {
-            if (CollectionUtils.isEmpty(kwsEntTypes) || kwsEntTypes.stream().anyMatch(x -> x.getType() == Integer.parseInt(item))) {
-                return;
-            }
-
-            KwsEntType kwsEntType = new KwsEntType();
-            kwsEntType.setEntId(entId);
-            kwsEntType.setType(Integer.parseInt(item));
-            if (kwsEntTypeDao.insert(kwsEntType) <= 0) {
-                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
-            }
-        });
-
-        //若表里的type没有在入参传来的type里则做逻辑删除,有就不管
-        if (CollectionUtils.isNotEmpty(kwsEntTypes)) {
-            List<String> finalTypeReqList = typeReqList;
-            kwsEntTypes.forEach(item -> {
-                if (finalTypeReqList.contains(String.valueOf(item.getType()))) {
-                    item.setDelFlag(Global.YES);
-                    if (kwsEntTypeDao.update(item) <= 0) {
-                        throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
-                    }
-                }
-            });
-        }
-
-        /*更新证书信息*/
-        //1、没有传则全部删除
-        List<BusinessLicense> certificates = reqVo.getCertificates();
-        if (CollectionUtils.isEmpty(certificates)) {
-            List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
-            if (!CollectionUtils.isEmpty(kwsEntCertificates)) {
-                kwsEntCertificates.forEach(item -> {
-                    item.setDelFlag(Global.YES);
-                    if (kwsEntCertificateDao.update(item) <= 0) {
-                        throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
-                    }
-                });
-            }
-            return;
-        }
-
-        certificates.forEach(item -> {
-            long id = item.getId();
-            if (Objects.isNull(id)) {
-                KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
-                kwsEntCertificate.setEntId(entId);
-                BeanUtils.copyProperties(item, kwsEntCertificate);
-                if (kwsEntCertificateDao.insert(kwsEntCertificate) <= 0) {
-                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
-                }
-                return;
-            }
-
-            KwsEntCertificate kwsEntCertificate = checkEntCertificate(id);
-            BeanUtils.copyProperties(item, kwsEntCertificate);
-            //不做更新条数校验
-            kwsEntCertificateDao.update(kwsEntCertificate);
-        });
-
-
+//        /*2、更新企业类型*/
+//        List<KwsEntType> kwsEntTypes = kwsEntTypeDao.findListByEntId(entId);
+//        List<String> typeReqList = new ArrayList<>();
+//        String entTypes = reqVo.getEntTypes();
+//        if (StringUtils.isNotBlank(entTypes)) {
+//            typeReqList = Arrays.stream(entTypes.split(",")).toList();
+//        }
+//
+//        //若入参传来的type在表里面本来就有则不管,没有就新增
+//        typeReqList.forEach(item -> {
+//            if (CollectionUtils.isEmpty(kwsEntTypes) || kwsEntTypes.stream().anyMatch(x -> x.getType() == Integer.parseInt(item))) {
+//                return;
+//            }
+//
+//            KwsEntType kwsEntType = new KwsEntType();
+//            kwsEntType.setEntId(entId);
+//            kwsEntType.setType(Integer.parseInt(item));
+//            if (kwsEntTypeDao.insert(kwsEntType) <= 0) {
+//                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+//            }
+//        });
+//
+//        //若表里的type没有在入参传来的type里则做逻辑删除,有就不管
+//        if (CollectionUtils.isNotEmpty(kwsEntTypes)) {
+//            List<String> finalTypeReqList = typeReqList;
+//            kwsEntTypes.forEach(item -> {
+//                if (finalTypeReqList.contains(String.valueOf(item.getType()))) {
+//                    item.setDelFlag(Global.YES);
+//                    if (kwsEntTypeDao.update(item) <= 0) {
+//                        throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+//                    }
+//                }
+//            });
+//        }
+//
+//        /*更新证书信息*/
+//        //1、没有传则全部删除
+//        List<BusinessLicense> certificates = reqVo.getCertificates();
+//        if (CollectionUtils.isEmpty(certificates)) {
+//            List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
+//            if (!CollectionUtils.isEmpty(kwsEntCertificates)) {
+//                kwsEntCertificates.forEach(item -> {
+//                    item.setDelFlag(Global.YES);
+//                    if (kwsEntCertificateDao.update(item) <= 0) {
+//                        throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+//                    }
+//                });
+//            }
+//            return;
+//        }
+//
+//        certificates.forEach(item -> {
+//            long id = item.getId();
+//            if (Objects.isNull(id)) {
+//                KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
+//                kwsEntCertificate.setEntId(entId);
+//                BeanUtils.copyProperties(item, kwsEntCertificate);
+//                if (kwsEntCertificateDao.insert(kwsEntCertificate) <= 0) {
+//                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+//                }
+//                return;
+//            }
+//
+//            KwsEntCertificate kwsEntCertificate = checkEntCertificate(id);
+//            BeanUtils.copyProperties(item, kwsEntCertificate);
+//            //不做更新条数校验
+//            kwsEntCertificateDao.update(kwsEntCertificate);
+//        });
     }
 
     public KwsEntCertificate checkEntCertificate(long id) throws SystemException {
@@ -234,7 +233,7 @@ public class KwsEnterpriseService {
      * @author: czh
      * @date: 2023/6/9
      */
-    public PageResult findPage(EntFindPageReqVo reqVo) throws Exception {
+    public PageResult findPage(EntFindPageReqVo reqVo) throws SystemException {
         PageHelper.startPage(reqVo.getPageNum(), reqVo.getPageSize());
         List<KwsEnterprise> list = findList(reqVo);
         return PageHelperUtil.getPageResult(new PageInfo<>(list));

+ 16 - 18
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java

@@ -4,6 +4,7 @@ import java.util.*;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Http;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.utils.BeanUtils;
@@ -54,7 +55,7 @@ public class KwsMenuService {
      * @throws Exception
      */
     @Transactional(rollbackFor = {})
-    public void add(KwsMenu params) throws Exception {
+    public void add(KwsMenu params) throws SystemException {
         Long parentId = params.getParentId();
         if (parentId.compareTo(0L) != 0) {
             KwsMenu kwsMenu = kwsMenuDao.selectByKey(parentId);
@@ -64,7 +65,7 @@ public class KwsMenuService {
         }
 
         //有重复的序号,则把后面的都加1
-        if(!Objects.isNull(params.getSort())){
+        if (!Objects.isNull(params.getSort())) {
             moveSort(params);
         }
 
@@ -111,7 +112,7 @@ public class KwsMenuService {
      * @author: czh
      * @date: 2023/6/25
      */
-    public void deleteByKey(String ids) throws Exception {
+    public void deleteByKey(String ids) throws SystemException {
         List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         /*1、删除菜单*/
         List<KwsMenu> kwsMenus = kwsMenuDao.selectByKeys(list);
@@ -136,7 +137,7 @@ public class KwsMenuService {
      * @author: czh
      * @date: 2023/6/25
      */
-    public void deleteMenuRightsByMenuIds(List<Long> menuIdList) throws Exception {
+    public void deleteMenuRightsByMenuIds(List<Long> menuIdList) throws SystemException {
         deleteMenuRights(kwsMenuRightsDao.selectByMenuIds(menuIdList));
     }
 
@@ -146,7 +147,7 @@ public class KwsMenuService {
      * @author: czh
      * @date: 2023/6/25
      */
-    public void deleteMenuRightsByRoleIds(List<Long> roleIdList) throws Exception {
+    public void deleteMenuRightsByRoleIds(List<Long> roleIdList) throws SystemException {
         deleteMenuRights(kwsMenuRightsDao.selectByRoleIds(roleIdList));
     }
 
@@ -165,18 +166,15 @@ public class KwsMenuService {
 
 
     /**
-     * 更新记录
-     *
-     * @param params
-     * @return
-     * @throws Exception
+     * @param params 更新记录
+     * @desc: 更新记录
+     * @author: czh
+     * @date: 2023/7/3
      */
-    public HttpResult update(KwsMenu params) throws Exception {
-        int count = kwsMenuDao.update(params);
-        /**1.对usingRoles值变更进行检测,如果变更需要更新已拥有该功能的企业/角色**/
-
-
-        return count > 0 ? HttpResult.ok("更新成功!") : HttpResult.error();
+    public void update(KwsMenu params) throws SystemException {
+        if (kwsMenuDao.update(params) <= 0) {
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+        }
     }
 
     /**
@@ -186,7 +184,7 @@ public class KwsMenuService {
      * @return
      * @throws Exception
      */
-    public KwsMenu selectByKey(Long key) throws Exception {
+    public KwsMenu selectByKey(Long key) throws SystemException {
         return kwsMenuDao.selectByKey(key);
     }
 
@@ -197,7 +195,7 @@ public class KwsMenuService {
      * @return
      * @throws Exception
      */
-    public List<KwsMenuResVo> findTree(FindMenuTreeReqVo reqVo) throws Exception {
+    public List<KwsMenuResVo> findTree(FindMenuTreeReqVo reqVo) throws SystemException {
         FindMenuTreePojo findMenuTreePojo = new FindMenuTreePojo();
         BeanUtils.copyProperties(reqVo, findMenuTreePojo);
 

+ 17 - 13
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java

@@ -1,4 +1,5 @@
 package com.sckw.system.service;
+
 import java.util.Date;
 
 import com.sckw.core.exception.SystemException;
@@ -26,6 +27,7 @@ import java.util.*;
 
 /**
  * 角色service接口
+ *
  * @author zk
  * @date 2023-05-31
  */
@@ -57,7 +59,7 @@ public class KwsRoleService {
     CustomConfig customConfig;
 
     /**
-     * @param  params KwsRole
+     * @param params KwsRole
      * @desc: 单表插入
      * @author: czh
      * @date: 2023/6/15
@@ -124,7 +126,7 @@ public class KwsRoleService {
             kwsAuthority.setDelFlag(Global.NO);
             kwsAuthorities.add(kwsAuthority);
         }
-        if(kwsAuthorityDao.saveBatch(kwsAuthorities) != kwsAuthorities.size() ) {
+        if (kwsAuthorityDao.saveBatch(kwsAuthorities) != kwsAuthorities.size()) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
 
@@ -137,7 +139,7 @@ public class KwsRoleService {
      * @author: czh
      * @date: 2023/6/25
      */
-    public void deleteByDeptIds(List<Long> unitIdList) throws Exception {
+    public void deleteByDeptIds(List<Long> unitIdList) throws SystemException {
         List<KwsRole> kwsRoles = kwsRoleDao.selectBatchByUnitIds(unitIdList);
         if (CollectionUtils.isEmpty(kwsRoles)) {
             return;
@@ -147,9 +149,10 @@ public class KwsRoleService {
 
     /**
      * 删除记录-根据主键
+     *
      * @param ids 主键
      */
-    public void deleteByKey(String ids) throws Exception {
+    public void deleteByKey(String ids) throws SystemException {
         List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         List<KwsRole> kwsRoles = kwsRoleDao.selectBatchByKeys(idList);
         if (CollectionUtils.isEmpty(kwsRoles)) {
@@ -167,7 +170,7 @@ public class KwsRoleService {
      * @date: 2023/6/28
      */
     @Transactional(rollbackFor = {})
-    public void deleteRole(List<KwsRole> kwsRoles) throws Exception {
+    public void deleteRole(List<KwsRole> kwsRoles) throws SystemException {
         /*1、删角色*/
         for (KwsRole kwsRole : kwsRoles) {
             kwsRole.setDelFlag(Global.YES);
@@ -204,7 +207,7 @@ public class KwsRoleService {
      * 更新记录
      */
     @Transactional(rollbackFor = {})
-    public void update(EditRoleReqVo reqVo) throws Exception {
+    public void update(EditRoleReqVo reqVo) throws SystemException {
 
         KwsRole kwsRole = kwsRoleDao.selectByKey(reqVo.getId());
         if (Objects.isNull(kwsRole)) {
@@ -220,6 +223,7 @@ public class KwsRoleService {
 
     /**
      * 根据主键查询
+     *
      * @param key 主键
      * @return KwsRole
      */
@@ -232,7 +236,7 @@ public class KwsRoleService {
      * @param params 分页入参
      * @return List
      */
-    public List<KwsRole> findPage(Map<String, Object> params) throws Exception{
+    public List<KwsRole> findPage(Map<String, Object> params) throws SystemException {
         return kwsRoleDao.findPage(params);
     }
 
@@ -248,14 +252,14 @@ public class KwsRoleService {
     }
 
     /**
-     * @param  reqVo 多个角色用","隔开
+     * @param reqVo 多个角色用","隔开
      * @desc: 用戶分配權限
      * @author: czh
      * @date: 2023/6/13
      */
     @Transactional(rollbackFor = Exception.class)
     public void userBindRole(UserBindRoleReqVo reqVo) {
-       //特殊校验,之前说用户和角色是一对多,后来产品改成一对一
+        //特殊校验,之前说用户和角色是一对多,后来产品改成一对一
         String[] roleIdArr = reqVo.getRoleIds().split(",");
         if (customConfig.getIsBindManyRole() == Global.NO && roleIdArr.length > 1) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_006);
@@ -285,7 +289,7 @@ public class KwsRoleService {
             kwsUserRolelist.add(kwsUserRole);
             roleIdList.add(Long.parseLong(roleId));
         }
-        if(kwsUserRoleDao.saveBatch(kwsUserRolelist) < kwsUserRolelist.size()){
+        if (kwsUserRoleDao.saveBatch(kwsUserRolelist) < kwsUserRolelist.size()) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
 
@@ -304,7 +308,7 @@ public class KwsRoleService {
                 menus.addAll(Arrays.asList(kwsMenuResVo.getLinks().split(",")));
             }
         }
-        RedissonUtils.putSet(Global.getFullUserMenuKey(reqVo.getSystemType() , userId), menus);
+        RedissonUtils.putSet(Global.getFullUserMenuKey(reqVo.getSystemType(), userId), menus);
         RedissonUtils.deleteBactch(Global.REDIS_USER_PREFIX + userId + "*");
 
     }
@@ -314,7 +318,7 @@ public class KwsRoleService {
         if (!CollectionUtils.isEmpty(currentUserRoleList)) {
             for (KwsUserRole kwsUserRole : currentUserRoleList) {
                 kwsUserRole.setDelFlag(Global.YES);
-                if(kwsUserRoleDao.update(kwsUserRole) <= 0){
+                if (kwsUserRoleDao.update(kwsUserRole) <= 0) {
                     throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
                 }
             }
@@ -323,7 +327,7 @@ public class KwsRoleService {
     }
 
 
-    public List<KwsUserRole> findAllByUserId (long userId) {
+    public List<KwsUserRole> findAllByUserId(long userId) {
         return kwsUserRoleDao.findAllByUserId(userId);
     }
 

+ 36 - 18
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -8,6 +8,7 @@ import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
+import com.sckw.system.api.model.dto.req.UpdatePasswordReqDto;
 import com.sckw.system.api.model.dto.res.RegisterResDto;
 import com.sckw.system.dao.KwsEntCheckTrackDao;
 import com.sckw.system.dao.KwsEnterpriseDao;
@@ -15,7 +16,6 @@ import com.sckw.system.dao.KwsUserDao;
 import com.sckw.system.dao.KwsUserDeptDao;
 import com.sckw.system.model.*;
 import com.sckw.system.model.vo.req.*;
-import com.sckw.system.model.vo.res.IdResVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -83,7 +83,7 @@ public class KwsUserService {
         entFindPageReqVo.setFirmName(reqDto.getEntName());
         List<KwsEnterprise> list = kwsEnterpriseDao.findList(entFindPageReqVo);
         if (!CollectionUtils.isEmpty(list)) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+            throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ENT_EXISTS);
         }
 
         /*1、数据校验*/
@@ -153,7 +153,7 @@ public class KwsUserService {
             EditRoleReqVo editRoleReqVo = new EditRoleReqVo();
             List<KwsMenu> kwsMenus = kwsMenuService.selectAll();
             if (CollectionUtils.isEmpty(kwsMenus)) {
-                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MENU_NOT_EXISTS);
             }
             editRoleReqVo.setName(Global.MANAGE_NAME);
             editRoleReqVo.setCurrentUnitId(entId);
@@ -190,25 +190,23 @@ public class KwsUserService {
     /**
      * 删除记录-根据主键
      */
-    public void deleteByKey(String ids) throws Exception {
+    @Transactional(rollbackFor = {})
+    public void deleteByKey(String ids) throws SystemException {
         /*1.数据校验*/
         if (StringUtils.isBlank(ids)) {
             throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_MISSING);
         }
 
-        int resultCode = 0;
         String[] idArray = ids.split(",");
         for (String id : idArray) {
             KwsUser kwsUser = kwsUserDao.selectByKey(Long.parseLong(id));
             if (null != kwsUser) {
                 kwsUser.setDelFlag(Global.YES);
-                resultCode += kwsUserDao.update(kwsUser);
+                if (kwsUserDao.update(kwsUser) <= 0) {
+                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
+                }
             }
         }
-
-        if (resultCode < idArray.length) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
-        }
     }
 
     /**
@@ -216,7 +214,7 @@ public class KwsUserService {
      *
      * @param params KwsUser
      */
-    public void update(KwsUser params) throws Exception {
+    public void update(KwsUser params) throws SystemException {
         //更换账号后账号唯一性校验
         if (StringUtils.isNotBlank(params.getAccount())) {
             //用户信息
@@ -232,8 +230,11 @@ public class KwsUserService {
     }
 
     /**
-     * 重置密码
-     */
+     * @param id 主键ID
+     * @desc 重置密码
+     * @author zk
+     * @date 2023/06/02
+     **/
     public void resetPassword(Long id) {
         //查用户信息
         KwsUser kwsUser = checkUserBase(id);
@@ -252,14 +253,14 @@ public class KwsUserService {
     /**
      * 分页查询
      */
-    public List<KwsUser> findPage(Map<String, Object> params) throws Exception {
+    public List<KwsUser> findPage(Map<String, Object> params) throws SystemException {
         return kwsUserDao.findPage(params);
     }
 
     /**
      * 查询
      */
-    public List<KwsUser> findList(KwsUser params) throws Exception {
+    public List<KwsUser> findList(KwsUser params) throws SystemException {
         return kwsUserDao.findList(params);
     }
 
@@ -275,9 +276,12 @@ public class KwsUserService {
     }
 
     /**
-     * 修改密码
+     * @param reqVo 修改密码入参
+     * @desc: 修改密码
+     * @author: czh
+     * @date: 2023/7/3
      */
-    public void updatePassword(UpdatePasswordReqVo reqVo) {
+    public void updatePassword(UpdatePasswordReqDto reqVo) {
         //查用户信息
         KwsUser kwsUser = checkUserBase(reqVo.getAccount(), reqVo.getSystemType());
 
@@ -311,7 +315,7 @@ public class KwsUserService {
         KwsUser kwsUser = checkUserBase(reqVo.getAccount(), reqVo.getSystemType());
 
         //从缓存中取出验证码,校验
-        String sms = RedissonUtils.get("captcha:czh").toString();
+        String sms = RedissonUtils.getString(Global.getForgetKey(reqVo.getSystemType(), reqVo.getAccount()));
         if (!reqVo.getCaptcha().equals(sms)) {
             throw new SystemException(HttpStatus.CODE_10301, HttpStatus.CAPTCHA_ERROR);
         }
@@ -389,4 +393,18 @@ public class KwsUserService {
         return kwsUserDao.selectByEntId(entId);
     }
 
+    /**
+     * @param id 用户id
+     * @desc: 注销
+     * @author: czh
+     * @date: 2023/7/3
+     */
+    public void closeAccount(Long id) {
+        KwsUser kwsUser = new KwsUser();
+        kwsUser.setId(id);
+        kwsUser.setDelFlag(Global.YES);
+        if (kwsUserDao.update(kwsUser) <= 0) {
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
+        }
+    }
 }