PC 2 anni fa
parent
commit
7ac9d762f4
33 ha cambiato i file con 1202 aggiunte e 174 eliminazioni
  1. 26 16
      sckw-auth/src/main/java/com/sckw/auth/controller/AuthController.java
  2. 20 0
      sckw-auth/src/main/java/com/sckw/auth/model/vo/req/AddEntSettleReqDto.java
  3. 55 0
      sckw-auth/src/main/java/com/sckw/auth/model/vo/req/BusinessLicenseReqVo.java
  4. 125 0
      sckw-auth/src/main/java/com/sckw/auth/model/vo/req/EntAuthenticationReqVo.java
  5. 40 0
      sckw-auth/src/main/java/com/sckw/auth/model/vo/req/ForgetPasswordReqVo.java
  6. 6 1
      sckw-auth/src/main/java/com/sckw/auth/model/vo/req/RegisterReqVo.java
  7. 14 2
      sckw-auth/src/main/java/com/sckw/auth/service/IAuthService.java
  8. 68 12
      sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java
  9. 45 0
      sckw-auth/src/main/java/com/sckw/auth/util/AsyncFactory.java
  10. 3 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/LoginFilter.java
  11. 0 35
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/DeptTypeEnum.java
  12. 36 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/SystemTypeEnum.java
  13. 54 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/AsyncThreadUtils.java
  14. 7 0
      sckw-modules-api/pom.xml
  15. 42 6
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteUserService.java
  16. 55 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/BusinessLicenseReqDto.java
  17. 125 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/EntAuthenticationReqDto.java
  18. 39 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/ForgetPasswordReqDto.java
  19. 5 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/RegisterReqDto.java
  20. 75 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/UserLoginReqDto.java
  21. 0 15
      sckw-modules/sckw-file/src/main/java/com/sckw/file/service/dubbo/RemoteUserService1Impl.java
  22. 17 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java
  23. 0 12
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsUserController.java
  24. 11 3
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEntTypeDao.java
  25. 12 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEnterpriseDao.java
  26. 43 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsUserLoginDao.java
  27. 36 6
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java
  28. 72 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/KwsUserLogin.java
  29. 71 48
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java
  30. 11 12
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java
  31. 6 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsEntTypeDao.xml
  32. 12 2
      sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml
  33. 71 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsUserLoginDao.xml

+ 26 - 16
sckw-auth/src/main/java/com/sckw/auth/controller/IndexController.java → sckw-auth/src/main/java/com/sckw/auth/controller/AuthController.java

@@ -1,29 +1,26 @@
 package com.sckw.auth.controller;
 
+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.service.IIndexService;
+import com.sckw.auth.service.IAuthService;
+import com.sckw.core.exception.SystemException;
 import com.sckw.core.web.response.HttpResult;
-import com.sckw.system.api.RemoteUserService;
-import com.sckw.system.api.feign.RemoteUserFService;
-import com.sckw.system.api.model.dto.req.RegisterReqDto;
-import jakarta.servlet.http.HttpServletRequest;
-import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+/**
+ * @desc: 用户权限
+ * @author: czh
+ * @date: 2023/6/19
+ */
 @RestController
 @RequestMapping("/auth")
