From d0c0c232e4f1c5551619cae25a8c3a75fd232f4b Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 03 九月 2025 11:54:35 +0800
Subject: [PATCH] 加盟商设置是否隐藏

---
 ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java |   61 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
index e699be8..0b35774 100644
--- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
+++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
@@ -1,5 +1,7 @@
 package com.ruoyi.auth.service;
 
+import com.ruoyi.admin.api.entity.FranchiseeVO;
+import com.ruoyi.admin.api.feignClient.AdminClient;
 import com.ruoyi.common.core.constant.Constants;
 import com.ruoyi.common.core.constant.SecurityConstants;
 import com.ruoyi.common.core.constant.UserConstants;
@@ -13,6 +15,8 @@
 import com.ruoyi.system.api.model.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+
+import java.util.Objects;
 
 /**
  * 登录校验方法
@@ -29,6 +33,8 @@
 
     @Autowired
     private SysRecordLogService recordLogService;
+    @Autowired
+    private AdminClient adminClient;
 
     /**
      * 登录
@@ -65,6 +71,17 @@
 
         LoginUser userInfo = userResult.getData();
         SysUser user = userResult.getData().getSysUser();
+        if (user.getFranchiseeId() == null) {
+            userInfo.setIsFranchisee(Boolean.FALSE);
+        }else {
+            userInfo.setIsFranchisee(Boolean.TRUE);
+            // 查询加盟商信息
+            R<FranchiseeVO> franchiseeResult = adminClient.getFranchiseeInfo(user.getFranchiseeId());
+            FranchiseeVO franchiseeVO = franchiseeResult.getData();
+            if(Objects.nonNull(franchiseeVO)){
+                userInfo.setIsDisplay(franchiseeVO.getIsDisplay());
+            }
+        }
         if (UserStatus.DELETED.getCode().equals(user.getIsDelete())) {
             recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
             throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
@@ -76,6 +93,50 @@
         passwordService.validate(user, password);
         recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
         return userInfo;
+    }/**
+     * 登录
+     */
+    public LoginUser loginApp(String username) {
+        // 用户名或密码为空 错误
+        if (StringUtils.isAnyBlank(username)) {
+            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户必须填写");
+            throw new ServiceException("用户/密码必须填写");
+        }
+        // 用户名不在指定范围内 错误
+        if (username.length() < UserConstants.USERNAME_MIN_LENGTH
+                || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
+            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
+            throw new ServiceException("用户名不在指定范围");
+        }
+        // 查询用户信息
+        R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
+
+        if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
+            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
+            throw new ServiceException("登录用户:" + username + " 不存在");
+        }
+
+        if (R.FAIL == userResult.getCode()) {
+            throw new ServiceException(userResult.getMsg());
+        }
+
+        LoginUser userInfo = userResult.getData();
+        SysUser user = userResult.getData().getSysUser();
+        if (user.getFranchiseeId() == null) {
+            userInfo.setIsFranchisee(Boolean.FALSE);
+        }else {
+            userInfo.setIsFranchisee(Boolean.TRUE);
+        }
+        if (UserStatus.DELETED.getCode().equals(user.getIsDelete())) {
+            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
+            throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
+        }
+        if (!UserStatus.ENABLE.getCode().equals(user.getIsEnable())) {
+            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
+            throw new ServiceException("对不起,您的账号:" + username + " 已停用");
+        }
+        recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
+        return userInfo;
     }
 
     public void logout(String loginName) {

--
Gitblit v1.7.1