ソースを参照

15天限制登录

LIVE_YE 2 年 前
コミット
d529d3311c

+ 32 - 0
boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteLoginInforService.java

@@ -0,0 +1,32 @@
+package com.boman.system.api;
+
+import com.boman.domain.SysUser;
+import com.boman.domain.constant.ServiceNameConstants;
+import com.boman.domain.dto.AjaxResult;
+import com.boman.domain.dto.R;
+import com.boman.system.api.factory.RemoteUserFallbackFactory;
+import com.boman.system.api.model.LoginUser;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+/**
+ * 登录记录
+ * 
+ * @author ruoyi
+ */
+@FeignClient(contextId = "remoteLoginInforService", value = ServiceNameConstants.SYSTEM_LOGININFOR)
+public interface RemoteLoginInforService
+{
+    /**
+     * 判断该用户名最后登录时间是否超过15天,返回值 大于0 则15天内登录过
+     * @param userName
+     * @return
+     */
+    @GetMapping("/logininfor/getLastLogininfor/{userName}")
+    Integer getLastLogininfor(@PathVariable("userName") String userName);
+}

+ 0 - 8
boman-api/boman-api-wechat/src/main/java/com/boman/wechat/api/RemoteWechatService.java

@@ -19,14 +19,6 @@ public interface RemoteWechatService {
     AjaxResult getWechatInfo(@RequestBody LoginBody loginBody);
 
 
-    /**
-     * 判断该用户名最后登录时间是否超过15天,返回值 大于0 则15天内登录过
-     * @param userName
-     * @return
-     */
-    @GetMapping("/logininfor/getLastLogininfor/{userName}")
-    Integer getLastLogininfor(@PathVariable("userName") String userName);
-
     /**
      * 发送消息
      *

+ 5 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/constant/ServiceNameConstants.java

@@ -17,6 +17,11 @@ public class ServiceNameConstants
      */
     public static final String SYSTEM_SERVICE = "boman-system";
 
+    /**
+     * 系统模块的serviceid
+     */
+    public static final String SYSTEM_LOGININFOR = "boman-loginInfor";
+
     /**
      * 文件服务的serviceid
      */

+ 4 - 3
boman-auth/src/main/java/com/boman/auth/service/SysLoginService.java

@@ -3,6 +3,7 @@ package com.boman.auth.service;
 import com.boman.common.redis.service.RedisService;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.form.LoginBody;
+import com.boman.system.api.RemoteLoginInforService;
 import com.boman.wechat.api.RemoteWechatService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -39,7 +40,7 @@ public class SysLoginService {
     @Autowired
     private RedisService redisService;
     @Resource
-    private RemoteWechatService remoteWechatService;
+    private RemoteLoginInforService remoteLoginInforService;
 
     @Value("${upkeep}")
     private Boolean upKeep;
@@ -89,7 +90,7 @@ public class SysLoginService {
 
         //判断15天内是否登录过 大于0 登录过
         if (!"admin".equals(username)){
-            Integer lastLogininforCount = remoteWechatService.getLastLogininfor(username);
+            Integer lastLogininforCount = remoteLoginInforService.getLastLogininfor(username);
             if (lastLogininforCount < 1){
                 //设置用户停用
                 remoteUserService.updateStatus(user);
@@ -137,7 +138,7 @@ public class SysLoginService {
         }
         //判断15天内是否登录过 大于0 登录过
         if (!"admin".equals(userName)) {
-            Integer lastLogininforCount = remoteWechatService.getLastLogininfor(userName);
+            Integer lastLogininforCount = remoteLoginInforService.getLastLogininfor(userName);
             if (lastLogininforCount < 1) {
                 //设置用户停用
                 remoteUserService.updateStatus(user);

+ 3 - 2
boman-wechat/src/main/java/com/boman/wechat/controller/AppletLoginController.java

@@ -20,6 +20,7 @@ import com.boman.domain.dto.AppletSessionDTO;
 import com.boman.domain.dto.R;
 import com.boman.system.api.RemoteDeptService;
 import com.boman.system.api.RemoteLogService;
+import com.boman.system.api.RemoteLoginInforService;
 import com.boman.system.api.RemoteUserService;
 import com.boman.system.api.model.LoginUser;
 import com.boman.wechat.api.RemoteWechatService;
@@ -67,7 +68,7 @@ public class AppletLoginController {
     @Resource
     private RemoteDeptService remoteDeptService;
     @Resource
-    private RemoteWechatService remoteWechatService;
+    private RemoteLoginInforService remoteLoginInforService;
 
     @Value("${upkeep}")
     private Boolean upKeep;
@@ -90,7 +91,7 @@ public class AppletLoginController {
         String userName = user.getUserName();
         //判断15天内是否登录过 大于0 登录过
         if (!"admin".equals(userName)) {
-            Integer lastLogininforCount = remoteWechatService.getLastLogininfor(userName);
+            Integer lastLogininforCount = remoteLoginInforService.getLastLogininfor(userName);
             if (lastLogininforCount < 1) {
                 //设置用户停用
                 remoteUserService.updateStatus(user);