lihong пре 1 година
родитељ
комит
4cc1bfc33c

+ 7 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/WindowsController.java

@@ -3,6 +3,7 @@ package cn.hnthyy.thmz.controller.mz;
 import cn.hnthyy.thmz.Utils.HttpUtil;
 import cn.hnthyy.thmz.Utils.JsonUtil;
 import cn.hnthyy.thmz.Utils.MacAddressUtil;
+import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.thmz.User;
@@ -12,6 +13,7 @@ import com.auth0.jwt.interfaces.DecodedJWT;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -92,6 +94,11 @@ public class WindowsController {
         }
     }
 
+    @GetMapping("/initWindowsCache")
+    public R initWindowsCache(){
+        windowsService.initWindowsCache();
+        return R.ok();
+    }
 
 
     /**

+ 3 - 0
src/main/java/cn/hnthyy/thmz/mapper/thmz/WindowsMapper.java

@@ -85,6 +85,9 @@ public interface WindowsMapper {
             "<when test='updateDate!=null'>",
             ",update_date=#{updateDate,jdbcType=TIMESTAMP}",
             "</when>",
+            "<when test='updateDate!=null'>",
+            ",create_date=#{updateDate,jdbcType=TIMESTAMP}",
+            "</when>",
             "<when test='clientIpAddress!=null'>",
             ",client_ip_address=#{clientIpAddress}",
             "</when>",

+ 14 - 0
src/main/java/cn/hnthyy/thmz/service/impl/thmz/WindowsServiceImpl.java

@@ -1,11 +1,15 @@
 package cn.hnthyy.thmz.service.impl.thmz;
 
+import cn.hnthyy.thmz.Utils.Tools;
+import cn.hnthyy.thmz.entity.thmz.Config;
 import cn.hnthyy.thmz.entity.thmz.Windows;
+import cn.hnthyy.thmz.mapper.thmz.ConfigMapper;
 import cn.hnthyy.thmz.mapper.thmz.WindowsMapper;
 import cn.hnthyy.thmz.service.thmz.WindowsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -18,9 +22,13 @@ public class WindowsServiceImpl implements WindowsService {
     @SuppressWarnings("all")
     @Autowired
     private WindowsMapper windowsMapper;
+    @Resource
+    private ConfigMapper configMapper;
     @Override
     public int saveWindows(Windows windows) {
         map.remove(windows.getIpAddress());
+        Config config = configMapper.selectConfigByKey("thmz_group");
+        Tools.sendRefreshCacheService(config,"initWindowsCache");
         if(windows.getId()==null){
             return windowsMapper.insertUser(windows);
         }
@@ -28,6 +36,12 @@ public class WindowsServiceImpl implements WindowsService {
         return windowsMapper.updateWindows(windows);
     }
 
+
+    @Override
+    public void initWindowsCache() {
+        map.clear();
+    }
+
     @Override
     public Windows queryLastWindowsByUserIdCode(String userIdCode) {
         return windowsMapper.selectLastWindowsByUserIdCode(userIdCode);

+ 2 - 0
src/main/java/cn/hnthyy/thmz/service/thmz/WindowsService.java

@@ -11,6 +11,8 @@ public interface WindowsService {
      */
     int saveWindows(Windows windows);
 
+    void initWindowsCache();
+
     /**
      * 查询用户的最后一个在使用中的窗口号
      * @param userIdCode