24282 2 tahun lalu
induk
melakukan
63984b8053

+ 13 - 0
hx-base/src/main/java/com/fjhx/base/system/SysLoginController.java

@@ -1,6 +1,9 @@
 package com.fjhx.base.system;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.fjhx.tenant.entity.tenant.po.TenantInfo;
+import com.fjhx.tenant.service.tenant.TenantInfoService;
+import com.ruoyi.common.annotation.TenantIgnore;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.DatasourceConstant;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -42,16 +46,25 @@ public class SysLoginController {
     @Autowired
     private HttpServletRequest request;
 
+    @Autowired
+    private TenantInfoService tenantInfoService;
+
     /**
      * 登录方法
      *
      * @param loginBody 登录信息
      * @return 结果
      */
+    @TenantIgnore
     @PostMapping("/login")
     public AjaxResult login(@RequestBody LoginBody loginBody) {
         String tenantId = request.getHeader("tenantId");
 
+        TenantInfo tenantInfo = tenantInfoService.getOne(q -> q.eq(TenantInfo::getTenantId, tenantId));
+        if (Objects.equals(tenantInfo.getStatus(), 0)) {
+            return AjaxResult.error("租户已被禁用");
+        }
+
         // 生成令牌
         String token = loginService.login(tenantId, loginBody.getUsername(), loginBody.getPassword(),
                 loginBody.getCode(), loginBody.getUuid());

+ 18 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@@ -1,6 +1,9 @@
 package com.ruoyi.web.controller.system;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.fjhx.tenant.entity.tenant.po.TenantInfo;
+import com.fjhx.tenant.service.tenant.TenantInfoService;
+import com.ruoyi.common.annotation.TenantIgnore;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.DatasourceConstant;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -41,16 +45,29 @@ public class SysLoginController {
     @Autowired
     private HttpServletRequest request;
 
+    @Autowired
+    private TenantInfoService tenantInfoService;
+
     /**
      * 登录方法
      *
      * @param loginBody 登录信息
      * @return 结果
      */
+    @TenantIgnore
     @PostMapping("/login")
     public AjaxResult login(@RequestBody LoginBody loginBody) {
         String tenantId = request.getHeader("tenantId");
 
+        TenantInfo tenantInfo = tenantInfoService.getOne(q -> q.eq(TenantInfo::getTenantId, tenantId));
+        if (tenantInfo == null) {
+            return AjaxResult.error("租户id不存在");
+        }
+
+        if (Objects.equals(tenantInfo.getStatus(), 0)) {
+            return AjaxResult.error("租户已被禁用");
+        }
+
         // 生成令牌
         String token = loginService.login(tenantId, loginBody.getUsername(), loginBody.getPassword(),
                 loginBody.getCode(), loginBody.getUuid());
@@ -60,6 +77,7 @@ public class SysLoginController {
         return ajax;
     }
 
+
     /**
      * 获取用户信息
      *

+ 37 - 30
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -24,7 +24,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"   column="update_time"  />
         <result property="remark"       column="remark"       />
 		<result property="tenantId" 	column="tenant_id"    />
-		<result property="jobNumber" column="job_number"	  />
+		<result property="jobNumber"    column="job_number"	  />
+		<result property="userType"     column="user_type"	  />
         <association property="dept"    column="dept_id" javaType="SysDept" resultMap="deptResult" />
         <collection  property="roles"   javaType="java.util.List"           resultMap="RoleResult" />
 	</resultMap>
@@ -90,41 +91,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</sql>
 
 	<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
-        select
-        u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
-        u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader_id,
-        d.director_id, d.type,u.job_number
-        from
-        sys_user u
-        left join sys_dept d on u.dept_id = d.dept_id
-        where u.del_flag = '0'
-        <if test="userId != null and userId != 0">
+		select
+		u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
+		u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader_id,
+		d.director_id, d.type,u.job_number,u.user_type
+		from
+		sys_user u
+		left join sys_dept d on u.dept_id = d.dept_id
+		where u.del_flag = '0'
+		<if test="userId != null and userId != 0">
             AND u.user_id = #{userId}
         </if>
         <if test="jobNumber != null and jobNumber != 0">
             AND u.job_number = #{jobNumber}
         </if>
         <if test="userName != null and userName != ''">
-            AND u.user_name like concat('%', #{userName}, '%')
-        </if>
-        <if test="status != null and status != ''">
-            AND u.status = #{status}
-        </if>
-        <if test="phonenumber != null and phonenumber != ''">
-            AND u.phonenumber like concat('%', #{phonenumber}, '%')
-        </if>
-        <if test="tenantId != null and tenantId != ''">
-            AND u.tenant_id = #{tenantId}
-        </if>
-        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-            AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-        </if>
-        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-            AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
-        </if>
-        <if test="deptId != null and deptId != 0">
-            AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
-            ancestors) ))
+			AND u.user_name like concat('%', #{userName}, '%')
+		</if>
+		<if test="status != null and status != ''">
+			AND u.status = #{status}
+		</if>
+		<if test="phonenumber != null and phonenumber != ''">
+			AND u.phonenumber like concat('%', #{phonenumber}, '%')
+		</if>
+		<if test="tenantId != null and tenantId != ''">
+			AND u.tenant_id = #{tenantId}
+		</if>
+		<if test="userType != null and userType != ''">
+			AND u.user_type = #{userType}
+		</if>
+		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
+			AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
+		</if>
+		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
+			AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+		</if>
+		<if test="deptId != null and deptId != 0">
+			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
+			ancestors) ))
         </if>
         <!-- 数据范围过滤 -->
         ${params.dataScope}
@@ -211,6 +215,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="tenantId != null and tenantId != ''">tenant_id,</if>
  			<if test="userType != null and userType != ''">user_type,</if>
  			<if test="jobNumber != null and jobNumber != ''">job_number,</if>
+		    <if test="userType != null and userType != ''">user_type,</if>
  			create_time
  		)values(
  			<if test="userId != null and userId != ''">#{userId},</if>
@@ -228,6 +233,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
  			<if test="userType != null and userType != ''">#{userType},</if>
  			<if test="jobNumber != null and jobNumber != ''">#{jobNumber},</if>
+		<if test="userType != null and userType != ''">#{userType},</if>
  			sysdate()
  		)
 	</insert>
@@ -251,6 +257,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
             <if test="userType != null and userType != ''">user_type = #{userType},</if>
             <if test="jobNumber != null and jobNumber != ''">job_number = #{jobNumber},</if>
+			<if test="userType != null and userType != ''">user_type = #{userType},</if>
             update_time = sysdate()
         </set>
         where user_id = #{userId}