small 3 سال پیش
والد
کامیت
d41dd49e20
25فایلهای تغییر یافته به همراه275 افزوده شده و 118 حذف شده
  1. 2 1
      sckw-auth/src/main/java/com/sckw/auth/service/IAuthService.java
  2. 5 10
      sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java
  3. 1 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/PasswordUtils.java
  4. 14 4
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/utils/RedissonUtils.java
  5. 1 1
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteUserService.java
  6. 45 2
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/KwsEnterpriseResDto.java
  7. 29 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/RegisterResDto.java
  8. 2 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsDeptController.java
  9. 3 6
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java
  10. 1 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsRoleController.java
  11. 1 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsUserController.java
  12. 8 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEnterpriseDao.java
  13. 8 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsMenuDao.java
  14. 9 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsUserDao.java
  15. 2 4
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java
  16. 1 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/KwsEnterprise.java
  17. 8 16
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EntRegisterReqVo.java
  18. 2 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsDeptService.java
  19. 73 19
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java
  20. 4 12
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java
  21. 7 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java
  22. 33 35
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java
  23. 3 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml
  24. 3 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsMenuDao.xml
  25. 10 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsUserDao.xml

+ 2 - 1
sckw-auth/src/main/java/com/sckw/auth/service/IAuthService.java

@@ -5,6 +5,7 @@ import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
 import com.sckw.auth.model.vo.req.LoginReqVo;
 import com.sckw.auth.model.vo.req.LoginReqVo;
 import com.sckw.auth.model.vo.req.RegisterReqVo;
 import com.sckw.auth.model.vo.req.RegisterReqVo;
 import com.sckw.auth.model.vo.res.LoginResVo;
 import com.sckw.auth.model.vo.res.LoginResVo;
+import com.sckw.core.exception.SystemException;
 
 
 /**
 /**
  *
  *
@@ -16,7 +17,7 @@ public interface IAuthService {
      * @param reqVo
      * @param reqVo
      * @return
      * @return
      */
      */
-    LoginResVo login(LoginReqVo reqVo);
+    LoginResVo login(LoginReqVo reqVo) throws SystemException;
 
 
     /**
     /**
      * @param reqVo 注册入参
      * @param reqVo 注册入参

+ 5 - 10
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -29,10 +29,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 
 /**
 /**
  * @desc: 用户权限实现类
  * @desc: 用户权限实现类
@@ -48,7 +45,7 @@ public class AuthServiceImpl implements IAuthService {
 
 
 
 
     @Override
     @Override
-    public LoginResVo login(LoginReqVo reqDto) {
+    public LoginResVo login(LoginReqVo reqDto) throws SystemException {
         /*1、根据账号密码或者手机号校验码登录, 手机号后面处理*/
         /*1、根据账号密码或者手机号校验码登录, 手机号后面处理*/
         KwsUserResDto kwsUser = checkLogin(reqDto);
         KwsUserResDto kwsUser = checkLogin(reqDto);
         LoginResVo loginResVo = new LoginResVo();
         LoginResVo loginResVo = new LoginResVo();
@@ -76,10 +73,7 @@ public class AuthServiceImpl implements IAuthService {
             afterProcessor(loginResVo);
             afterProcessor(loginResVo);
             return loginResVo;
             return loginResVo;
         }
         }
-
-        List<DeptInfoResVo> deptInfo = new ArrayList<>(4);
-        BeanUtils.copyProperties(kwsDepts, deptInfo);
-        entInfoResVo.setDeptInfo(deptInfo);
+        entInfoResVo.setDeptInfo(BeanUtils.copyToList(kwsDepts, DeptInfoResVo.class));
 
 
         /*3、查企业*/
         /*3、查企业*/
         //目前一个人只能归属于一个企业,所以这里取第一个就行
         //目前一个人只能归属于一个企业,所以这里取第一个就行
@@ -97,7 +91,7 @@ public class AuthServiceImpl implements IAuthService {
         return loginResVo;
         return loginResVo;
     }
     }
 
 
