Explorar o código

Merge branch 'test-wks' into test

wks hai 1 ano
pai
achega
91a59f0a18

+ 1 - 0
src/main/java/com/ydtech/components/TokenInterceptor.java

@@ -30,6 +30,7 @@ public class TokenInterceptor {
 
         notMatchList.add("/captchaById"); // 验证码通过ID
         notMatchList.add("/login2");//登录2  配合验证码ID的校验
+        notMatchList.add("/system/login");//登录PC
         notMatchList.add("/aapLogin");//合伙人和机构负责人登录APP接口
         notMatchList.add("/loginAPPByPhone");//合伙人和机构负责人登录APP接口
 

+ 9 - 60
src/main/java/com/ydtech/modules/admin/controller/SysLoginController.java

@@ -91,6 +91,8 @@ public class SysLoginController {
 
     private final SysAgencyLeaderService sysAgencyLeaderService;
 
+    private final SysLoginService sysLoginService;
+
     @GetMapping("captcha.jpg")
     @ApiOperation(value = "获取验证码", produces = "application/octet-stream")
     public void captcha(HttpServletResponse response, HttpServletRequest request) throws IOException {
@@ -203,67 +205,14 @@ public class SysLoginController {
      */
     @PostMapping(value = "/login2")
     @ApiOperation(value = "登录2")
-    public HttpResult login2(@RequestBody LoginBean loginBean, HttpServletRequest request) {
-        String username = loginBean.getAccount();
-        String password = loginBean.getPassword();
-        String captcha = loginBean.getCaptcha();
-
-        String captchaId = loginBean.getCaptchaId();
-        if (StringUtils.isEmpty(captchaId)) return HttpResult.error("验证码不正确");
-
-        // 从redis中获取
-        String kaptcha = redisTemplate.opsForValue().get(captchaId);
-        log.info("登录校验验证码,redis取出的信息为:" + captchaId + ":" + kaptcha);
-        log.info("页面验证码:" + captcha + "===" + "redis验证码:" + kaptcha);
-        if (!captcha.equals(kaptcha)) {
-            return HttpResult.error("验证码不正确");
-        }
-//
-        // 用户信息
-        SysUser user = sysUserService.getById(username);
-        /**
-         *  多个系统登录  添加默认参数解决手机端登陆问题
-         * */
-        if (StringUtils.isBlank(loginBean.getSysId())) {
-            loginBean.setSysId("1");
-        }
-        if (!SysConstants.ADMIN.equalsIgnoreCase(username) && !"1".equals(loginBean.getSysId())) {
-            LambdaQueryWrapper<SysUserLinkSys> sysLambdaQueryWrapper = new LambdaQueryWrapper<>();
-            sysLambdaQueryWrapper.eq(SysUserLinkSys::getUserId, user.getId());
-            sysLambdaQueryWrapper.eq(SysUserLinkSys::getSysId, loginBean.getSysId());
-            List<SysUserLinkSys> list = sysUserLinkSysService.list(sysLambdaQueryWrapper);
-            if (list == null || list.size() == 0) {
-                throw new SystemException("该用户未授权");
-            }
-        }
-        SysUser sysUser = sysUserService.getByUserId(user.getId());
-        if ("2".equals(sysUser.getManagementSource())){
-            user.setIsLock(0);
-        }
-        //验证用户
-        SysUser.verifyUser(user);
-        SysPassword sysPassword = sysPasswordService.getOne(new LambdaQueryWrapper<SysPassword>().eq(SysPassword::getCode, SysPasswordEnum.GENERAL.getCode()));
-        // 万能密码设置
-        if (!"admin".equals(username) && PasswordUtils.matches(sysPassword.getSalt(), password,
-                sysPassword.getPassword())) {
-            log.info("万能密码登录系统");
-        } else {
-            if (!PasswordUtils.matches(user.getSalt(), password, user.getPassword())) {
-                return HttpResult.error("密码不正确");
-            }
-        }
-        //查询用户角色
-        SysRole sysRole = sysUserRoleService.gainRoleByUserId(user.getId());
-        //设置用户角色
-        user.setRoleId(sysRole.getId().toString());
-        user.setRoleName(sysRole.getName());
-        // 获取这个人的token
-        String token = StpUtil.createLoginSession(user.getId());
-        StpUtil.getSessionByLoginId(user.getId()).set(SaSession.USER, user);
-        // 保存登录信息
-        //sysUserService.saveLoginIpAddr(loginBean.getSystemType(),user);
-        return HttpResult.ok("登录成功", token);
+    public HttpResult login2(@RequestBody LoginBean loginBean) {
+        return sysLoginService.loginApp(loginBean);
+    }
 
+    @PostMapping(value = "/system/login")
+    @ApiOperation(value = "登录2")
+    public HttpResult loginPc(@RequestBody LoginBean loginBean) {
+        return sysLoginService.loginPC(loginBean);
     }
 
     /**

+ 31 - 0
src/main/java/com/ydtech/modules/admin/service/SysLoginService.java

@@ -0,0 +1,31 @@
+package com.ydtech.modules.admin.service;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.vo.LoginBean;
+
+/**
+ * @description: 系统登陆接口
+ * @author: wenks
+ * @date: 2025/6/6 14:20
+ **/
+public interface SysLoginService {
+
+    /**
+     * 登录App
+     *
+     * @param loginBean 登陆信息
+     * @return token
+     */
+    HttpResult<String> loginApp(LoginBean loginBean);
+
+
+    /**
+     * 登录PC
+     *
+     * @param loginBean 登陆信息
+     * @return token
+     */
+    HttpResult<String> loginPC(LoginBean loginBean);
+
+
+}

+ 46 - 20
src/main/java/com/ydtech/modules/admin/service/SysUserService.java

@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageResult;
+import com.ydtech.exception.SystemException;
 import com.ydtech.extension.BaseIService;
+import com.ydtech.modules.admin.constants.UserWorkStatus;
 import com.ydtech.modules.admin.model.QuTeamNum;
 import com.ydtech.modules.admin.model.QuUserNum;
 import com.ydtech.modules.admin.model.SysUser;
@@ -126,6 +128,7 @@ public interface SysUserService extends BaseIService<SysUser> {
     boolean saveUser(SysUser sysUser);
 
     HttpResult saveUserInfo(SysUser2Vo sysUserVo);
+
     SysUser saveUserJzgInfo(SysUser2Vo sysUserVo);
 
     HttpResult saveUserInfoByPartner(SysUser2Vo sysUserVo);
@@ -251,8 +254,10 @@ public interface SysUserService extends BaseIService<SysUser> {
      * @return
      */
     List<String> getTelemarketingPersonnelData();
+
     /**
      * 获取当前用户的下级所有人员
+     *
      * @return
      */
     List<SysUser> findNextTree();
@@ -264,29 +269,31 @@ public interface SysUserService extends BaseIService<SysUser> {
 
     /**
      * 获取当前用户的所有代理人
+     *
      * @return
      */
     List<SysUser> findNextAgentTree(String pid);
 
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/9/24 17:35
-     *  @Description:  查询电销的管理人列表
+     * @version
+     * @author: hxl
+     * @Date: 2024/9/24 17:35
+     * @Description: 查询电销的管理人列表
      */
     List<SysUser> findDxUserList(String type);
 
-    List<Map<String,String>>  selectHxUserList(SysUserDto sysUserDto);
+    List<Map<String, String>> selectHxUserList(SysUserDto sysUserDto);
 
     HttpResult cancelManagementPersonnel(UpdateManagementDto managementDto);
 
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/9/25 19:23
-     *  @Description: 查询用户管理的电销组员
+     * @version
+     * @author: hxl
+     * @Date: 2024/9/25 19:23
+     * @Description: 查询用户管理的电销组员
      */
     List<String> getGroupByUserId(String userId);
+
     /**
      * @version
      * @author: whp
@@ -297,6 +304,7 @@ public interface SysUserService extends BaseIService<SysUser> {
 
     /**
      * 获取人员数
+     *
      * @return
      */
     List<SysUser> getTreeUser();
@@ -307,7 +315,7 @@ public interface SysUserService extends BaseIService<SysUser> {
     /**
      * 个代注册
      *
-     * @param dto 注册dto
+     * @param dto         注册dto
      * @param recommender 推荐人信息
      * @return
      */
@@ -317,12 +325,13 @@ public interface SysUserService extends BaseIService<SysUser> {
      * 个代认证
      *
      * @param sysUser 用户信息
-     * @param dto 认证dto
+     * @param dto     认证dto
      */
     SysUserAgentVo agentAuth(SysUser sysUser, AgentAuthDto dto);
 
     /**
      * 个代(认证/审核)结果获取
+     *
      * @param sysUser
      * @param dto
      */
@@ -330,6 +339,7 @@ public interface SysUserService extends BaseIService<SysUser> {
 
     /**
      * 个代资料提交
+     *
      * @param sysUser
      * @param dto
      * @return
@@ -337,7 +347,6 @@ public interface SysUserService extends BaseIService<SysUser> {
     void agentSubmit(SysUser sysUser, AgentSubmitDto dto);
 
     /**
-     *
      * @param roleId 角色id
      * @param deptId 机构id
      * @return 用户信息
@@ -351,22 +360,39 @@ public interface SysUserService extends BaseIService<SysUser> {
     List<SysUser> selectByUserId(List<String> ids);
 
     HttpResult userLogout(String userId);
+
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2025/1/18 18:16
-     *  @Description: 转岗
+     * @version
+     * @author: hxl
+     * @Date: 2025/1/18 18:16
+     * @Description: 转岗
      */
     String transferPost(TransferUserVo transferUserVo);
 
 
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2025/1/21 9:31
-     *  @Description: 获取最大的id
+     * @version
+     * @author: hxl
+     * @Date: 2025/1/21 9:31
+     * @Description: 获取最大的id
      */
     String findNewMaxId(String deptId);
+
+
+    /**
+     * 校验用户是否在职
+     *
+     * @param id 用户id
+     * @return 用户
+     */
+    default SysUser judgmentIncumbency(String id) {
+        SysUser user = getById(id);
+        if (!UserWorkStatus.UWS_1.getCode().equals(user.getStatus())) {
+            throw new SystemException("审核未通过、请联系管理员");
+        }
+        return user;
+    }
+
 }
 
 

+ 126 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysLoginServiceImpl.java

@@ -0,0 +1,126 @@
+package com.ydtech.modules.admin.service.impl;
+
+import cn.dev33.satoken.session.SaSession;
+import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ydtech.constants.SysConstants;
+import com.ydtech.constants.sys.SysPasswordEnum;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.admin.constants.UserWorkStatus;
+import com.ydtech.modules.admin.model.SysPassword;
+import com.ydtech.modules.admin.model.SysRole;
+import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.admin.model.po.SysUserLinkSys;
+import com.ydtech.modules.admin.model.vo.LoginBean;
+import com.ydtech.modules.admin.service.*;
+import com.ydtech.security.utils.PasswordUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class SysLoginServiceImpl implements SysLoginService {
+
+    private final StringRedisTemplate redisTemplate;
+
+    private final SysUserService sysUserService;
+
+    private final SysUserLinkSysService sysUserLinkSysService;
+
+    private final SysPasswordService sysPasswordService;
+
+    private final SysUserRoleService sysUserRoleService;
+
+    @Override
+    public HttpResult<String> loginApp(LoginBean loginBean) {
+        this.verifyTheVerificationCode(loginBean);
+        String username = loginBean.getAccount();
+        String password = loginBean.getPassword();
+        // 用户信息
+        SysUser user = sysUserService.getById(username);
+        return getHttpResult(loginBean, username, user, password);
+    }
+
+
+    @Override
+    public HttpResult<String> loginPC(LoginBean loginBean) {
+        this.verifyTheVerificationCode(loginBean);
+        String username = loginBean.getAccount();
+        String password = loginBean.getPassword();
+        // 用户信息
+        SysUser user = sysUserService.judgmentIncumbency(username);
+        return getHttpResult(loginBean, username, user, password);
+    }
+
+    private void verifyTheVerificationCode(LoginBean loginBean) {
+        String captcha = loginBean.getCaptcha();
+        String captchaId = loginBean.getCaptchaId();
+        if (StringUtils.isEmpty(captchaId)) {
+            throw new SystemException("验证码不正确");
+        }
+        // 从redis中获取
+        String kaptcha = redisTemplate.opsForValue().get(captchaId);
+        log.info("登录校验验证码,redis取出的信息为:" + captchaId + ":" + kaptcha);
+        log.info("页面验证码:" + captcha + "===" + "redis验证码:" + kaptcha);
+        if (!captcha.equals(kaptcha)) {
+            throw new SystemException("验证码不正确");
+        }
+    }
+
+    private HttpResult<String> getHttpResult(LoginBean loginBean, String username, SysUser user, String password) {
+        /**
+         *  多个系统登录  添加默认参数解决手机端登陆问题
+         * */
+        if (StringUtils.isBlank(loginBean.getSysId())) {
+            loginBean.setSysId("1");
+        }
+        if (!SysConstants.ADMIN.equalsIgnoreCase(username) && !"1".equals(loginBean.getSysId())) {
+            LambdaQueryWrapper<SysUserLinkSys> sysLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            sysLambdaQueryWrapper.eq(SysUserLinkSys::getUserId, user.getId());
+            sysLambdaQueryWrapper.eq(SysUserLinkSys::getSysId, loginBean.getSysId());
+            List<SysUserLinkSys> list = sysUserLinkSysService.list(sysLambdaQueryWrapper);
+            if (list == null || list.isEmpty()) {
+                throw new SystemException("该用户未授权");
+            }
+        }
+
+        if ("2".equals(user.getManagementSource())) {
+            user.setIsLock(0);
+        }
+        //验证用户
+        SysUser.verifyUser(user);
+        SysPassword sysPassword = sysPasswordService
+                .lambdaQuery()
+                .eq(SysPassword::getCode, SysPasswordEnum.GENERAL.getCode())
+                .one();
+        // 万能密码设置
+        if (!"admin".equals(username) && PasswordUtils.matches(sysPassword.getSalt(), password,
+                sysPassword.getPassword())) {
+            log.info("万能密码登录系统");
+        } else {
+            if (!PasswordUtils.matches(user.getSalt(), password, user.getPassword())) {
+                return HttpResult.error("密码不正确");
+            }
+        }
+        //查询用户角色
+        SysRole sysRole = sysUserRoleService.gainRoleByUserId(user.getId());
+        //设置用户角色
+        user.setRoleId(sysRole.getId().toString());
+        user.setRoleName(sysRole.getName());
+        // 获取这个人的token
+        String token = StpUtil.createLoginSession(user.getId());
+        StpUtil.getSessionByLoginId(user.getId()).set(SaSession.USER, user);
+        // 保存登录信息
+        //sysUserService.saveLoginIpAddr(loginBean.getSystemType(),user);
+        return HttpResult.ok("登录成功", token);
+    }
+
+
+}

+ 3 - 0
src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java

@@ -178,6 +178,9 @@ public class QuoteVerificationAspect {
         Object[] args = point.getArgs();
         for (Object arg : args) {
             if (arg instanceof BaseQuoteVo) {
+                // 校验用户在职状态(审核通过之后才可以报价)
+                sysUserService.judgmentIncumbency(BaseController.getUserId());
+
                 String companyId = ((BaseQuoteVo<?>) arg).getCompanyId();
                 String agreementId = ((BaseQuoteVo<?>) arg).getAgreementId();
                 String orderno = ((BaseQuoteVo<?>) arg).getOrderNo();