-public class IndexController {
+public class AuthController {
 
     @Autowired
-    private RemoteUserFService remoteUserFService;
-
-    @DubboReference(version = "2.0.0", group = "design", check = false)
-    private RemoteUserService remoteUserService;
-
-    @Autowired
-    private IIndexService indexService;
+    private IAuthService indexService;
 
     /**
      * @param reqVo 登录入参
@@ -33,7 +30,7 @@ public class IndexController {
      * @date: 2023/6/16
      */
     @PostMapping("/login")
-    public HttpResult login(@RequestBody LoginReqVo reqVo) {
+    public HttpResult login(@RequestBody LoginReqVo reqVo) throws SystemException {
         return HttpResult.ok(indexService.login(reqVo));
     }
 
@@ -45,9 +42,22 @@ public class IndexController {
      * @date: 2023/6/16
      */
     @PostMapping("/register")
-    public HttpResult register(@RequestBody RegisterReqVo reqDto) {
+    public HttpResult register(@RequestBody RegisterReqVo reqDto) throws SystemException {
         indexService.register(reqDto);
         return HttpResult.ok();
     }
 
+    /**
+     * @param reqDto 忘记密码入参
+     * @return HttpResult
+     * @desc: 忘记密码
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    @PostMapping("/forgetPassword")
+    public HttpResult forgetPassword(@RequestBody ForgetPasswordReqVo reqDto) throws SystemException {
+        indexService.forgetPassword(reqDto);
+        return HttpResult.ok();
+    }
+
 }

+ 20 - 0
sckw-auth/src/main/java/com/sckw/auth/model/vo/req/AddEntSettleReqDto.java

@@ -0,0 +1,20 @@
+package com.sckw.auth.model.vo.req;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 企业入驻入参
+ * @date 2023/6/19
+ */
+@Data
+public class AddEntSettleReqDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 2272172846219113723L;
+
+
+}

+ 55 - 0
sckw-auth/src/main/java/com/sckw/auth/model/vo/req/BusinessLicenseReqVo.java

@@ -0,0 +1,55 @@
+package com.sckw.auth.model.vo.req;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author czh
+ * @desc 执照
+ * @date 2023/6/19
+ */
+@Data
+public class BusinessLicenseReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 7847247628730819132L;
+
+    /**
+     * 执照记录id,新增时为空
+     */
+    private long id;
+
+    /**
+     * 执照编号
+     */
+    private String code;
+
+    /**
+     * 证书类型 (1联系人身份证 2法人身份证 3营业执照 4道路运输许可证 5开户许可证号 6授权证书 6电子签章授权书)
+     */
+    private int type;
+
+    /**
+     * 证书正面
+     */
+    private String certificateMian;
+
+    /**
+     * 证书反面
+     */
+    private String certificateRevolt;
+
+    /**
+     * 有效期
+     */
+    private Date validity;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 125 - 0
sckw-auth/src/main/java/com/sckw/auth/model/vo/req/EntAuthenticationReqVo.java

@@ -0,0 +1,125 @@
+package com.sckw.auth.model.vo.req;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author czh
+ * @desc 企业认证入参
+ * @date 2023/6/19
+ */
+@Data
+public class EntAuthenticationReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -6172558233846847201L;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 母公司id(当注册的公司是一家子公司时,entPid必传)
+     */
+    private Long entPid;
+
+    /**
+     * 企业名称
+     */
+    private String firmName;
+
+    /**
+     * 企业编号
+     */
+    private String code;
+
+    /**
+     * 企业联系人
+     */
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    private String telephone;
+
+    /**
+     * 法人姓名
+     */
+    private String legalName;
+
+    /**
+     * 法人电话
+     */
+    private String legalTelephone;
+
+    /**
+     * 企业头像
+     */
+    private String head;
+
+    /**
+     * 企业类型 多个类型用","隔开
+     */
+    private String entTypes;
+
+    /**
+     * 企业级别
+     */
+    private String entLevel;
+
+    /**
+     * 所属一级企业
+     */
+    private String belongFirstEnt;
+
+    /**
+     * 组织机构代码
+     */
+    private String orgCode;
+
+    /**
+     * 企业地址
+     */
+    private String cityCode;
+
+    /**
+     * 详细地址
+     */
+    private String detailAddress;
+
+    /**
+     * 注册来源 (app、pc)
+     */
+    private String regSource;
+
+    /**
+     * 纬度
+     */
+    private String lat;
+
+    /**
+     * 经度
+     */
+    private String lng;
+
+    /**
+     * 专属客户经理(用户ID)
+     */
+    private long manager;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 执照集合
+     */
+    private List<BusinessLicenseReqVo> businessLicense;
+
+}

+ 40 - 0
sckw-auth/src/main/java/com/sckw/auth/model/vo/req/ForgetPasswordReqVo.java

@@ -0,0 +1,40 @@
+package com.sckw.auth.model.vo.req;
+
+import lombok.Data;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 忘记密码入参
+ * @date 2023/6/19
+ */
+@Data
+public class ForgetPasswordReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 7390721321970569096L;
+
+    /**
+     * 账号
+     */
+    private String account;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 验证码
+     */
+    private String captcha;
+
+    /**
+     * 系统类型(1运营端、2企业开户)
+     */
+    private int systemType;
+
+}

+ 6 - 1
sckw-auth/src/main/java/com/sckw/auth/model/vo/req/RegisterReqVo.java

@@ -32,7 +32,7 @@ public class RegisterReqVo implements Serializable {
     private String telephone;
 
     /**
-     *系统类型(1运营端、2企业开户)
+     * 系统类型(1运营端、2企业开户)
      */
     private Integer systemType;
 
@@ -46,4 +46,9 @@ public class RegisterReqVo implements Serializable {
      */
     private Integer isMain;
 
+    /**
+     * 密码
+     */
+    private String password;
+
 }

+ 14 - 2
sckw-auth/src/main/java/com/sckw/auth/service/IIndexService.java → sckw-auth/src/main/java/com/sckw/auth/service/IAuthService.java

@@ -1,11 +1,15 @@
 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.system.api.model.dto.req.RegisterReqDto;
 import com.sckw.auth.model.vo.res.LoginResVo;
 
-public interface IIndexService {
+/**
+ *
+ */
+public interface IAuthService {
 
     /**
      * 登录
@@ -21,4 +25,12 @@ public interface IIndexService {
      * @date: 2023/6/16
      */
     void register(RegisterReqVo reqVo);
+
+    /**
+     * @param reqDto 忘记密码入参
+     * @desc: 忘记密码
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    void forgetPassword(ForgetPasswordReqVo reqDto);
 }

+ 68 - 12
sckw-auth/src/main/java/com/sckw/auth/service/impl/IndexServiceImpl.java → sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -1,11 +1,19 @@
 package com.sckw.auth.service.impl;
 
 import com.alibaba.fastjson.JSON;
+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.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.SystemTypeEnum;
+import com.sckw.core.web.context.LoginUserHolder;
+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.UserLoginReqDto;
 import com.sckw.system.api.model.dto.res.KwsRoleResDto;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
@@ -16,7 +24,7 @@ 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.res.*;
-import com.sckw.auth.service.IIndexService;
+import com.sckw.auth.service.IAuthService;
 import com.sckw.system.api.RemoteUserService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -26,11 +34,15 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
-import java.util.concurrent.*;
 
+/**
+ * @desc: 用户权限实现类
+ * @author: czh
+ * @date: 2023/6/19
+ */
 @Slf4j
 @Service
-public class IndexServiceImpl implements IIndexService {
+public class AuthServiceImpl implements IAuthService {
 
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteUserService remoteUserService;
@@ -54,7 +66,7 @@ public class IndexServiceImpl implements IIndexService {
         loginResVo.setRoleInfo(kwsRoleResDtos);
         if (CollectionUtils.isEmpty(kwsRoleResDtos)) {
             //角色信息为空,没有认证
-            saveToCache(loginResVo);
+            afterProcessor(loginResVo);
             return loginResVo;
         }
 
@@ -64,7 +76,7 @@ public class IndexServiceImpl implements IIndexService {
         List<KwsDeptResDto> kwsDepts = remoteUserService.queryDeptByIds(deptIds);
         if (CollectionUtils.isEmpty(kwsDepts)) {
             //数据不全,直接返回
-            saveToCache(loginResVo);
+            afterProcessor(loginResVo);
             return loginResVo;
         }
 
@@ -78,13 +90,13 @@ public class IndexServiceImpl implements IIndexService {
         KwsEnterpriseResDto kwsEnterprise = remoteUserService.queryEnterpriseById(entId);
         if (Objects.isNull(kwsEnterprise)) {
             //只要查出了机构,这个if其实不会进的,做保险起见还是加上判空
-            saveToCache(loginResVo);
+            afterProcessor(loginResVo);
             return loginResVo;
         }
         BeanUtils.copyProperties(kwsEnterprise, entInfoResVo);
 
         /*4、生成token,一些信息存redis*/
-        saveToCache(loginResVo);
+        afterProcessor(loginResVo);
         return loginResVo;
     }
 
@@ -94,16 +106,16 @@ public class IndexServiceImpl implements IIndexService {
      * @author: czh
      * @date: 2023/6/12
      */
-    private void saveToCache(LoginResVo loginResVo) {
+    private void afterProcessor(LoginResVo loginResVo) {
         try {
             String id = String.valueOf(loginResVo.getId());
             String token = EncryUtil.encry(Global.PRI_KEY, id);
             loginResVo.setToken(token);
-            RedissonUtils.add(Global.REDIS_USER_PREFIX + id, JSON.toJSONString(loginResVo));
+            RedissonUtils.add(Global.REDIS_USER_PREFIX + LoginUserHolder.getClientType() + Global.COLON + id, JSON.toJSONString(loginResVo));
 
             //异步存redis
-            ExecutorService executorService = new ThreadPoolExecutor(10, 20, 500L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
-            executorService.submit(new SaveMenuInfo(loginResVo.getId()));
+            AsyncFactory.execute(new SaveMenuInfo(loginResVo.getId()));
+            AsyncFactory.execute(new SaveLoginInfo(loginResVo, LoginUserHolder.getClientType()));
 
         } catch (Exception e) {
             throw new SystemException(HttpStatus.GLOBAL_EXCEPTION_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
@@ -124,8 +136,19 @@ public class IndexServiceImpl implements IIndexService {
     }
 
 
+
+    @Override
+    public void forgetPassword(ForgetPasswordReqVo reqDto) throws SystemException {
+        ForgetPasswordReqDto forgetPasswordReqDto = new ForgetPasswordReqDto();
+        BeanUtils.copyProperties(reqDto, forgetPasswordReqDto);
+        remoteUserService.forgetPassword(forgetPasswordReqDto);
+    }
+
+
     class SaveMenuInfo implements Runnable{
-        private long id;
+
+        private final long id;
+
         public SaveMenuInfo(long id) {
             this.id = id;
         }
@@ -147,4 +170,37 @@ public class IndexServiceImpl implements IIndexService {
         }
     }
 
+    class SaveLoginInfo implements Runnable {
+
+        private final LoginResVo loginResVo;
+
+        private final String clientType;
+
+        @DubboReference(version = "2.0.0", group = "design", check = false)
+        private RemoteUserService remoteUserService;
+
+        public SaveLoginInfo(LoginResVo loginResVo, String clientType) {
+            this.loginResVo = loginResVo;
+            this.clientType = clientType;
+        }
+
+        @Override
+        public void run() {
+            long userId = loginResVo.getId();
+            UserLoginReqDto currentDayLogin = remoteUserService.currentDayLogin(userId);
+            UserLoginReqDto userLoginReqDto = new UserLoginReqDto();
+            userLoginReqDto.setPid(Objects.isNull(currentDayLogin) ? "" : String.valueOf(currentDayLogin.getUserId()));
+            userLoginReqDto.setIp("");
+            userLoginReqDto.setUserAgent("");
+            userLoginReqDto.setUserId(loginResVo.getId());
+            userLoginReqDto.setToken(loginResVo.getToken());
+            userLoginReqDto.setValidTime("");
+            userLoginReqDto.setFirst(Objects.isNull(currentDayLogin) ? Global.YES : Global.NO);
+            userLoginReqDto.setLock(Global.NO);
+            userLoginReqDto.setType(Global.NO);
+            userLoginReqDto.setSource(clientType);
+            remoteUserService.saveUserLogin(userLoginReqDto);
+        }
+    }
+
 }

+ 45 - 0
sckw-auth/src/main/java/com/sckw/auth/util/AsyncFactory.java

@@ -0,0 +1,45 @@
+package com.sckw.auth.util;
+
+import cn.hutool.core.thread.NamedThreadFactory;
+
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author czh
+ * @desc 异步工厂
+ * @date 2023/6/19
+ */
+public class AsyncFactory {
+
+    private AsyncFactory() {}
+
+    /**
+     * 全局访问点
+     */
+    public static void execute(Runnable runnable) {
+        ThreadPoolExecutorHolder.THREAD_POOL_EXECUTOR.execute(runnable);
+    }
+
+    /**
+     * 静态内部类创建实例(单例)
+     */
+    private static class ThreadPoolExecutorHolder {
+//        static final int CPU = Runtime.getRuntime().availableProcessors();
+        static final int CORE_POOL_SIZE = 10;
+        static final int MAXIMUM_POOL_SIZE = 15;
+        static final long KEEP_ALIVE_TIME = 1L;
+        static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
+        static final int MAX_QUEUE_NUM = 1024;
+
+        //static变量只会初始化一次
+        public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(
+                CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, TIME_UNIT,
+                new LinkedBlockingQueue<>(MAX_QUEUE_NUM),
+                new NamedThreadFactory("ThreadPoolExecutorFactory-", false),
+                new ThreadPoolExecutor.AbortPolicy());
+    }
+
+
+}

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

@@ -72,13 +72,15 @@ public class LoginFilter implements Filter {
         }
 
         //从redis获取用户信息
-        Object object = RedissonUtils.get(Global.REDIS_USER_PREFIX + key);
+        Object object = RedissonUtils.get(Global.REDIS_USER_PREFIX + LoginUserHolder.getClientType() + Global.COLON + key);
         if (Objects.isNull(object)) {
             throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.TOKEN_INVAILD);
         }
 
         /*3、将redis里的用户信息存入内存中,避免业务操作多次从redis获取值*/
+        String clientType = request.getHeader(RequestConstant.CLIENT_TYPE);
         LoginUserInfo loginUserInfo = JSONObject.parseObject(object.toString(), LoginUserInfo.class);
+        loginUserInfo.setClientType(clientType);
         LoginUserHolder.set(loginUserInfo);
         //管理员不限制权限
         if (loginUserInfo.getIsMain() == Global.YES){

+ 0 - 35
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/DeptTypeEnum.java

@@ -1,35 +0,0 @@
-package com.sckw.core.model.enums;
-
-import lombok.Getter;
-
-/**
- * @author czh
- * @desc 机构类型枚举
- * @date 2023/6/15
- */
-@Getter
-public enum DeptTypeEnum {
-
-    //系统管理机构
-    MANAGE(1, "系统管理机构"),
-    //平台企业机构
-    COMPANY(2, "平台企业机构");
-
-    private final int code;
-
-    private final String name;
-
-    DeptTypeEnum(int code, String name){
-        this.code = code;
-        this.name = name;
-    }
-
-    public static DeptTypeEnum getName(int code){
-        for (DeptTypeEnum deptTypeEnum : values()) {
-            if (deptTypeEnum.getCode() == code) {
-                return deptTypeEnum;
-            }
-        }
-        return null;
-    }
-}

+ 36 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/SystemTypeEnum.java

@@ -0,0 +1,36 @@
+package com.sckw.core.model.enums;
+
+import lombok.Getter;
+
+/**
+ * @author czh
+ * @desc 系统类型枚举
+ * @date 2023/6/15
+ */
+@Getter
+public enum SystemTypeEnum {
+    //运营端
+    MANAGE(1, "运营端"),
+    //企业开户
+    COMPANY(2, "企业开户"),
+    //司机
+    DRIVER(3, "司机");
+
+    private final int code;
+
+    private final String name;
+
+    SystemTypeEnum(int code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public static SystemTypeEnum getName(int code){
+        for (SystemTypeEnum systemTypeEnum : values()) {
+            if (systemTypeEnum.getCode() == code) {
+                return systemTypeEnum;
+            }
+        }
+        return null;
+    }
+}

+ 54 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/AsyncThreadUtils.java

@@ -0,0 +1,54 @@
+package com.sckw.core.utils;
+
+import java.util.concurrent.*;
+
+/**
+ * @author czh
+ * @desc TODO
+ * @date 2023/6/19
+ */
+public class AsyncThreadUtils {
+
+    //CPU核心数
+    private static final int corePoolSize = Runtime.getRuntime().availableProcessors();
+    private static final int maximumPoolSize = corePoolSize * 2;
+    private static final long keepAliveTime = 10;
+    private static final TimeUnit keepAliveTimeUnit = TimeUnit.SECONDS;
+    private static final BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(1024);
+    private static final RejectedExecutionHandler rejectedHandler = new ThreadPoolExecutor.CallerRunsPolicy();
+
+    /**
+     * corePoolSize : 线程池核心线程数,最好默认CPU核心数
+     * maximumPoolSize : 线程池最大线程数,最好是核心线程数的两倍,太多会引起线程切换
+     * keepAliveTime : 大于核心线程数的空闲线程存活时间
+     * keepAliveTimeUnit : 空闲线程存活时间的单位(秒、分钟、小时等等)
+     * workQueue : 线程池有界队列,新任务没有可用线程处理时会把任务放到该队列中,等待被处理
+     * rejectedHandler : 拒绝处理策略,默认直接丢弃并抛出异常-AbortPolicy,调用者线程直接处理-CallerRunsPolicy
+     */
+    private static ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
+            corePoolSize,
+            maximumPoolSize,
+            keepAliveTime,
+            keepAliveTimeUnit,
+            workQueue,
+            rejectedHandler
+    );
+
+    /**
+     * 直接提交任务,无返回值
+     * @param task Runnable
+     */
+    public static void submit(Runnable task){
+        poolExecutor.submit(task);
+    }
+
+    /**
+     * 提交任务,返回泛型结果
+     * @param <T>
+     * @return Future
+     */
+    public static <T> Future<T> submit(Callable<T> task){
+        return poolExecutor.submit(task);
+    }
+
+}

+ 7 - 0
sckw-modules-api/pom.xml

@@ -15,6 +15,13 @@
     <packaging>pom</packaging>
     <description>接口模块</description>
 
+    <dependencies>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-core</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+    </dependencies>
     <modules>
         <module>sckw-system-api</module>
         <module>sckw-file-api</module>

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

@@ -1,23 +1,30 @@
 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.res.*;
 import java.util.List;
 
+/**
+ * @desc: 远程接口
+ * @author: czh
+ * @date: 2023/6/19
+ */
 public interface RemoteUserService {
 
-    String getUserInfoV1(String account);
-
     /**
      * 根据用户名查用户信息
-     * @param username
+     * @param username 用户账号
      * @return
      */
     KwsUserResDto getUserByAccount(String username);
 
     /**
      * 根据用户id查用户和机构关联关系
-     * @param userId
+     * @param userId 用户id
      * @return
      */
     List<KwsUserDeptResDto> queryUserDeptByUserId(Long userId);
@@ -30,9 +37,12 @@ public interface RemoteUserService {
     List<KwsDeptResDto> queryDeptByIds(List<Long> ids);
 
     /**
-     * 注册
+     * @param reqDto 用户注册入参
+     * @desc: 用户注册
+     * @author: czh
+     * @date: 2023/6/19
      */
-    void register(RegisterReqDto reqDto);
+    void register(RegisterReqDto reqDto) throws SystemException;
 
     /**
      * 校验密码
@@ -72,4 +82,30 @@ public interface RemoteUserService {
      * @date: 2023/6/13
      */
     List<UserAccessMenuInfoResDto> queryUserAccessMenu(long id);
+
+
+    /**
+     * @param reqDto 忘记密码入参
+     * @desc: 忘记密码
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    void forgetPassword(ForgetPasswordReqDto reqDto);
+
+    /**
+     * @param userLoginReqDto  用户登录信息
+     * @desc: 保存用户登录信息
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    void saveUserLogin(UserLoginReqDto userLoginReqDto);
+
+    /**
+     * @param userId 用户id
+     * @return 登录
+     * @desc: 查询用户当天首次登录
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    UserLoginReqDto currentDayLogin(long userId);
 }

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

@@ -0,0 +1,55 @@
+package com.sckw.system.api.model.dto.req;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author czh
+ * @desc 执照
+ * @date 2023/6/19
+ */
+@Data
+public class BusinessLicenseReqDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 7847247628730819132L;
+
+    /**
+     * 执照记录id,新增时为空
+     */
+    private long id;
+
+    /**
+     * 执照编号
+     */
+    private String code;
+
+    /**
+     * 证书类型 (1联系人身份证 2法人身份证 3营业执照 4道路运输许可证 5开户许可证号 6授权证书 6电子签章授权书)
+     */
+    private int type;
+
+    /**
+     * 证书正面
+     */
+    private String certificateMian;
+
+    /**
+     * 证书反面
+     */
+    private String certificateRevolt;
+
+    /**
+     * 有效期
+     */
+    private Date validity;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

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

@@ -0,0 +1,125 @@
+package com.sckw.system.api.model.dto.req;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author czh
+ * @desc 企业认证入参
+ * @date 2023/6/19
+ */
+@Data
+public class EntAuthenticationReqDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 3979518567178774797L;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 母公司id(当注册的公司是一家子公司时,entPid必传)
+     */
+    private Long entPid;
+
+    /**
+     * 企业名称
+     */
+    private String firmName;
+
+    /**
+     * 企业编号
+     */
+    private String code;
+
+    /**
+     * 企业联系人
+     */
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    private String telephone;
+
+    /**
+     * 法人姓名
+     */
+    private String legalName;
+
+    /**
+     * 法人电话
+     */
+    private String legalTelephone;
+
+    /**
+     * 企业头像
+     */
+    private String head;
+
+    /**
+     * 企业类型 多个类型用","隔开
+     */
+    private String entTypes;
+
+    /**
+     * 企业级别
+     */
+    private String entLevel;
+
+    /**
+     * 所属一级企业
+     */
+    private String belongFirstEnt;
+
+    /**
+     * 组织机构代码
+     */
+    private String orgCode;
+
+    /**
+     * 企业地址
+     */
+    private String cityCode;
+
+    /**
+     * 详细地址
+     */
+    private String detailAddress;
+
+    /**
+     * 注册来源 (app、pc)
+     */
+    private String regSource;
+
+    /**
+     * 纬度
+     */
+    private String lat;
+
+    /**
+     * 经度
+     */
+    private String lng;
+
+    /**
+     * 专属客户经理(用户ID)
+     */
+    private long manager;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 执照集合
+     */
+    private List<BusinessLicenseReqDto> businessLicense;
+
+}

+ 39 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/req/ForgetPasswordReqDto.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/6/19
+ */
+@Data
+public class ForgetPasswordReqDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 8377449507548850232L;
+
+    /**
+     * 账号
+     */
+    private String account;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 验证码
+     */
+    private String captcha;
+
+    /**
+     * 系统类型(1运营端、2企业开户)
+     */
+    private int systemType;
+
+}

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

@@ -41,4 +41,9 @@ public class RegisterReqDto implements Serializable {
      */
     private Integer systemType;
 
+    /**
+     * 密码
+     */
+    private String password;
+
 }

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

@@ -0,0 +1,75 @@
+package com.sckw.system.api.model.dto.req;
+
+import com.sckw.system.api.model.dto.BaseModelResDto;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author czh
+ * @desc 用户登录记录
+ * @date 2023/6/19
+ */
+@Data
+public class UserLoginReqDto extends BaseModelResDto implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 5716439258112124800L;
+
+    /**
+     * 首次登陆id
+     */
+    private String pid;
+
+    /**
+     * 操作ip
+     */
+    private String ip;
+
+    /**
+     * 用户代理
+     */
+    private String userAgent;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * token
+     */
+    private String token;
+
+    /**
+     * 有效时间
+     */
+    private String validTime;
+
+    /**
+     * 是否首次登陆(1是,0否)
+     */
+    private Integer first;
+
+    /**
+     * 是否上锁(此次登陆该账号是否还有用户在线:0未上锁,1上锁)
+     */
+    private Integer lock;
+
+    /**
+     * 退出类型(0主动退出登录,1异常退出登录)
+     */
+    private Integer type;
+
+    /**
+     * 退出时间
+     */
+    private Date outTime;
+
+    /**
+     * 来源(app、pc)
+     */
+    private String source;
+}

+ 0 - 15
sckw-modules/sckw-file/src/main/java/com/sckw/file/service/dubbo/RemoteUserService1Impl.java

@@ -1,15 +0,0 @@
-package com.sckw.file.service.dubbo;
-
-import com.sckw.system.api.RemoteUserService;
-import org.apache.dubbo.config.annotation.DubboService;
-
-import java.util.Date;
-
-@DubboService(group = "design", version = "2.0.0")
-public class RemoteUserService1Impl implements RemoteUserService {
-
-    @Override
-    public String getUserInfoV1(String account) {
-        return "getUserInfoV1:"+new Date() +account;
-    }
-}

+ 17 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -1,5 +1,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;
@@ -63,7 +64,7 @@ public class KwsEnterpriseController {
 
     /**
      * @return HttpResult
-     * @description 注册
+     * @description 注册 企业认证
      * @author zk
      * @date 2023/06/02
      **/
@@ -73,6 +74,19 @@ public class KwsEnterpriseController {
         return HttpResult.ok(HttpStatus.MSG_003);
     }
 
+    /**
+     * @param reqVo 新增企业入驻入参
+     * @return HttpResult
+     * @desc: 新增企业入驻
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    @PostMapping("/addEntSettle")
+    public HttpResult addEntSettle(@RequestBody EntRegisterReqVo reqVo) throws SystemException {
+        kwsEntService.addEntSettle(reqVo);
+        return HttpResult.ok();
+    }
+
     /**
      * @param params {name 机构名称、company 是否公司}
      * @return HttpResult
@@ -107,7 +121,8 @@ public class KwsEnterpriseController {
      **/
     @DeleteMapping("/dels")
     public HttpResult del(@RequestParam String ids) throws Exception {
-        return kwsEntService.deleteByKey(ids);
+        kwsEntService.deleteByKey(ids);
+        return  HttpResult.ok();
     }
 
     /**

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

@@ -151,18 +151,6 @@ public class KwsUserController {
         return HttpResult.ok();
     }
 
-    /**
-     * @param reqVo 校验账号有效性入参
-     * @return HttpResult
-     * @desc: 校验账号有效性
-     * @author: czh
-     * @date: 2023/6/16
-     */
-    @PostMapping
-    public HttpResult checkAccountValid(@RequestBody CheckAccountValidReqVo reqVo){
-        kwsUserService.checkAccountValid(reqVo);
-        return HttpResult.ok();
-    }
 
     @PostMapping("testEdit")
     public HttpResult testEdit() {

+ 11 - 3
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEntTypeDao.java

@@ -29,11 +29,19 @@ public interface KwsEntTypeDao {
 
     /**
      * 查询
-     * @param entId
+     * @param 主键Id
      * @return
-     * @throws Exception
      */
-    List<KwsEntType> findList(Long entId);
+    List<KwsEntType> findList(Long id);
+
+    /**
+     * @param entId 企业id
+     * @return KwsEntType
+     * @desc: 根据企业id查
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    List<KwsEntType> findListByEntId(Long entId);
 
     /**
      * 批量插

+ 12 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEnterpriseDao.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.system.model.KwsEnterprise;
 import com.sckw.system.model.vo.req.EntFindPageReqVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
 import java.util.List;
 import java.util.Map;
 
@@ -13,7 +15,7 @@ import java.util.Map;
  * @date 2023-06-02
  */
 @Mapper
-public interface KwsEnterpriseDao extends BaseMapper<KwsEnterprise> {
+public interface KwsEnterpriseDao {
     /**
      * 新增
      * @param record
@@ -35,6 +37,15 @@ public interface KwsEnterpriseDao extends BaseMapper<KwsEnterprise> {
      */
     KwsEnterprise selectByKey(Long id);
 
+    /**
+     * @param list 主键Ids
+     * @return KwsEnterprise
+     * @desc: 批量查
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    List<KwsEnterprise> selectByKeys(@Param(value = "list") List<Long> list);
+
     /**
      * 查询
      * @param params

+ 43 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsUserLoginDao.java

@@ -0,0 +1,43 @@
+package com.sckw.system.dao;
+
+import com.sckw.system.model.KwsUserLogin;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @desc: 用户登录
+ * @author: czh
+ * @date: 2023/6/19
+ */
+@Mapper
+public interface KwsUserLoginDao {
+
+    /**
+     * 批量新增
+     * @param list
+     * @return
+     */
+    int saveBatch(@Param(value = "list") List<KwsUserLogin> list);
+
+    /**
+     * @param userId 用户id
+     * @return List
+     * @desc: 根据用户ID查
+     * @author: czh
+     * @date: 2023/6/13
+     */
+    List<KwsUserLogin> findAllByUserId(@Param(value = "userId") Long userId, @Param(value = "startTime") Date startTime, @Param(value = "endTime") Date endTime);
+
+    /**
+     * @param userId 用户id
+     * @return KwsUserLogin
+     * @desc: 当天登录次数
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    KwsUserLogin currentDayLogin(@Param(value = "userId") Long userId);
+
+}

+ 36 - 6
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java

@@ -1,12 +1,19 @@
 package com.sckw.system.dubbo;
 
+import com.sckw.core.exception.SystemException;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.system.api.RemoteUserService;
+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.res.*;
+import com.sckw.system.dao.KwsUserLoginDao;
 import com.sckw.system.model.*;
 import com.sckw.system.model.pojo.FindMenuTreePojo;
+import com.sckw.system.model.vo.req.EntRegisterReqVo;
+import com.sckw.system.model.vo.req.ForgetPasswordReqVo;
 import com.sckw.system.model.vo.res.KwsMenuResVo;
 import com.sckw.system.service.KwsEnterpriseService;
 import com.sckw.system.service.KwsMenuService;
@@ -43,10 +50,8 @@ public class RemoteUserServiceImpl implements RemoteUserService {
     @Resource
     private KwsMenuService kwsMenuService;
 
-    @Override
-    public String getUserInfoV1(String account) {
-        return null;
-    }
+    @Resource
+    private KwsUserLoginDao kwsUserLoginDao;
 
     @Override
     public KwsUserResDto getUserByAccount(String username) {
@@ -116,12 +121,37 @@ public class RemoteUserServiceImpl implements RemoteUserService {
     }
 
     @Override
-    public void register(RegisterReqDto reqDto) {
+    public void forgetPassword(ForgetPasswordReqDto reqDto) throws SystemException {
+        com.sckw.system.model.vo.req.ForgetPasswordReqVo forgetPasswordReqVo = new ForgetPasswordReqVo();
+        BeanUtils.copyProperties(reqDto, forgetPasswordReqVo);
+        kwsUserService.forgetPassword(forgetPasswordReqVo);
+    }
+
+    @Override
+    public void saveUserLogin(UserLoginReqDto userLoginReqDto) {
+        KwsUserLogin kwsUserLogin = new KwsUserLogin();
+        BeanUtils.copyProperties(userLoginReqDto, kwsUserLogin);
+        kwsUserLoginDao.saveBatch(Collections.singletonList(kwsUserLogin));
+    }
+
+    @Override
+    public UserLoginReqDto currentDayLogin(long userId) {
+        KwsUserLogin kwsUserLogin = kwsUserLoginDao.currentDayLogin(userId);
+        if (Objects.isNull(kwsUserLogin)) {
+            return null;
+        }
+        UserLoginReqDto userLoginReqDto = new UserLoginReqDto();
+        BeanUtils.copyProperties(kwsUserLogin, userLoginReqDto);
+        return userLoginReqDto;
+    }
+
+    @Override
+    public void register(RegisterReqDto reqDto) throws SystemException {
         kwsUserService.register(reqDto);
     }
 
     @Override
-    public void checkPassword(String password, String currentPwd) {
+    public void checkPassword(String password, String currentPwd) throws SystemException {
         kwsUserService.checkPassword(password, currentPwd);
     }
 

+ 72 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/KwsUserLogin.java

@@ -0,0 +1,72 @@
+package com.sckw.system.model;
+
+import com.sckw.core.model.base.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * @desc: 用户登录
+ * @author: czh
+ * @date: 2023/6/19
+ */
+@Data
+public class KwsUserLogin extends BaseModel {
+
+    /**
+     * 首次登陆id
+     */
+    private String pid;
+
+    /**
+     * 操作ip
+     */
+    private String ip;
+
+    /**
+     * 用户代理
+     */
+    private String userAgent;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * token
+     */
+    private String token;
+
+    /**
+     * 有效时间
+     */
+    private Date validTime;
+
+    /**
+     * 是否首次登陆(1是,0否)
+     */
+    private Integer first;
+
+    /**
+     * 是否上锁(此次登陆该账号是否还有用户在线:0未上锁,1上锁)
+     */
+    private Integer lock;
+
+    /**
+     * 退出类型(0主动退出登录,1异常退出登录)
+     */
+    private Integer type;
+
+    /**
+     * 退出时间
+     */
+    private Date outTime;
+
+    /**
+     * 来源(app、pc)
+     */
+    private String source;
+
+}

+ 71 - 48
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -9,9 +9,8 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.ApprovalEnum;
-import com.sckw.core.model.enums.DeptTypeEnum;
 import com.sckw.core.model.enums.EntTypeEnum;
-import com.sckw.core.model.enums.UserSystemTypeEnum;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.utils.BeanUtils;
@@ -21,13 +20,11 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.system.api.model.dto.req.RegisterReqDto;
 import com.sckw.system.dao.*;
 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.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.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -56,24 +53,14 @@ public class KwsEnterpriseService {
     @Autowired
     private KwsEntDeptDao kwsEntDeptDao;
 
-    @Autowired
-    private KwsDeptService kwsDeptService;
-
-    @Autowired
-    private KwsRoleService kwsRoleService;
-
     @Autowired
     private KwsUserService kwsUserService;
 
-    @Autowired
-    private KwsMenuService kwsMenuService;
-
     /**
-     * 添加新纪录
-     *
-     * @param params
-     * @return
-     * @throws Exception
+     * @param params 入库
+     * @desc: 单表入库
+     * @author: czh
+     * @date: 2023/6/19
      */
     public void add(KwsEnterprise params) {
         if (kwsEnterpriseDao.insert(params) <= 0) {
@@ -83,17 +70,35 @@ public class KwsEnterpriseService {
 
     /**
      * 删除记录-根据主键
-     *
-     * @param ids
-     * @return
-     * @throws Exception
+     * @param ids 主键
+     * @desc: 批量删除
+     * @author: czh
+     * @date: 2023/6/19
      */
-    public HttpResult deleteByKey(String ids) throws Exception {
-        return null;
+    public void deleteByKey(String ids) throws Exception {
+        String[] idArr = ids.split(",");
+        List<Long> list = new ArrayList<>();
+        for (String id : idArr) {
+            list.add(Long.valueOf(id));
+        }
+        List<KwsEnterprise> kwsEnterprises = kwsEnterpriseDao.selectByKeys(list);
+        if (CollectionUtils.isEmpty(kwsEnterprises)) {
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
+        }
+
+        for (KwsEnterprise kwsEnterprise : kwsEnterprises) {
+            kwsEnterprise.setDelFlag(Global.YES);
+            if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
+                throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+            }
+        }
     }
 
     /**
-     * 更新记录,有的是更新有的是新增,两种情况
+     * @param reqVo 更新记录入参
+     * @desc: 更新记录,有的是更新有的是新增,两种情况
+     * @author: czh
+     * @date: 2023/6/19
      */
     @Transactional(rollbackFor = Exception.class)
     public void update(KwsEnterpriseReqVo reqVo) throws Exception {
@@ -106,7 +111,7 @@ public class KwsEnterpriseService {
         }
 
         /*2、更新企业类型*/
-        List<KwsEntType> kwsEntTypes = null;
+        List<KwsEntType> kwsEntTypes = kwsEntTypeDao.findListByEntId(entId);
         List<String> typeReqList = new ArrayList<>();
         String entTypes = reqVo.getEntTypes();
         if (StringUtils.isNotBlank(entTypes)) {
@@ -187,11 +192,11 @@ public class KwsEnterpriseService {
 
 
     /**
-     * 根据主键查询
-     *
-     * @param key
-     * @return
-     * @throws Exception
+     * @param key 企业id
+     * @return KwsEnterprise
+     * @desc: 根据主键查询
+     * @author: czh
+     * @date: 2023/6/9
      */
     public KwsEnterprise selectByKey(Long key) {
         return checkKwsEnterpriseById(key);
@@ -199,7 +204,7 @@ public class KwsEnterpriseService {
 
 
     /**
-     * @param reqVo
+     * @param reqVo 分页入参
      * @return HttpResult
      * @desc: 分页查询
      * @author: czh
@@ -208,11 +213,11 @@ public class KwsEnterpriseService {
     public PageResult findPage(EntFindPageReqVo reqVo) throws Exception {
         PageHelper.startPage(reqVo.getPageNum(), reqVo.getPageSize());
         List<KwsEnterprise> list = findList(reqVo);
-        return PageHelperUtil.getPageResult(new PageInfo(list));
+        return PageHelperUtil.getPageResult(new PageInfo<>(list));
     }
 
     /**
-     * @param reqVo
+     * @param reqVo 企业实体类入参
      * @return List<KwsEnterprise>
      * @desc: 全量查询
      * @author: czh
@@ -223,15 +228,12 @@ public class KwsEnterpriseService {
     }
 
     /**
-     * 参数校验
-     *
-     * @param params
-     * @return
-     * @throws Exception
+     * @param params 参数校验
+     * @desc: 参数校验
+     * @author: czh
+     * @date: 2023/6/19
      */
-    public HttpResult paramsCheck(KwsEnterprise params) {
-
-        return null;
+    public void paramsCheck(KwsEnterprise params) {
     }
 
     /**
@@ -240,9 +242,12 @@ public class KwsEnterpriseService {
     @Transactional(rollbackFor = Exception.class)
     public void register(EntRegisterReqVo reqVo) {
         /*1、存企业信息表*/
-        KwsEnterprise kwsEnterprise = new KwsEnterprise();
-        long entId = reqVo.getEntId();
-        kwsEnterprise.setId(entId);
+        KwsEnterprise kwsEnterprise = kwsEnterpriseDao.selectByKey(reqVo.getEntId());
+        if (Objects.isNull(kwsEnterprise)) {
+            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+        }
+
+        Long entId = kwsEnterprise.getId();
         Date date = new Date();
         Long userId = LoginUserHolder.getUserId();
         BeanUtils.copyProperties(reqVo, kwsEnterprise);
@@ -303,7 +308,6 @@ public class KwsEnterpriseService {
             kwsEntDept.setEntId(entId);
             kwsEntDept.setEntPid(reqVo.getEntPid());
             kwsEntDept.setId(new IdWorker(1L).nextId());
-            kwsEntDept.setRemark("");
             if (kwsEntDeptDao.insert(kwsEntDept) <= 0) {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             }
@@ -366,7 +370,7 @@ public class KwsEnterpriseService {
         List<CertificateResVo> list = new ArrayList<>();
         kwsEntCertificates.forEach(item -> {
             CertificateResVo certificateResVo = new CertificateResVo();
-            certificateResVo.setTypeName(EntTypeEnum.getName(item.getType()).getName());
+            certificateResVo.setTypeName(Objects.requireNonNull(EntTypeEnum.getName(item.getType())).getName());
             BeanUtils.copyProperties(item, certificateResVo);
             list.add(certificateResVo);
         });
@@ -384,4 +388,23 @@ public class KwsEnterpriseService {
         return kwsEnterpriseDao.findByUserId(userId);
     }
 
+    /**
+     * @param reqVo 新增企业入驻入参
+     * @desc: 新增企业入驻
+     * @author: czh
+     * @date: 2023/6/19
+     */
+    public void addEntSettle(EntRegisterReqVo reqVo) {
+        /*1、存用户信息*/
+        RegisterReqDto registerReqDto = new RegisterReqDto();
+        registerReqDto.setEntName(reqVo.getFirmName());
+        registerReqDto.setName(reqVo.getContacts());
+        registerReqDto.setTelephone(reqVo.getTelephone());
+        registerReqDto.setIsMain(Global.YES);
+        registerReqDto.setSystemType(SystemTypeEnum.COMPANY.getCode());
+        kwsUserService.register(registerReqDto);
+
+        /*2、认证*/
+        register(reqVo);
+    }
 }

+ 11 - 12
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -1,10 +1,8 @@
 package com.sckw.system.service;
-import java.util.Date;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.ApprovalEnum;
-import com.sckw.core.model.enums.DeptTypeEnum;
-import com.sckw.core.model.enums.UserSystemTypeEnum;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.redis.utils.RedissonUtils;
@@ -80,12 +78,13 @@ public class KwsUserService {
 
     }
 
-    public void register(RegisterReqDto reqDto) {
+    public void register(RegisterReqDto reqDto) throws SystemException {
         /*存用户表、企业表,暂时不处理角色关系,需要认证*/
         KwsUser kwsUser = new KwsUser();
         long userId = new IdWorker(1).nextId();
         kwsUser.setSystemType(reqDto.getSystemType());
         kwsUser.setAccount(reqDto.getTelephone());
+        kwsUser.setPassword(reqDto.getPassword());
         kwsUser.setName(reqDto.getName());
         kwsUser.setTelephone(reqDto.getTelephone());
         kwsUser.setIsMain(reqDto.getIsMain());
@@ -98,6 +97,7 @@ public class KwsUserService {
         }
 
         /*存企业机构等*/
+        //目前注册接口只有管理员进来
         if(reqDto.getIsMain() == Global.YES) {
             KwsEnterprise kwsEnterprise = new KwsEnterprise();
             long entId = new IdWorker(1L).nextId();
@@ -110,8 +110,8 @@ public class KwsUserService {
             KwsDept kwsDept = new KwsDept();
             long deptId = new IdWorker(1L).nextId();
             kwsDept.setEntId(entId);
-            kwsDept.setName(DeptTypeEnum.MANAGE.getName());
-            kwsDept.setSystemType(DeptTypeEnum.MANAGE.getCode());
+            kwsDept.setName(SystemTypeEnum.MANAGE.getName());
+            kwsDept.setSystemType(SystemTypeEnum.MANAGE.getCode());
             kwsDept.setCompany(Global.NO);
             kwsDeptService.add(kwsDept);
 
@@ -277,7 +277,7 @@ public class KwsUserService {
         updatePwd(newPassword, kwsUser);
     }
 
-    private void updatePwd(String newPassword, KwsUser kwsUser) {
+    private void updatePwd(String newPassword, KwsUser kwsUser) throws SystemException {
         kwsUser.setPassword(PasswordUtils.entryptPassword(newPassword));
         if(kwsUserDao.update(kwsUser) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
@@ -287,12 +287,11 @@ public class KwsUserService {
     /**
      * 忘记密码
      */
-    public void forgetPassword(ForgetPasswordReqVo reqVo) {
+    public void forgetPassword(ForgetPasswordReqVo reqVo) throws SystemException {
         //查用户信息
         KwsUser kwsUser = checkUserBase(reqVo.getAccount(), reqVo.getSystemType());
 
         //从缓存中取出验证码,校验
-        //todo
         String sms = RedissonUtils.get("captcha:czh").toString();
         if (!reqVo.getCaptcha().equals(sms)) {
             throw new SystemException(HttpStatus.CODE_10301, HttpStatus.CAPTCHA_ERROR);
@@ -309,7 +308,7 @@ public class KwsUserService {
      * @author: czh
      * @date: 2023/6/16
      */
-    public KwsUser checkUserBase(String account, int systemType) {
+    public KwsUser checkUserBase(String account, int systemType) throws SystemException {
         KwsUser kwsUser = getUserByAccount(account, systemType);
         if (Objects.isNull(kwsUser)) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ACCOUNT_NOT_EXISTS);
@@ -333,7 +332,7 @@ public class KwsUserService {
      * @param password 入参传的密码
      * @param currentPwd 当前用户的密码
      */
-    public void checkPassword(String password, String currentPwd) {
+    public void checkPassword(String password, String currentPwd) throws SystemException{
         if (!PasswordUtils.validatePassword(password, currentPwd)) {
             throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PASSWD_ERROR);
         }
@@ -358,4 +357,4 @@ public class KwsUserService {
             throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_EXISTS);
         }
     }
-}
+}

+ 6 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEntTypeDao.xml

@@ -151,4 +151,10 @@
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
+  <select id="findList" resultType="com.sckw.system.model.KwsEntType">
+    select * from kws_ent_type a where a.id = #{id} and a.del_flag = 0 and a.status = 0
+  </select>
+  <select id="findListByEntId" resultType="com.sckw.system.model.KwsEntType">
+    select * from kws_ent_type a where a.ent_id = #{entId} and a.del_flag = 0 and a.status = 0
+  </select>
 </mapper>

+ 12 - 2
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -66,7 +66,7 @@
     <if test="legalTelephone != null and legalTelephone != ''">
       and a.legal_telephone = #{legalName}
     </if>
-    <if test="approval !=">
+    <if test="approval != null">
       and a.approval = #{approval}
     </if>
     order by a.create_time
@@ -87,8 +87,18 @@
          and c.status = 0
          and d.status = 0
     </select>
+  <select id="selectByKeys" resultType="com.sckw.system.model.KwsEnterprise">
+    select
+    <include refid="Base_Column_List" />
+    from kws_enterprise
+    where id in
+        <foreach collection="list" item="item" open="(" close=")" separator=",">
+          #{item}
+        </foreach>
+
+  </select>
 
-    <insert id="insert" parameterType="com.sckw.system.model.KwsEnterprise">
+  <insert id="insert" parameterType="com.sckw.system.model.KwsEnterprise">
     insert into kws_enterprise
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="id != null">

+ 71 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsUserLoginDao.xml

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.system.dao.KwsUserLoginDao">
+    <insert id="saveBatch" parameterType="com.sckw.system.model.KwsUserLogin">
+      insert into kws_user_login
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+        id,
+        pid,
+        ip,
+        user_agent,
+        user_id,
+        token,
+        valid_time,
+        first,
+        lock,
+        type,
+        out_time,
+        source,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        del_flag
+      </trim>
+      values
+      <foreach collection="list" item="item" separator=",">
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+          #{item.id, jdbcType=BIGINT},
+          #{item.pid, jdbcType=VARCHAR},
+          #{item.ip, jdbcType=VARCHAR},
+          #{item.userAgent, jdbcType=VARCHAR},
+          #{item.user_id, jdbcType=BIGINT},
+          #{item.token, jdbcType=VARCHAR},
+          #{item.validTime, jdbcType=VARCHAR},
+          #{item.first, jdbcType=INTEGER},
+          #{item.lock, jdbcType=INTEGER},
+          #{item.type, jdbcType=INTEGER},
+          #{item.outTime, jdbcType=TIMESTAMP},
+          #{item.source, jdbcType=VARCHAR},
+          #{item.createBy, jdbcType=BIGINT},
+          #{item.createTime, jdbcType=TIMESTAMP},
+          #{item.updateBy, jdbcType=BIGINT},
+          #{item.updateTime, jdbcType=TIMESTAMP},
+          #{item.delFlag, jdbcType=INTEGER}
+        </trim>
+      </foreach>
+  </insert>
+
+
+  <select id="findAllByUserId" resultType="com.sckw.system.model.KwsUserLogin">
+    select *
+      from kws_user_login
+     where user_id = #{userId}
+     <if test="startTime != null">
+       and create_time >= #{startTime}
+     </if>
+     <if test="endTime != null">
+       and create_time &lt;= #{endTime}
+     </if>
+     order by create_time desc
+  </select>
+
+  <select id="currentDayLogin" resultType="com.sckw.system.model.KwsUserLogin">
+    select *
+      from kws_user_login
+     where user_id = #{userId}
+       and create_time >= current_date()
+     order by create_time
+     limit 1
+  </select>
+</mapper>