-    private KwsUserResDto checkLogin(LoginReqVo reqDto) {
+    private KwsUserResDto checkLogin(LoginReqVo reqDto) throws SystemException {
         List<KwsUserResDto> kwsUsers = remoteUserService.checkUserBase(reqDto.getAccount(), reqDto.getSystemType());
         List<KwsUserResDto> kwsUsers = remoteUserService.checkUserBase(reqDto.getAccount(), reqDto.getSystemType());
         KwsUserResDto kwsUser = kwsUsers.get(0);
         KwsUserResDto kwsUser = kwsUsers.get(0);
         //密码校验、验证码
         //密码校验、验证码
@@ -175,6 +169,7 @@ public class AuthServiceImpl implements IAuthService {
             //存权限菜单
             //存权限菜单
             List<UserAccessMenuInfoResDto> userAccessMenuInfo = remoteUserService.queryUserAccessMenu(id);
             List<UserAccessMenuInfoResDto> userAccessMenuInfo = remoteUserService.queryUserAccessMenu(id);
             if (CollectionUtils.isEmpty(userAccessMenuInfo)) {
             if (CollectionUtils.isEmpty(userAccessMenuInfo)) {
+                RedissonUtils.delete(Global.REDIS_SYS_MENU_PREFIX + id);
                 log.error("未查询到用户{}的菜单权限", id);
                 log.error("未查询到用户{}的菜单权限", id);
                 return;
                 return;
             }
             }

+ 1 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/PasswordUtils.java

@@ -109,7 +109,7 @@ public class PasswordUtils {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
         String password = PasswordUtils.entryptPassword(PasswordUtils.md5("123"));
         String password = PasswordUtils.entryptPassword(PasswordUtils.md5("123"));
-        String md5 = PasswordUtils.md5("18901010101");
+        String md5 = PasswordUtils.md5("18482106067");
         System.out.println(password);
         System.out.println(password);
         System.out.println(md5);
         System.out.println(md5);
         System.out.println(validatePassword(md5, password));
         System.out.println(validatePassword(md5, password));

+ 14 - 4
sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/utils/RedissonUtils.java

@@ -7,10 +7,7 @@ import org.redisson.client.codec.StringCodec;
 import org.redisson.config.Config;
 import org.redisson.config.Config;
 
 
 import java.time.Duration;
 import java.time.Duration;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
 @Slf4j
 @Slf4j
@@ -65,6 +62,19 @@ public class RedissonUtils {
         bucket.delete();
         bucket.delete();
     }
     }
 
 
+    /**
+     * 批量删除
+     * @param key 用*模糊匹配
+     */
+    public static void deleteBactch(String key) {
+        Iterator<String> iterator = redissonUtils.redissonClient.getKeys().getKeysByPattern(key).iterator();
+        while(iterator.hasNext()) {
+            String word = iterator.next();
+            RBucket<Object> bucket = redissonUtils.redissonClient.getBucket(word);
+            bucket.delete();
+        }
+    }
+
     /**
     /**
      * 判断缓存是否存在
      * 判断缓存是否存在
      *
      *

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

@@ -49,7 +49,7 @@ public interface RemoteUserService {
      * @param password 入参传的密码
      * @param password 入参传的密码
      * @param currentPwd 当前用户的密码
      * @param currentPwd 当前用户的密码
      */
      */
-    void checkPassword(String password, String currentPwd);
+    void checkPassword(String password, String currentPwd) throws SystemException;
 
 
     /**
     /**
      * 检验用户信息
      * 检验用户信息

+ 45 - 2
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/KwsEnterpriseResDto.java

@@ -1,13 +1,56 @@
 package com.sckw.system.api.model.dto.res;
 package com.sckw.system.api.model.dto.res;
 
 
-import com.sckw.system.api.model.dto.BaseModelResDto;
 import lombok.Data;
 import lombok.Data;
 
 
+import java.io.Serial;
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
 
 
 @Data
 @Data
-public class KwsEnterpriseResDto extends BaseModelResDto implements Serializable {
+public class KwsEnterpriseResDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 584335442672847826L;
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态:0正常/1锁定
+     */
+    private Integer status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 删除标识(0正常/-1删除)
+     */
+    private Integer delFlag;
 
 
     /**
     /**
      * 企业编号
      * 企业编号

+ 29 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/RegisterResDto.java

@@ -0,0 +1,29 @@
+package com.sckw.system.api.model.dto.res;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 注册返参
+ * @date 2023/6/26
+ */
+@Data
+public class RegisterResDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 6339492007803393200L;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+}

+ 2 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsDeptController.java

@@ -76,9 +76,10 @@ public class KwsDeptController {
      * @author zk
      * @author zk
      * @date 2023/5/30
      * @date 2023/5/30
      **/
      **/
-    @DeleteMapping("/dels")
+    @PostMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws Exception {
     public HttpResult del(@RequestParam String ids) throws Exception {
         kwsDeptService.deleteByKey(ids);
         kwsDeptService.deleteByKey(ids);
         return HttpResult.ok();
         return HttpResult.ok();
     }
     }
+
 }
 }

+ 3 - 6
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -5,10 +5,7 @@ import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.model.KwsEntCheckTrack;
 import com.sckw.system.model.KwsEntCheckTrack;
 import com.sckw.system.model.KwsEnterprise;
 import com.sckw.system.model.KwsEnterprise;
-import com.sckw.system.model.vo.req.EntFindPageReqVo;
-import com.sckw.system.model.vo.req.EntRegisterReqVo;
-import com.sckw.system.model.vo.req.FreezeReqVo;
-import com.sckw.system.model.vo.req.KwsEnterpriseReqVo;
+import com.sckw.system.model.vo.req.*;
 import com.sckw.system.service.KwsEnterpriseService;
 import com.sckw.system.service.KwsEnterpriseService;
 import jakarta.validation.Valid;
 import jakarta.validation.Valid;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,7 +80,7 @@ public class KwsEnterpriseController {
      * @date: 2023/6/19
      * @date: 2023/6/19
      */
      */
     @PostMapping("/addEntSettle")
     @PostMapping("/addEntSettle")
-    public HttpResult addEntSettle(@RequestBody EntRegisterReqVo reqVo) throws SystemException {
+    public HttpResult addEntSettle(@Valid @RequestBody AddEntSettleReqVo reqVo) throws SystemException {
         kwsEntService.addEntSettle(reqVo);
         kwsEntService.addEntSettle(reqVo);
         return HttpResult.ok();
         return HttpResult.ok();
     }
     }
@@ -121,7 +118,7 @@ public class KwsEnterpriseController {
      * @author zk
      * @author zk
      * @date 2023/06/02
      * @date 2023/06/02
      **/
      **/
-    @DeleteMapping("/dels")
+    @PostMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws Exception {
     public HttpResult del(@RequestParam String ids) throws Exception {
         kwsEntService.deleteByKey(ids);
         kwsEntService.deleteByKey(ids);
         return HttpResult.ok();
         return HttpResult.ok();

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

@@ -87,7 +87,7 @@ public class KwsRoleController {
      * @author zk
      * @author zk
      * @date 2023/5/30
      * @date 2023/5/30
      **/
      **/
-    @DeleteMapping("/dels")
+    @PostMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws Exception {
     public HttpResult del(@RequestParam String ids) throws Exception {
         kwsRoleService.deleteByKey(ids);
         kwsRoleService.deleteByKey(ids);
         return HttpResult.ok();
         return HttpResult.ok();

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

@@ -146,7 +146,7 @@ public class KwsUserController {
      * @author zk
      * @author zk
      * @date 2023/5/30
      * @date 2023/5/30
      **/
      **/
-    @DeleteMapping("/dels")
+    @PostMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws Exception {
     public HttpResult del(@RequestParam String ids) throws Exception {
         kwsUserService.deleteByKey(ids);
         kwsUserService.deleteByKey(ids);
         return HttpResult.ok();
         return HttpResult.ok();

+ 8 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEnterpriseDao.java

@@ -68,4 +68,12 @@ public interface KwsEnterpriseDao {
      */
      */
     KwsEnterprise findByUserId(long id);
     KwsEnterprise findByUserId(long id);
 
 
+    /**
+     * @param kwsEnterprise 实体
+     * @return int
+     * @desc: 审批
+     * @author: czh
+     * @date: 2023/6/26
+     */
+    int approval(KwsEnterprise kwsEnterprise);
 }
 }

+ 8 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsMenuDao.java

@@ -16,6 +16,14 @@ import java.util.Map;
 @Mapper
 @Mapper
 public interface KwsMenuDao {
 public interface KwsMenuDao {
 
 
+    /**
+     * @desc: 全量查
+     * @author: czh
+     * @date: 2023/6/26
+     * @return
+     */
+    List<KwsMenu> selectAll();
+
     /**
     /**
      * 新增
      * 新增
      * @param record
      * @param record

+ 9 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsUserDao.java

@@ -64,4 +64,13 @@ public interface KwsUserDao {
      */
      */
     List<KwsDept> queryDeptByIds(List<Long> list);
     List<KwsDept> queryDeptByIds(List<Long> list);
 
 
+    /**
+     * @param entId 企业id
+     * @return KwsUser
+     * @desc: 根据企业id查用户
+     * @author: czh
+     * @date: 2023/6/26
+     */
+    List<KwsUser> selectByEntId(Long entId);
+
 }
 }

+ 2 - 4
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java

@@ -75,9 +75,7 @@ public class RemoteUserServiceImpl implements RemoteUserService {
             return Collections.emptyList();
             return Collections.emptyList();
         }
         }
 
 
-        List<KwsDeptResDto> list = new ArrayList<>(4);
-        BeanUtils.copyProperties(kwsDepts, list, false);
-        return list;
+        return BeanUtils.copyToList(kwsDepts, KwsDeptResDto.class);
     }
     }
 
 
     @Override
     @Override
@@ -105,7 +103,7 @@ public class RemoteUserServiceImpl implements RemoteUserService {
     public List<UserAccessMenuInfoResDto> queryUserAccessMenu(long id) {
     public List<UserAccessMenuInfoResDto> queryUserAccessMenu(long id) {
         FindMenuTreePojo findMenuTreePojo = new FindMenuTreePojo();
         FindMenuTreePojo findMenuTreePojo = new FindMenuTreePojo();
         List<KwsUserRole> kwsUserRoles = kwsRoleService.findAllByUserId(id);
         List<KwsUserRole> kwsUserRoles = kwsRoleService.findAllByUserId(id);
-        if (Objects.isNull(kwsUserRoles)) {
+        if (CollectionUtils.isEmpty(kwsUserRoles)) {
             return Collections.emptyList();
             return Collections.emptyList();
         }
         }
         findMenuTreePojo.setRoleIds(kwsUserRoles.stream().map(KwsUserRole::getRoleId).toList());
         findMenuTreePojo.setRoleIds(kwsUserRoles.stream().map(KwsUserRole::getRoleId).toList());

+ 1 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/KwsEnterprise.java

@@ -90,7 +90,7 @@ public class KwsEnterprise extends BaseModel {
     /**
     /**
      * 企业地址-----区域表id---实际用途?
      * 企业地址-----区域表id---实际用途?
      */
      */
-    private Integer cityName;
+    private String cityName;
 
 
     /**
     /**
      * 企业详细地址
      * 企业详细地址

+ 8 - 16
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EntRegisterReqVo.java

@@ -17,12 +17,11 @@ import java.util.List;
 public class EntRegisterReqVo implements Serializable {
 public class EntRegisterReqVo implements Serializable {
 
 
     @Serial
     @Serial
-    private static final long serialVersionUID = 2800416148876795046L;
+    private static final long serialVersionUID = -6222024827249219404L;
 
 
     /**
     /**
      * 企业id
      * 企业id
      */
      */
-    @NotNull(message = "企业不能为空")
     private Long entId;
     private Long entId;
 
 
     /**
     /**
@@ -33,8 +32,6 @@ public class EntRegisterReqVo implements Serializable {
     /**
     /**
      * 企业名称
      * 企业名称
      */
      */
-    @NotBlank(message = "企业名称不能为空")
-    private String firmName;
 
 
     /**
     /**
      * 企业编号
      * 企业编号
@@ -42,17 +39,6 @@ public class EntRegisterReqVo implements Serializable {
     @NotBlank(message = "企业编号不能为空")
     @NotBlank(message = "企业编号不能为空")
     private String code;
     private String code;
 
 
-    /**
-     * 企业联系人
-     */
-    @NotBlank(message = "企业联系人不能为空")
-    private String contacts;
-
-    /**
-     * 联系电话
-     */
-    private String telephone;
-
     /**
     /**
      * 法人姓名
      * 法人姓名
      */
      */
@@ -92,7 +78,13 @@ public class EntRegisterReqVo implements Serializable {
     /**
     /**
      * 企业地址
      * 企业地址
      */
      */
-    private String cityCode;
+    @NotNull(message = "企业地址编码不能为空")
+    private Integer cityCode;
+
+    /**
+     * 企业地址名
+     */
+    private String cityName;
 
 
     /**
     /**
      * 详细地址
      * 详细地址

+ 2 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsDeptService.java

@@ -8,6 +8,7 @@ import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.system.dao.KwsDeptDao;
 import com.sckw.system.dao.KwsDeptDao;
 import com.sckw.system.dao.KwsUserDeptDao;
 import com.sckw.system.dao.KwsUserDeptDao;
 import com.sckw.system.model.KwsDept;
 import com.sckw.system.model.KwsDept;
@@ -43,7 +44,6 @@ public class KwsDeptService {
      * @return
      * @return
      */
      */
     public void add(KwsDept params) {
     public void add(KwsDept params) {
-        params.setId(new IdWorker(1).nextId());
         if (StringUtils.isNotBlank(params.getParentId())) {
         if (StringUtils.isNotBlank(params.getParentId())) {
             KwsDept kwsDept = kwsDeptDao.selectByKey(params.getParentId());
             KwsDept kwsDept = kwsDeptDao.selectByKey(params.getParentId());
             if (kwsDept != null) {
             if (kwsDept != null) {
@@ -186,4 +186,5 @@ public class KwsDeptService {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
     }
     }
+
 }
 }

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

@@ -20,10 +20,14 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
+import com.sckw.system.api.model.dto.res.RegisterResDto;
 import com.sckw.system.dao.*;
 import com.sckw.system.dao.*;
 import com.sckw.system.model.*;
 import com.sckw.system.model.*;
+import com.sckw.system.model.pojo.FindMenuTreePojo;
 import com.sckw.system.model.vo.req.*;
 import com.sckw.system.model.vo.req.*;
 import com.sckw.system.model.vo.res.CertificateResVo;
 import com.sckw.system.model.vo.res.CertificateResVo;
+import com.sckw.system.model.vo.res.IdResVo;
+import com.sckw.system.model.vo.res.KwsMenuResVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -61,13 +65,19 @@ public class KwsEnterpriseService {
     @Autowired
     @Autowired
     private KwsDeptService kwsDeptService;
     private KwsDeptService kwsDeptService;
 
 
+    @Autowired
+    private KwsMenuService kwsMenuService;
+
+    @Autowired
+    private KwsRoleService kwsRoleService;
+
     /**
     /**
      * @param params 入库
      * @param params 入库
      * @desc: 单表入库
      * @desc: 单表入库
      * @author: czh
      * @author: czh
      * @date: 2023/6/19
      * @date: 2023/6/19
      */
      */
-    public void add(KwsEnterprise params) {
+    public void add(KwsEnterprise params) throws SystemException {
         if (kwsEnterpriseDao.insert(params) <= 0) {
         if (kwsEnterpriseDao.insert(params) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
@@ -106,7 +116,7 @@ public class KwsEnterpriseService {
      * @date: 2023/6/19
      * @date: 2023/6/19
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
-    public void update(KwsEnterpriseReqVo reqVo) throws Exception {
+    public void update(KwsEnterpriseReqVo reqVo) throws SystemException {
         /*1、更新企业信息表*/
         /*1、更新企业信息表*/
         long entId = reqVo.getId();
         long entId = reqVo.getId();
         KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(entId);
         KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(entId);
@@ -187,7 +197,7 @@ public class KwsEnterpriseService {
 
 
     }
     }
 
 
-    public KwsEntCertificate checkEntCertificate(long id) {
+    public KwsEntCertificate checkEntCertificate(long id) throws SystemException {
         KwsEntCertificate kwsEntCertificate = kwsEntCertificateDao.selectByKey(id);
         KwsEntCertificate kwsEntCertificate = kwsEntCertificateDao.selectByKey(id);
         if (Objects.isNull(kwsEntCertificate) || kwsEntCertificate.getDelFlag() == Global.YES) {
         if (Objects.isNull(kwsEntCertificate) || kwsEntCertificate.getDelFlag() == Global.YES) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
@@ -237,7 +247,7 @@ public class KwsEnterpriseService {
      * 新增企业(注册)
      * 新增企业(注册)
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
-    public void register(EntRegisterReqVo reqVo) {
+    public void register(EntRegisterReqVo reqVo) throws SystemException {
         /*1、存企业信息表*/
         /*1、存企业信息表*/
         KwsEnterprise kwsEnterprise = kwsEnterpriseDao.selectByKey(reqVo.getEntId());
         KwsEnterprise kwsEnterprise = kwsEnterpriseDao.selectByKey(reqVo.getEntId());
         if (Objects.isNull(kwsEnterprise)) {
         if (Objects.isNull(kwsEnterprise)) {
@@ -247,15 +257,25 @@ public class KwsEnterpriseService {
         Long entId = kwsEnterprise.getId();
         Long entId = kwsEnterprise.getId();
         Date date = new Date();
         Date date = new Date();
         Long userId = LoginUserHolder.getUserId();
         Long userId = LoginUserHolder.getUserId();
-        BeanUtils.copyProperties(reqVo, kwsEnterprise);
+        kwsEnterprise.setCode(reqVo.getCode());
+        kwsEnterprise.setLegalName(reqVo.getLegalName());
+        kwsEnterprise.setLegalTelephone(reqVo.getLegalTelephone());
+        kwsEnterprise.setHead(reqVo.getHead());
+        kwsEnterprise.setRegSource(LoginUserHolder.getClientType());
+        kwsEnterprise.setCityCode(reqVo.getCityCode());
+        kwsEnterprise.setCityName(reqVo.getCityName());
+        kwsEnterprise.setDetailAddress(reqVo.getDetailAddress());
+        kwsEnterprise.setLat(reqVo.getLat());
+        kwsEnterprise.setLng(reqVo.getLng());
 
 
         //一些待确认的字段
         //一些待确认的字段
         kwsEnterprise.setIntegral(0);
         kwsEnterprise.setIntegral(0);
         kwsEnterprise.setBalance(0L);
         kwsEnterprise.setBalance(0L);
         kwsEnterprise.setExperience(0);
         kwsEnterprise.setExperience(0);
         kwsEnterprise.setMemberLevel(0);
         kwsEnterprise.setMemberLevel(0);
+        kwsEnterprise.setOrgCode("");
         kwsEnterprise.setRegTime(date);
         kwsEnterprise.setRegTime(date);
-        kwsEnterprise.setApproval(ApprovalEnum.NO.getCode());
+        kwsEnterprise.setApproval(ApprovalEnum.PROCESS.getCode());
         if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
         if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
         }
         }
@@ -281,20 +301,20 @@ public class KwsEnterpriseService {
 
 
         /*3、存企业证书*/
         /*3、存企业证书*/
         List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
         List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
-        reqVo.getBusinessLicense().forEach(item -> {
+        for (BusinessLicense businessLicense : reqVo.getBusinessLicense()) {
             KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
             KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
             //todo 上传证书正反面,将url放到两个入参里
             //todo 上传证书正反面,将url放到两个入参里
             kwsEntCertificate.setEntId(entId);
             kwsEntCertificate.setEntId(entId);
-            kwsEntCertificate.setId(new IdWorker(1).nextId());
             kwsEntCertificate.setStatus(Global.NO);
             kwsEntCertificate.setStatus(Global.NO);
             kwsEntCertificate.setCreateBy(userId);
             kwsEntCertificate.setCreateBy(userId);
             kwsEntCertificate.setCreateTime(date);
             kwsEntCertificate.setCreateTime(date);
             kwsEntCertificate.setUpdateBy(userId);
             kwsEntCertificate.setUpdateBy(userId);
             kwsEntCertificate.setUpdateTime(date);
             kwsEntCertificate.setUpdateTime(date);
             kwsEntCertificate.setDelFlag(Global.NO);
             kwsEntCertificate.setDelFlag(Global.NO);
-            BeanUtils.copyProperties(item, kwsEntCertificate);
+            BeanUtils.copyProperties(businessLicense, kwsEntCertificate);
+            kwsEntCertificate.setId(new IdWorker(1).nextId());
             kwsEntCertificates.add(kwsEntCertificate);
             kwsEntCertificates.add(kwsEntCertificate);
-        });
+        }
         if (kwsEntCertificateDao.saveBatch(kwsEntCertificates) != kwsEntCertificates.size()) {
         if (kwsEntCertificateDao.saveBatch(kwsEntCertificates) != kwsEntCertificates.size()) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
@@ -316,11 +336,12 @@ public class KwsEnterpriseService {
      * 企业审批
      * 企业审批
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
-    public void approval(KwsEntCheckTrack kwsEntCheckTrack) {
+    public void approval(KwsEntCheckTrack kwsEntCheckTrack) throws SystemException {
         /*更新企业信息主表审批状态*/
         /*更新企业信息主表审批状态*/
-        KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(kwsEntCheckTrack.getEntId());
+        Long entId = kwsEntCheckTrack.getEntId();
+        KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(entId);
         kwsEnterprise.setApproval(kwsEntCheckTrack.getStatus());
         kwsEnterprise.setApproval(kwsEntCheckTrack.getStatus());
-        if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
+        if (kwsEnterpriseDao.approval(kwsEnterprise) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
         }
         }
 
 
@@ -328,9 +349,39 @@ public class KwsEnterpriseService {
         if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
         if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
+
+        /*审批通过,构建管理员角色及权限*/
+        /*1、新增管理员机构*/
+        KwsDept kwsDept = new KwsDept();
+        long deptId = new IdWorker(1L).nextId();
+        kwsDept.setEntId(entId);
+        kwsDept.setName(Global.MANAGE_NAME);
+        kwsDept.setSystemType(SystemTypeEnum.COMPANY.getCode());
+        kwsDept.setCompany(Global.NO);
+        kwsDept.setId(deptId);
+        kwsDeptService.add(kwsDept);
+
+        /*2、新增管理员角色*/
+        AddRoleReqVo addRoleReqVo = new AddRoleReqVo();
+        List<KwsMenu> list = kwsMenuService.selectAll();
+        if (CollectionUtils.isEmpty(list)) {
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+        }
+        addRoleReqVo.setName(Global.MANAGE_NAME);
+        addRoleReqVo.setCurrentDeptId(deptId);
+        addRoleReqVo.setMenuIds(String.join(",", list.stream().map(KwsMenu::getId).map(String::valueOf).toList()));
+        addRoleReqVo.setVisiblePersonal(false);
+        IdResVo idResVo = kwsRoleService.add(addRoleReqVo);
+
+        /*3、绑定角色等*/
+        KwsUser userByAccount = kwsUserService.getUserByAccount(kwsEnterprise.getTelephone(), SystemTypeEnum.COMPANY.getCode());
+        if (Objects.isNull(userByAccount)) {
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+        }
+        kwsUserService.fillUserRole(String.valueOf(idResVo.getId()),userByAccount.getId());
     }
     }
 
 
-    private KwsEnterprise checkKwsEnterpriseById(long id) {
+    private KwsEnterprise checkKwsEnterpriseById(long id) throws SystemException {
         KwsEnterprise kwsEnterprise = queryKwsEnterpriseById(id);
         KwsEnterprise kwsEnterprise = queryKwsEnterpriseById(id);
         if (Objects.isNull(kwsEnterprise) || kwsEnterprise.getDelFlag() == Global.YES) {
         if (Objects.isNull(kwsEnterprise) || kwsEnterprise.getDelFlag() == Global.YES) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
@@ -345,7 +396,7 @@ public class KwsEnterpriseService {
     /**
     /**
      * 企业冻结/解冻
      * 企业冻结/解冻
      */
      */
-    public void freeze(FreezeReqVo reqVo) {
+    public void freeze(FreezeReqVo reqVo) throws SystemException {
         KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(reqVo.getId());
         KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(reqVo.getId());
         kwsEnterprise.setStatus(reqVo.getStatus());
         kwsEnterprise.setStatus(reqVo.getStatus());
         if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
         if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
@@ -356,7 +407,7 @@ public class KwsEnterpriseService {
     /**
     /**
      * 企业证件信息
      * 企业证件信息
      */
      */
-    public List<CertificateResVo> certificate(Long id) {
+    public List<CertificateResVo> certificate(Long id) throws SystemException {
         /*查企业资质*/
         /*查企业资质*/
         List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(id);
         List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(id);
         if (CollectionUtils.isEmpty(kwsEntCertificates)) {
         if (CollectionUtils.isEmpty(kwsEntCertificates)) {
@@ -391,7 +442,7 @@ public class KwsEnterpriseService {
      * @author: czh
      * @author: czh
      * @date: 2023/6/19
      * @date: 2023/6/19
      */
      */
-    public void addEntSettle(EntRegisterReqVo reqVo) {
+    public void addEntSettle(AddEntSettleReqVo reqVo) throws SystemException {
         /*1、存用户信息*/
         /*1、存用户信息*/
         RegisterReqDto registerReqDto = new RegisterReqDto();
         RegisterReqDto registerReqDto = new RegisterReqDto();
         registerReqDto.setEntName(reqVo.getFirmName());
         registerReqDto.setEntName(reqVo.getFirmName());
@@ -399,10 +450,13 @@ public class KwsEnterpriseService {
         registerReqDto.setTelephone(reqVo.getTelephone());
         registerReqDto.setTelephone(reqVo.getTelephone());
         registerReqDto.setIsMain(Global.YES);
         registerReqDto.setIsMain(Global.YES);
         registerReqDto.setSystemType(SystemTypeEnum.COMPANY.getCode());
         registerReqDto.setSystemType(SystemTypeEnum.COMPANY.getCode());
-        kwsUserService.register(registerReqDto);
+        RegisterResDto register = kwsUserService.register(registerReqDto);
 
 
         /*2、认证*/
         /*2、认证*/
-        register(reqVo);
+        EntRegisterReqVo entRegisterReqVo = new EntRegisterReqVo();
+        BeanUtils.copyProperties(reqVo, entRegisterReqVo);
+        entRegisterReqVo.setEntId(register.getEntId());
+        register(entRegisterReqVo);
     }
     }
 
 
     public List<KwsEntCheckTrack> entCheck(Long entId) {
     public List<KwsEntCheckTrack> entCheck(Long entId) {

+ 4 - 12
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java

@@ -123,18 +123,6 @@ public class KwsMenuService {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
             }
             }
         }
         }
-
-        //让涉及到的用户重新登录获取菜单权限
-        List<Long> roleIds = kwsMenuRightsList.stream().map(KwsMenuRights::getRoleId).toList();
-        List<KwsUserRole> kwsUserRoleList = kwsUserRoleDao.findAllByRoleIds(roleIds);
-        if (CollectionUtils.isEmpty(kwsUserRoleList)) {
-            return;
-        }
-
-        for (KwsUserRole kwsUserRole : kwsUserRoleList) {
-            Long userId = kwsUserRole.getUserId();
-            RedissonUtils.delete(Global.REDIS_USER_PREFIX + userId + "*");
-        }
     }
     }
 
 
 
 
@@ -275,4 +263,8 @@ public class KwsMenuService {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
     }
     }
+
+    public List<KwsMenu> selectAll(){
+        return kwsMenuDao.selectAll();
+    }
 }
 }

+ 7 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java

@@ -158,7 +158,6 @@ public class KwsRoleService {
      * @param ids 主键
      * @param ids 主键
      */
      */
     public void deleteByKey(String ids) throws Exception {
     public void deleteByKey(String ids) throws Exception {
-
         List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         List<KwsRole> kwsRoles = kwsRoleDao.selectBatchByKeys(idList);
         List<KwsRole> kwsRoles = kwsRoleDao.selectBatchByKeys(idList);
         if (CollectionUtils.isEmpty(kwsRoles)) {
         if (CollectionUtils.isEmpty(kwsRoles)) {
@@ -193,6 +192,12 @@ public class KwsRoleService {
 
 
         /*4、删除角色菜单关系*/
         /*4、删除角色菜单关系*/
         kwsMenuService.deleteMenuRightsByRoleIds(idList);
         kwsMenuService.deleteMenuRightsByRoleIds(idList);
+
+        //让涉及到的用户重新登录获取菜单权限
+        for (KwsUserRole kwsUserRole : kwsUserRoleList) {
+            Long userId = kwsUserRole.getUserId();
+            RedissonUtils.deleteBactch(Global.REDIS_USER_PREFIX + userId + "*");
+        }
     }
     }
 
 
     /**
     /**
@@ -313,7 +318,7 @@ public class KwsRoleService {
             }
             }
         }
         }
         RedissonUtils.putSet(Global.REDIS_SYS_MENU_PREFIX + userId, menus);
         RedissonUtils.putSet(Global.REDIS_SYS_MENU_PREFIX + userId, menus);
-        RedissonUtils.delete(Global.REDIS_USER_PREFIX + userId + "*");
+        RedissonUtils.deleteBactch(Global.REDIS_USER_PREFIX + userId + "*");
 
 
     }
     }
 
 

+ 33 - 35
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -1,4 +1,5 @@
 package com.sckw.system.service;
 package com.sckw.system.service;
+
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.ApprovalEnum;
 import com.sckw.core.model.enums.ApprovalEnum;
@@ -7,6 +8,7 @@ import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
+import com.sckw.system.api.model.dto.res.RegisterResDto;
 import com.sckw.system.dao.KwsEntCheckTrackDao;
 import com.sckw.system.dao.KwsEntCheckTrackDao;
 import com.sckw.system.dao.KwsEnterpriseDao;
 import com.sckw.system.dao.KwsEnterpriseDao;
 import com.sckw.system.dao.KwsUserDao;
 import com.sckw.system.dao.KwsUserDao;
@@ -28,6 +30,7 @@ import java.util.*;
 
 
 /**
 /**
  * 用户service接口
  * 用户service接口
+ *
  * @author zk
  * @author zk
  * @date 2023-05-31
  * @date 2023-05-31
  */
  */
@@ -71,7 +74,7 @@ public class KwsUserService {
         long userId = new IdWorker(1).nextId();
         long userId = new IdWorker(1).nextId();
         kwsUser.setId(userId);
         kwsUser.setId(userId);
         if (kwsUserDao.insert(kwsUser) <= 0) {
         if (kwsUserDao.insert(kwsUser) <= 0) {
-           throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
 
 
         /*4、填充用户角色、用户机构关系*/
         /*4、填充用户角色、用户机构关系*/
@@ -80,10 +83,12 @@ public class KwsUserService {
     }
     }
 
 
     @Transactional(rollbackFor = {})
     @Transactional(rollbackFor = {})
-    public void register(RegisterReqDto reqDto) throws SystemException {
+    public RegisterResDto register(RegisterReqDto reqDto) throws SystemException {
         /*存用户表、企业表,暂时不处理角色关系,需要认证*/
         /*存用户表、企业表,暂时不处理角色关系,需要认证*/
         KwsUser kwsUser = new KwsUser();
         KwsUser kwsUser = new KwsUser();
+        RegisterResDto registerResDto = new RegisterResDto();
         long userId = new IdWorker(1).nextId();
         long userId = new IdWorker(1).nextId();
+        registerResDto.setUserId(userId);
         kwsUser.setSystemType(reqDto.getSystemType());
         kwsUser.setSystemType(reqDto.getSystemType());
         kwsUser.setAccount(reqDto.getTelephone());
         kwsUser.setAccount(reqDto.getTelephone());
         kwsUser.setPassword(reqDto.getPassword());
         kwsUser.setPassword(reqDto.getPassword());
@@ -98,9 +103,10 @@ public class KwsUserService {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
 
 
+
         /*存企业机构等*/
         /*存企业机构等*/
         //目前注册接口只有企业管理员进来
         //目前注册接口只有企业管理员进来
-        if(reqDto.getIsMain() == Global.YES && reqDto.getSystemType() != SystemTypeEnum.MANAGE.getCode()) {
+        if (reqDto.getIsMain() == Global.YES && reqDto.getSystemType() != SystemTypeEnum.MANAGE.getCode()) {
             KwsEnterprise kwsEnterprise = new KwsEnterprise();
             KwsEnterprise kwsEnterprise = new KwsEnterprise();
             long entId = new IdWorker(1L).nextId();
             long entId = new IdWorker(1L).nextId();
             kwsEnterprise.setId(entId);
             kwsEnterprise.setId(entId);
@@ -109,38 +115,16 @@ public class KwsUserService {
             kwsEnterprise.setApproval(ApprovalEnum.NO.getCode());
             kwsEnterprise.setApproval(ApprovalEnum.NO.getCode());
             kwsEnterprise.setContacts(reqDto.getName());
             kwsEnterprise.setContacts(reqDto.getName());
             kwsEnterprise.setTelephone(reqDto.getTelephone());
             kwsEnterprise.setTelephone(reqDto.getTelephone());
+            registerResDto.setEntId(entId);
             if (kwsEnterpriseDao.insert(kwsEnterprise) <= 0) {
             if (kwsEnterpriseDao.insert(kwsEnterprise) <= 0) {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             }
             }
-
-            /*4、新增管理员机构*/
-            KwsDept kwsDept = new KwsDept();
-            long deptId = new IdWorker(1L).nextId();
-            kwsDept.setEntId(entId);
-            kwsDept.setName(SystemTypeEnum.MANAGE.getName());
-            kwsDept.setSystemType(SystemTypeEnum.MANAGE.getCode());
-            kwsDept.setCompany(Global.NO);
-            kwsDeptService.add(kwsDept);
-
-            /*5、新增管理员角色*/
-            AddRoleReqVo addRoleReqVo = new AddRoleReqVo();
-            List<KwsMenuResVo> list = kwsMenuService.findList(new FindMenuTreePojo());
-            if (CollectionUtils.isEmpty(list)) {
-                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
-            }
-            addRoleReqVo.setName(Global.MANAGE_NAME);
-            addRoleReqVo.setCurrentDeptId(deptId);
-            addRoleReqVo.setMenuIds(String.join(",", list.stream().map(KwsMenuResVo::getId).map(String::valueOf).toList()));
-            addRoleReqVo.setVisiblePersonal(false);
-            IdResVo idResVo = kwsRoleService.add(addRoleReqVo);
-
-            /*6、绑定角色等*/
-            fillUserRole(String.valueOf(idResVo.getId()), userId);
         }
         }
+        return registerResDto;
     }
     }
 
 
 
 
-    private void fillUserRole(String roleIds, long userId) {
+    public void fillUserRole(String roleIds, long userId) {
         UserBindRoleReqVo userBindRoleReqVo = new UserBindRoleReqVo();
         UserBindRoleReqVo userBindRoleReqVo = new UserBindRoleReqVo();
         userBindRoleReqVo.setUserId(userId);
         userBindRoleReqVo.setUserId(userId);
         userBindRoleReqVo.setRoleIds(roleIds);
         userBindRoleReqVo.setRoleIds(roleIds);
@@ -184,6 +168,7 @@ public class KwsUserService {
 
 
     /**
     /**
      * 更新记录
      * 更新记录
+     *
      * @param params KwsUser
      * @param params KwsUser
      */
      */
     public void update(KwsUser params) throws Exception {
     public void update(KwsUser params) throws Exception {
@@ -222,14 +207,14 @@ public class KwsUserService {
     /**
     /**
      * 分页查询
      * 分页查询
      */
      */
-    public List<KwsUser> findPage(Map<String, Object> params) throws Exception{
+    public List<KwsUser> findPage(Map<String, Object> params) throws Exception {
         return kwsUserDao.findPage(params);
         return kwsUserDao.findPage(params);
     }
     }
 
 
     /**
     /**
      * 查询
      * 查询
      */
      */
-    public List<KwsUser> findList(KwsUser params) throws Exception{
+    public List<KwsUser> findList(KwsUser params) throws Exception {
         return kwsUserDao.findList(params);
         return kwsUserDao.findList(params);
     }
     }
 
 
@@ -268,7 +253,7 @@ public class KwsUserService {
 
 
     private void updatePwd(String newPassword, KwsUser kwsUser) throws SystemException {
     private void updatePwd(String newPassword, KwsUser kwsUser) throws SystemException {
         kwsUser.setPassword(PasswordUtils.entryptPassword(newPassword));
         kwsUser.setPassword(PasswordUtils.entryptPassword(newPassword));
-        if(kwsUserDao.update(kwsUser) <= 0) {
+        if (kwsUserDao.update(kwsUser) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
         }
         }
     }
     }
@@ -318,16 +303,17 @@ public class KwsUserService {
 
 
     /**
     /**
      * 校验密码
      * 校验密码
-     * @param password 入参传的密码
+     *
+     * @param password   入参传的密码
      * @param currentPwd 当前用户的密码
      * @param currentPwd 当前用户的密码
      */
      */
-    public void checkPassword(String password, String currentPwd) throws SystemException{
+    public void checkPassword(String password, String currentPwd) throws SystemException {
         if (!PasswordUtils.validatePassword(password, currentPwd)) {
         if (!PasswordUtils.validatePassword(password, currentPwd)) {
             throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PASSWD_ERROR);
             throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PASSWD_ERROR);
         }
         }
     }
     }
 
 
-    public List<KwsUserDept> queryUserDeptByUserId (Long userId) {
+    public List<KwsUserDept> queryUserDeptByUserId(Long userId) {
         return kwsUserDao.queryUserDeptByUserId(userId);
         return kwsUserDao.queryUserDeptByUserId(userId);
     }
     }
 
 
@@ -337,7 +323,7 @@ public class KwsUserService {
 
 
     /**
     /**
      * @param account 账号 systemType系统类型
      * @param account 账号 systemType系统类型
-     * @desc: 校验账号有效性,存在抛异常用户账号已存在
+     * @desc: 校验账号有效性, 存在抛异常用户账号已存在
      * @author: czh
      * @author: czh
      * @date: 2023/6/16
      * @date: 2023/6/16
      */
      */
@@ -346,4 +332,16 @@ public class KwsUserService {
             throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_EXISTS);
             throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_EXISTS);
         }
         }
     }
     }
+
+    /**
+     * @param entId 企业id
+     * @return KwsUser
+     * @desc: 根据企业id查用户
+     * @author: czh
+     * @date: 2023/6/26
+     */
+    public List<KwsUser> selectByEntId(Long entId) {
+        return kwsUserDao.selectByEntId(entId);
+    }
+
 }
 }

+ 3 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -371,5 +371,8 @@
     </set>
     </set>
     where id = #{id,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>
   </update>
+  <update id="approval">
+    update kws_enterprise set approval = #{approval} where id = #{id,jdbcType=BIGINT} and approval = 3 and del_flag = 0
+  </update>
 
 
 </mapper>
 </mapper>

+ 3 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsMenuDao.xml

@@ -298,4 +298,7 @@
       #{item}
       #{item}
     </foreach>
     </foreach>
   </select>
   </select>
+  <select id="selectAll" resultType="com.sckw.system.model.KwsMenu">
+    select * from kws_menu where del_flag = 0
+  </select>
 </mapper>
 </mapper>

+ 10 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsUserDao.xml

@@ -272,5 +272,15 @@
         #{item}
         #{item}
      </foreach>
      </foreach>
   </select>
   </select>
+  <select id="selectByEntId" resultType="com.sckw.system.model.KwsUser">
+    select distinct c.*
+      from kws_dept a
+      left join kws_user_dept b on a.id = b.dept_id
+      left join kws_user c on b.user_id = c.id
+     where a.ent_id = #{entId}
+       and a.del_flag = 0
+       and b.del_flag = 0
+       and c.del_flag = 0
+  </select>
 
 
 </mapper>
 </mapper>