From 5525627950c1b4f9d70acc202a9083fb7e4d45de Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 16 七月 2024 13:44:10 +0800
Subject: [PATCH] 提交

---
 server/service/src/main/java/com/doumee/core/utils/DateUtil.java                    |    4 
 /dev/null                                                                           |   25 ------
 server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java                |   10 ++
 server/service/src/main/java/com/doumee/core/utils/tyyun/TyyZosUtil.java            |    5 +
 server/web/src/main/java/com/doumee/api/web/ApiController.java                      |   37 +++++++++
 server/service/src/main/java/com/doumee/core/utils/Constants.java                   |    5 +
 server/web/src/main/java/com/doumee/api/web/PersonnelApi.java                       |   12 ++-
 server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java |   39 ++++++++-
 server/service/src/main/java/com/doumee/core/utils/GeneratePicUtil.java             |   86 ++++++++++++++++++++-
 server/service/src/main/java/com/doumee/service/business/UsersService.java          |    3 
 10 files changed, 187 insertions(+), 39 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
index 00d3a0d..8fd806c 100644
--- a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
+++ b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -13,6 +13,7 @@
 import io.jsonwebtoken.JwtException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -40,6 +41,12 @@
 
     @Autowired
     private RedisTemplate<String,Object> redisTemplate;
+
+    /**
+     * 鏄惁寮�鍙戣��
+     */
+    @Value("${debug_model}")
+    private Boolean isDebug;
 
     /**
      * 娣诲姞鎷︽埅鍣�
@@ -121,6 +128,9 @@
     public Boolean checkPersonnelLogin(HttpServletRequest request, HttpServletResponse response){
         String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
         try {
+            if(isDebug){
+                return  true;
+            }
             //鍒ゆ柇Token鏄惁瓒呮椂
             boolean expiration = JwtTokenUtil.isTokenExpired(token);
             if (expiration) {
diff --git a/server/service/src/main/java/com/doumee/core/utils/Constants.java b/server/service/src/main/java/com/doumee/core/utils/Constants.java
index 8b19260..4841bbb 100644
--- a/server/service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -93,6 +93,9 @@
     public static final String ZBOM = "ZBOM" ;
     public static final String ZBOM_IAM_APPKEY = "ZBOM_IAM_APPKEY";
     public static final String ZBOM_IAM_APPID = "ZBOM_IAM_APPID";
+    public static final String USER_CARD_HEADER_IMG ="USER_CARD_HEADER_IMG" ;
+    public static final String USER_CARD_PHONE_IMG ="USER_CARD_PHONE_IMG" ;
+    public static final String USER_CARD_ADDR_IMG ="USER_CARD_ADDR_IMG" ;
 
     public static Integer parseIntByStr(String idtOrgStatus) {
         try {
@@ -309,6 +312,8 @@
     public static final String ACCESS_KEY = "ACCESS_KEY";
     public static final String ENDPOINT = "ENDPOINT";
     public static final String RESOURCE_PATH = "RESOURCE_PATH";
+    public static final String WEIXIN_DEFAULT_IMGS = "WEIXIN_DEFAULT_IMGS";
+    public static final String USER_CARD_DEFAULT_IMG = "USER_CARD_DEFAULT_IMG";
     public static final String USERS_FILE = "USERS_FILE";
     public static final String NEWS_FILE = "NEWS_FILE";
     //鍙戦�佷細璁紑濮�  瀹氭椂鎻愬墠澶氬皯鍒嗛挓鍙戦��
diff --git a/server/service/src/main/java/com/doumee/core/utils/DateUtil.java b/server/service/src/main/java/com/doumee/core/utils/DateUtil.java
index 2ccb323..ab78baa 100644
--- a/server/service/src/main/java/com/doumee/core/utils/DateUtil.java
+++ b/server/service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -356,7 +356,7 @@
      * @return String
      * @throws Exception
      */
-    public static String getNowShortDate() throws Exception {
+    public static String getNowShortDate() {
         String nowDate = "";
         try {
             java.sql.Date date = null;
@@ -364,7 +364,7 @@
             nowDate = sdfShort.format(date);
             return nowDate;
         } catch (Exception e) {
-            throw e;
+           return  "";
         }
     }
 
diff --git a/server/service/src/main/java/com/doumee/core/utils/GeneratePicUtil.java b/server/service/src/main/java/com/doumee/core/utils/GeneratePicUtil.java
index b6af5c6..c467fde 100644
--- a/server/service/src/main/java/com/doumee/core/utils/GeneratePicUtil.java
+++ b/server/service/src/main/java/com/doumee/core/utils/GeneratePicUtil.java
@@ -4,6 +4,7 @@
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileItemFactory;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.http.MediaType;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
@@ -43,8 +44,8 @@
         System.out.println("缁撴潫锛�" + (System.currentTimeMillis() - starttime) / 1000);
     }
 
-    private static final int width = 898;
-    private static final int height = 1308;
+    private static final int width = 750;
+    private static final int height = 1140;
 
     /**
      * 鐢熸垚鍒嗕韩鍥剧墖
@@ -195,7 +196,7 @@
         }
     }
 
-    public static InputStream bufferedImageToInputStream(BufferedImage backgroundImage) throws IOException {
+    public static InputStream bufferedImageToInputStream(BufferedImage backgroundImage) {
         return bufferedImageToInputStream(backgroundImage, "jpg");
     }
 
@@ -207,7 +208,7 @@
      * @return
      * @throws IOException
      */
-    public static InputStream bufferedImageToInputStream(BufferedImage backgroundImage, String format) throws IOException {
+    public static InputStream bufferedImageToInputStream(BufferedImage backgroundImage, String format)  {
         ByteArrayOutputStream bs = new ByteArrayOutputStream();
         try (
                 ImageOutputStream
@@ -215,6 +216,8 @@
             ImageIO.write(backgroundImage, format, imOut);
             InputStream is = new ByteArrayInputStream(bs.toByteArray());
             return is;
+        }catch (Exception e){
+            return null;
         }
     }
 
@@ -265,8 +268,83 @@
         }
         return resMatrix;
     }
+    public static InputStream generateUserCardImg(String imgurl, String qrcode, String name,String type, String phone, String shopaddr, String shopname,String phoneIcon,String addrIcon)  {
 
+        BufferedImage bi =  new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        //寰楀埌瀹冪殑缁樺埗鐜(杩欏紶鍥剧墖鐨勭瑪)
+        Graphics2D g2 = (Graphics2D) bi.getGraphics();
+        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+        g2.fillRect(0, 0, width, height);
+        //鑳屾櫙鍥剧墖
+        BufferedImage img1 =getImgIO(imgurl);
+        if(img1!=null){
+            g2.drawImage(img1, 0, 0, 750, 700, null);
+        }else{
+            g2.setColor(new Color(102, 102, 102, 1));
+            g2.drawRect( 0, 0, 750, 700);
+        }
 
+        //鍟嗗搧鍚嶇О
+        if(name.length()>5){
+            name = name.substring(0,5)+"...";
+        }
+        g2.setColor(Color.black);
+        g2.setFont(new Font("榛戜綋", Font.PLAIN, 40));
+        g2.drawString(name, 40, 990-242);
 
+        int w = 40+ name.length()*40;
+        g2.setColor(Color.GRAY);
+        g2.setFont(new Font("榛戜綋", Font.PLAIN, 30));
+        g2.drawString(type, w, 990-242);
+        if(StringUtils.isNotBlank(qrcode)){
+            //涓汉浜岀淮鐮�
+            BufferedImage img2 = getImgIO(qrcode);
+            if(img2!=null){
+                g2.drawImage(img2, 522, 982-242, 188, 188, null);
+            }
 
+            g2.setColor(Color.GRAY);
+            g2.setFont(new Font("榛戜綋", Font.PLAIN, 24));
+            g2.drawString("鎵爜娣诲姞濂藉弸", 544, 1186-242);
+        }
+        //鎵嬫満鍙�
+        BufferedImage img4 = getImgIO(phoneIcon);
+        if(img4!=null){
+            g2.drawImage(img4, 40, 1072-28-242, 34, 36, null);
+        }
+        g2.setColor(Color.GRAY);
+        g2.setFont(new Font("榛戜綋", Font.PLAIN, 30));
+        g2.drawString(phone, 94, 1072-242);
+
+        BufferedImage img3 = getImgIO(addrIcon);
+        if(img3!=null){
+            g2.drawImage(img3, 40, 1142-28-242, 34, 36, null);
+        }
+        if(shopaddr.length()>12){
+            shopaddr = shopaddr.substring(0,12)+"\n"+shopaddr.substring(12);
+        }
+        //鍦板潃
+        g2.setColor(Color.GRAY);
+        g2.setFont(new Font("榛戜綋", Font.PLAIN, 30));
+        g2.drawString(shopaddr, 94, 1142-242);
+
+        //搴曢儴
+        if(shopname.length()>15){
+            shopname = shopname.substring(0,15)+"...";
+        }
+        g2.setColor(Color.GRAY);
+        g2.setFont(new Font("榛戜綋", Font.PLAIN, 30));
+        g2.drawString(shopname, 180, 1300-242);
+
+        InputStream inputStream = bufferedImageToInputStream(bi);
+        return inputStream;
+    }
+
+    private static BufferedImage getImgIO(String imgurl) {
+        try {
+        return     ImageIO.read(new URL(imgurl));
+        }catch (Exception e){
+
+        }return null;
+    }
 }
diff --git a/server/service/src/main/java/com/doumee/core/utils/tyyun/TyyZosUtil.java b/server/service/src/main/java/com/doumee/core/utils/tyyun/TyyZosUtil.java
index cb8a032..16cbafd 100644
--- a/server/service/src/main/java/com/doumee/core/utils/tyyun/TyyZosUtil.java
+++ b/server/service/src/main/java/com/doumee/core/utils/tyyun/TyyZosUtil.java
@@ -9,14 +9,19 @@
 import com.amazonaws.services.s3.AmazonS3;
 import com.amazonaws.services.s3.AmazonS3ClientBuilder;
 import com.amazonaws.services.s3.model.*;
+import com.doumee.core.oss.FileContent;
+import com.doumee.core.oss.FileModel;
 import com.doumee.core.utils.FileDigest;
 
 import java.io.*;
 import java.net.URL;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+import com.doumee.core.utils.ID;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
diff --git a/server/service/src/main/java/com/doumee/service/business/UsersService.java b/server/service/src/main/java/com/doumee/service/business/UsersService.java
index 0aad93d..3467559 100644
--- a/server/service/src/main/java/com/doumee/service/business/UsersService.java
+++ b/server/service/src/main/java/com/doumee/service/business/UsersService.java
@@ -2,6 +2,7 @@
 
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.dao.business.model.Member;
 import com.doumee.dao.business.model.Users;
 import com.doumee.dao.web.response.AccountResponse;
 import org.springframework.web.multipart.MultipartFile;
@@ -107,4 +108,6 @@
     String importBatch(MultipartFile file);
 
     Users usersDetail(Long userId);
+
+    String getUserCard(Users users);
 }
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
index e92832d..509aafe 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
@@ -1,6 +1,7 @@
 package com.doumee.service.business.impl;
 
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import cn.hutool.core.date.DateUnit;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.biz.zbom.model.IamUserRoleModel;
 import com.doumee.biz.zbom.model.IamUserTypeModel;
@@ -13,7 +14,10 @@
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.DateUtil;
+import com.doumee.core.utils.GeneratePicUtil;
 import com.doumee.core.utils.Utils;
+import com.doumee.core.utils.tyyun.TyyZosUtil;
 import com.doumee.dao.admin.request.ShopImport;
 import com.doumee.dao.admin.request.UserImport;
 import com.doumee.dao.business.ShopMapper;
@@ -41,10 +45,8 @@
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.io.InputStream;
+import java.util.*;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -603,6 +605,35 @@
 
 
     @Override
+    public     String getUserCard(Users users){
+        String path = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.RESOURCE_PATH).getCode();
+        String folder = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.USERS_FILE).getCode();
+        String defualtHeader = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_HEADER_IMG).getCode();
+        String defualtPhone = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_PHONE_IMG).getCode();
+        String defualtAddr = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_ADDR_IMG).getCode();
+        String imgurl =StringUtils.isNotBlank(users.getImgurl())?path+users.getImgurl():defualtHeader;
+        String qrcode =StringUtils.isNotBlank(users.getQrcodeImg())?path+users.getQrcodeImg():null;
+        InputStream inputStream = GeneratePicUtil.generateUserCardImg(
+                imgurl
+                ,qrcode
+                ,StringUtils.defaultString(users.getName(),"-")
+                ,"瀵艰喘"
+                ,StringUtils.defaultString(users.getPhone(),"-")
+                ,StringUtils.defaultString(users.getShopAddress(),"-")
+                ,"ZBOM蹇楅偊瀹跺眳锝�"+ StringUtils.defaultString(users.getShopName(),"-")
+                ,defualtPhone
+                ,defualtAddr);
+        TyyZosUtil obs = new TyyZosUtil( systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.ENDPOINT).getCode(),
+                systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.ACCESS_ID).getCode(),
+                systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.ACCESS_KEY).getCode());
+        String fileName =folder+ DateUtil.getNowShortDate()+"/"+UUID.randomUUID().toString() + ".jpg";
+        if (obs.uploadInputstreamObject(inputStream,systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.BUCKETNAME).getCode(), fileName)) {
+            return  path+fileName;
+        }
+        return null;
+    }
+
+    @Override
     public Users usersDetail(Long userId){
         Users users = usersMapper.selectById(userId);
         if(Objects.isNull(users)){
diff --git a/server/web/src/main/java/com/doumee/api/web/ApiController.java b/server/web/src/main/java/com/doumee/api/web/ApiController.java
index f52186c..969c732 100644
--- a/server/web/src/main/java/com/doumee/api/web/ApiController.java
+++ b/server/web/src/main/java/com/doumee/api/web/ApiController.java
@@ -2,8 +2,13 @@
 
 import com.doumee.config.Jwt.JwtTokenUtil;
 import com.doumee.dao.business.model.Member;
+import com.doumee.dao.business.model.Users;
+import com.doumee.service.business.MemberService;
+import com.doumee.service.business.UsersService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.ss.formula.ptg.MemAreaPtg;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
@@ -17,6 +22,15 @@
 @Slf4j
 public class ApiController {
 
+    @Autowired
+    UsersService usersService;
+    @Autowired
+    MemberService memberService;
+    /**
+     * 鏄惁寮�鍙戣��
+     */
+    @Value("${debug_model}")
+    private Boolean isDebug;
 
     /**
      * 寰楀埌request瀵硅薄
@@ -38,6 +52,29 @@
         Object obj = this.getRequest().getAttribute(JwtTokenUtil.UserId_Name);
         return obj != null ? (Long) obj : null;
     }
+    protected Long getUserId() {
+        if(isDebug){
+            return 2L;
+        }
+        Object obj = this.getRequest().getAttribute(JwtTokenUtil.UserId_Name);
+        return obj != null ? (Long) obj : null;
+    }
+    protected Users getLoginUserInfo() {
+      Long userId = getUserId();
+      if(userId== null){
+          return null;
+      }
+        Users user = usersService.findById(userId);
+      return user;
+    }
+    protected Member getLoginMemberInfo() {
+      Long userId = getMemberId();
+      if(userId== null){
+          return null;
+      }
+        Member user = memberService.findById(userId);
+      return user;
+    }
 
 
     protected Long getUserType() {
diff --git a/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java b/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java
index b68354e..6b24bfd 100644
--- a/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java
@@ -15,10 +15,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * Created by IntelliJ IDEA.
@@ -86,4 +83,11 @@
         return  ApiResponse.success("鎿嶄綔鎴愬姛");
     }
 
+    @ApiOperation(value = "鑾峰彇涓汉鍚嶇墖", notes = "鍛樺伐绔皬绋嬪簭")
+    @PostMapping("/getUserCard")
+    public ApiResponse<String> getUserCard() {
+        return  ApiResponse.success(usersService.getUserCard(this.getLoginUserInfo()));
+    }
+
+
 }
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroAuthFilter.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroAuthFilter.java
deleted file mode 100644
index f978edf..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroAuthFilter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.doumee.config.shiro;
-
-import com.alibaba.fastjson.JSON;
-import com.doumee.core.model.ApiResponse;
-import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
-import org.springframework.http.HttpStatus;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Shiro璁よ瘉杩囨护鍣紝澶勭悊鏈璇佹儏鍐电殑鍝嶅簲
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-public class ShiroAuthFilter extends FormAuthenticationFilter {
-
-    public ShiroAuthFilter() {
-        super();
-    }
-
-    @Override
-    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
-        HttpServletResponse servletResponse = (HttpServletResponse) response;
-        servletResponse.setHeader("content-type", "application/json;charset=UTF-8");
-        servletResponse.getWriter().write(JSON.toJSONString(ApiResponse.failed(HttpStatus.UNAUTHORIZED.value(), "鏈櫥褰曟垨鐧诲綍淇℃伅宸茶繃鏈�")));
-        return Boolean.FALSE;
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroCache.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroCache.java
deleted file mode 100644
index 36cd7af..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroCache.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.doumee.config.shiro;
-
-import com.doumee.service.proxy.CacheProxy;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * Shiro缂撳瓨
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Scope(value = "prototype")
-@Slf4j
-@Component
-public class ShiroCache implements Cache<Object, Serializable> {
-
-    private String keyPrefix = "";
-
-    @Autowired
-    private CacheProxy<Object, Serializable> cacheProxy;
-
-    public ShiroCache () {
-        log.debug("ShiroCache: new, keyPrefix = [" + keyPrefix + "]");
-    }
-
-    public ShiroCache(String keyPrefix) {
-        log.debug("ShiroCache: new, keyPrefix = [" + keyPrefix + "]");
-        this.keyPrefix = keyPrefix;
-    }
-
-    @Override
-    public Serializable get(Object key) throws CacheException {
-        if (key == null) {
-            return null;
-        }
-        return cacheProxy.get(getKey(key));
-    }
-
-    @Override
-    public Serializable put(Object key, Serializable value) throws CacheException {
-        if (key == null) {
-            return null;
-        }
-        cacheProxy.put(getKey(key), value);
-        return value;
-    }
-
-    public Serializable put(Object key, Serializable value, int timeout) throws CacheException {
-        if (key == null) {
-            return null;
-        }
-        cacheProxy.put(getKey(key), value, timeout);
-        return value;
-    }
-
-    @Override
-    public void clear() throws CacheException {
-        Set<Object> keys = this.keys();
-        cacheProxy.remove(keys);
-    }
-
-    @Override
-    public int size() {
-        return this.keys().size();
-    }
-
-    @Override
-    public Set<Object> keys() {
-        Set<Object> keys = cacheProxy.keys(keyPrefix + "*");
-        if (CollectionUtils.isEmpty(keys)) {
-            return Collections.emptySet();
-        }
-        return keys;
-    }
-
-    @Override
-    public Collection<Serializable> values() {
-        Collection<Serializable> values = new ArrayList<>();
-        Set<Object> keys = this.keys();
-        if (CollectionUtils.isEmpty(keys)) {
-            return values;
-        }
-        for (Object k : keys) {
-            values.add(cacheProxy.get(k));
-        }
-        return values;
-    }
-
-    @Override
-    public Serializable remove(Object key) throws CacheException {
-        if (key == null) {
-            return null;
-        }
-        Serializable value = this.get(getKey(key));
-        cacheProxy.remove(getKey(key));
-        return value;
-    }
-
-    private Object getKey (Object key) {
-        return (key instanceof String ? (this.keyPrefix + key) : key);
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroCacheManager.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroCacheManager.java
deleted file mode 100644
index fedcb98..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroCacheManager.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.doumee.config.shiro;
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-import org.apache.shiro.cache.CacheManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Component;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * 鑷畾涔塖hiro CacheManager
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Slf4j
-@Component
-public class ShiroCacheManager implements CacheManager {
-
-    private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap();
-
-    private static ApplicationContext applicationContext;
-
-    @Override
-    public <K, V> Cache<K, V> getCache(String name) throws CacheException {
-        log.debug("get cache, name=" + name);
-        Cache cache = this.caches.get(name);
-        if (cache == null) {
-            cache = applicationContext.getBean(ShiroCache.class, "shiro:cache:");
-            this.caches.put(name, cache);
-        }
-        return cache;
-    }
-
-    @Autowired
-    public void setApplicationContext (ApplicationContext applicationContext) {
-        if (ShiroCacheManager.applicationContext == null) {
-            ShiroCacheManager.applicationContext = applicationContext;
-        }
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroConfig.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroConfig.java
deleted file mode 100644
index 86411e1..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroConfig.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.doumee.config.shiro;
-
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.session.mgt.SessionManager;
-import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
-import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
-import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
-import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import javax.servlet.Filter;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Shiro閰嶇疆
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Configuration
-public class ShiroConfig {
-
-    @Value("${cache.session.expire}")
-    private int sessionExpireTime;
-
-    @Autowired
-    private ShiroCredentialsMatcher shiroCredentialsMatcher;
-
-    @Autowired
-    private ShiroSessionDAO shiroSessionDAO;
-
-    @Autowired
-    private ShiroCacheManager shiroCacheManager;
-
-    @Autowired
-    private ShiroRealm shiroRealm;
-
-    @Bean
-    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
-        DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
-        autoProxyCreator.setProxyTargetClass(true);
-        return autoProxyCreator;
-    }
-
-    @Bean
-    public SessionManager sessionManager() {
-        ShiroSessionManager sessionManager = new ShiroSessionManager();
-        sessionManager.setSessionDAO(shiroSessionDAO);
-        return sessionManager;
-    }
-
-    @Bean
-    public SecurityManager securityManager() {
-        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
-        securityManager.setRealm(shiroRealm);
-        securityManager.setSessionManager(this.sessionManager());
-        securityManager.setCacheManager(shiroCacheManager);
-        return securityManager;
-    }
-
-    @Bean
-    public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
-        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
-        shiroFilterFactoryBean.setSecurityManager(securityManager);
-        Map<String, String> map = new LinkedHashMap<>();
-        // 璺緞鎷︽埅閰嶇疆
-        map.put("/system/login", "anon");
-        map.put("/system/logout", "anon");
-        map.put("/common/captcha", "anon");
-        map.put("/web/**", "anon");
-        //鏂囦欢涓婁紶鍙栨秷鎷︽埅
-        map.put("/public/**", "anon");
-        // - 鏀捐swagger
-        map.put("/doc.html", "anon");
-        map.put("/webjars/**", "anon");
-        map.put("/swagger-resources/**", "anon");
-        map.put("/v2/api-docs/**", "anon");
-        // - 鍏朵粬鎺ュ彛缁熶竴鎷︽埅
-        map.put("/**", "authc");
-        shiroFilterFactoryBean.setFilterChainDefinitionMap(map);
-        // 娣诲姞璁よ瘉杩囨护鍣�
-        Map<String, Filter> filters = new LinkedHashMap<>();
-        filters.put("authc", new ShiroAuthFilter());
-        shiroFilterFactoryBean.setFilters(filters);
-        return shiroFilterFactoryBean;
-    }
-
-    @Bean
-    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
-        AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
-        authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
-        return authorizationAttributeSourceAdvisor;
-    }
-
-    @Bean
-    public ShiroSessionDAO getShiroSessionDAO () {
-        shiroSessionDAO.setExpireTime(sessionExpireTime);
-        return shiroSessionDAO;
-    }
-
-    @Bean
-    public ShiroRealm getShiroRealm () {
-        shiroRealm.setCredentialsMatcher(shiroCredentialsMatcher);
-        return shiroRealm;
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java
deleted file mode 100644
index 75c5280..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.doumee.config.shiro;
-
-import com.doumee.core.utils.Utils;
-import com.doumee.dao.system.model.SystemUser;
-import com.doumee.service.system.SystemUserService;
-import org.apache.shiro.authc.AuthenticationInfo;
-import org.apache.shiro.authc.AuthenticationToken;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Component;
-
-/**
- * Shiro瀵嗙爜姣斿澶勭悊
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Component
-public class ShiroCredentialsMatcher extends HashedCredentialsMatcher {
-
-    @Lazy
-    @Autowired
-    private SystemUserService systemUserService;
-
-    @Override
-    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
-        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
-        SystemUser queryUserDto = new SystemUser();
-        queryUserDto.setUsername(usernamePasswordToken.getUsername());
-        queryUserDto.setDeleted(Boolean.FALSE);
-        SystemUser systemUser = systemUserService.findOne(queryUserDto);
-        if (systemUser == null) {
-            return Boolean.FALSE;
-        }
-        // 鍔犲瘑瀵嗙爜
-        String pwd = Utils.Secure.encryptPassword(new String(usernamePasswordToken.getPassword()), systemUser.getSalt());
-        // 姣旇緝瀵嗙爜
-        return this.equals(pwd, systemUser.getPassword());
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroRealm.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroRealm.java
deleted file mode 100644
index 690addf..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroRealm.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.doumee.config.shiro;
-
-import com.doumee.core.model.LoginUserInfo;
-import com.doumee.dao.system.model.SystemPermission;
-import com.doumee.dao.system.model.SystemRole;
-import com.doumee.dao.system.model.SystemUser;
-import com.doumee.service.system.SystemPermissionService;
-import com.doumee.service.system.SystemRoleService;
-import com.doumee.service.system.SystemUserService;
-import org.apache.shiro.authc.AuthenticationException;
-import org.apache.shiro.authc.AuthenticationInfo;
-import org.apache.shiro.authc.AuthenticationToken;
-import org.apache.shiro.authc.SimpleAuthenticationInfo;
-import org.apache.shiro.authz.AuthorizationInfo;
-import org.apache.shiro.authz.SimpleAuthorizationInfo;
-import org.apache.shiro.realm.AuthorizingRealm;
-import org.apache.shiro.subject.PrincipalCollection;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * 鑷畾涔塕ealm锛屽鐞嗚璇佸拰鏉冮檺
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Component
-public class ShiroRealm extends AuthorizingRealm {
-
-    @Lazy
-    @Autowired
-    private SystemUserService systemUserService;
-
-    @Lazy
-    @Autowired
-    private SystemRoleService systemRoleService;
-
-    @Lazy
-    @Autowired
-    private SystemPermissionService systemPermissionService;
-
-    /**
-     * 鏉冮檺澶勭悊
-     * @author Eva.Caesar Liu
-     * @date 2023/03/21 14:49
-     */
-    @Override
-    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
-        LoginUserInfo loginUserInfo = (LoginUserInfo)principalCollection.getPrimaryPrincipal();
-        // 璁剧疆鐢ㄦ埛瑙掕壊鍜屾潈闄�
-        SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
-        authorizationInfo.addRoles(loginUserInfo.getRoles());
-        authorizationInfo.addStringPermissions(loginUserInfo.getPermissions());
-        return authorizationInfo;
-    }
-
-    /**
-     * 璁よ瘉澶勭悊
-     * @author Eva.Caesar Liu
-     * @date 2023/03/21 14:49
-     */
-    @Override
-    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
-        // 鑾峰彇鐢ㄦ埛鍚�
-        String username = authenticationToken.getPrincipal().toString();
-        // 鏍规嵁鐢ㄦ埛鍚嶆煡璇㈢敤鎴峰璞�
-        SystemUser queryDto = new SystemUser();
-        queryDto.setUsername(username);
-        queryDto.setDeleted(Boolean.FALSE);
-        SystemUser user = systemUserService.findOne(queryDto);
-        if (user == null) {
-            return null;
-        }
-        // 鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅
-        List<SystemRole> roles = systemRoleService.findByUserId(user.getId());
-        List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId());
-        LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions);
-        // 楠岃瘉鐢ㄦ埛
-        return new SimpleAuthenticationInfo(userInfo, user.getPassword(), this.getName());
-    }
-
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroSessionDAO.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroSessionDAO.java
deleted file mode 100644
index 2cc6a11..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroSessionDAO.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.doumee.config.shiro;
-
-import lombok.Data;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.session.UnknownSessionException;
-import org.apache.shiro.session.mgt.SimpleSession;
-import org.apache.shiro.session.mgt.eis.SessionDAO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * 鑷畾涔塖hiro SessionDAO锛屽皢浼氳瘽淇℃伅瀛樺叆缂撳瓨涓�
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Data
-@Slf4j
-@Component
-public class ShiroSessionDAO implements SessionDAO {
-
-    private static final String KEY_PREFIX = "shiro:session:";
-
-    @Autowired
-    private ShiroCache shiroCache;
-
-    private int expireTime = 1800;
-
-    @Autowired
-    private ShiroTokenManager shiroTokenManager;
-
-    @Override
-    public Serializable create(Session session) {
-        if (session == null) {
-            log.error("session is null");
-            throw new UnknownSessionException("session is null");
-        }
-        Serializable sessionId = shiroTokenManager.build();
-        ((SimpleSession)session).setId(sessionId);
-        this.saveSession(session);
-        return sessionId;
-    }
-
-    @Override
-    public Session readSession(Serializable sessionId) throws UnknownSessionException{
-        if (sessionId == null) {
-            log.warn("session id is null");
-            return null;
-        }
-        if (sessionId instanceof String) {
-            // 瀵筍essionId杩涜楠岃瘉锛堝彲鐢ㄤ簬闃叉Session鎹曡幏銆佹毚鍔涙崟鎹夌瓑涓�绯诲垪瀹夊叏闂锛屾渶缁堝畨鍏ㄦ�у彇鍐充簬check濡備綍瀹炵幇锛�
-            shiroTokenManager.check((String) sessionId);
-        }
-        log.debug("read session from cache");
-        Session session = getSessionFromCache(sessionId);
-        if (session == null) {
-            throw new UnknownSessionException("There is no session with id [" + sessionId + "]");
-        }
-        return session;
-    }
-
-    @Override
-    public void update(Session session) throws UnknownSessionException {
-        this.saveSession(session);
-    }
-
-    @Override
-    public void delete(Session session) {
-        if (session != null && session.getId() != null) {
-            shiroCache.remove(KEY_PREFIX + session.getId());
-        }
-    }
-
-    @Override
-    public Collection<Session> getActiveSessions() {
-        Set<Session> sessions = new HashSet<>();
-        Set<Object> keys = shiroCache.keys();
-        if (keys != null && keys.size() > 0) {
-            Iterator iter = keys.iterator();
-            while(iter.hasNext()) {
-                sessions.add((Session) shiroCache.get(iter.next()));
-            }
-        }
-        return sessions;
-    }
-
-    private void saveSession(Session session) throws UnknownSessionException {
-        if (session == null || session.getId() == null) {
-            log.error("session or session id is null");
-            throw new UnknownSessionException("session or session id is null");
-        }
-        shiroCache.put(KEY_PREFIX + session.getId(), (SimpleSession)session, expireTime);
-    }
-
-    private Session getSessionFromCache (Serializable sessionId) {
-        Serializable object = shiroCache.get(KEY_PREFIX + sessionId);
-        Session session = null;
-        if (object != null) {
-            session = (Session)shiroCache.get(KEY_PREFIX + sessionId);
-        }
-        return session;
-    }
-
-    public void setExpireTime (int expireTime) {
-        this.expireTime = expireTime;
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroSessionManager.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroSessionManager.java
deleted file mode 100644
index ef159a7..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroSessionManager.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.doumee.config.shiro;
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.session.mgt.DefaultSessionManager;
-import org.apache.shiro.session.mgt.SessionContext;
-import org.apache.shiro.session.mgt.SessionKey;
-import org.apache.shiro.web.servlet.Cookie;
-import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
-import org.apache.shiro.web.servlet.SimpleCookie;
-import org.apache.shiro.web.session.mgt.WebSessionManager;
-import org.apache.shiro.web.util.WebUtils;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.Serializable;
-
-/**
- * 鑷畾涔変細璇濈鐞嗗櫒
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
-@Slf4j
-public class ShiroSessionManager extends DefaultSessionManager implements WebSessionManager {
-
-    private static final String AUTH_TOKEN = "eva-auth-token";
-
-    @Override
-    protected void onStart(Session session, SessionContext context) {
-        super.onStart(session, context);
-        if (!WebUtils.isHttp(context)) {
-            log.debug("SessionContext argument is not Http compatible or does not have an Http request/response pair. No session ID cookie will be set.");
-            return;
-        }
-        HttpServletRequest request = WebUtils.getHttpRequest(context);
-        HttpServletResponse response = WebUtils.getHttpResponse(context);
-        Serializable sessionId = session.getId();
-        this.storeSessionId(sessionId, request, response);
-        request.removeAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE);
-        request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_IS_NEW, Boolean.TRUE);
-    }
-
-    @Override
-    public Serializable getSessionId(SessionKey key) {
-        Serializable sessionId = super.getSessionId(key);
-        if (sessionId == null && WebUtils.isWeb(key)) {
-            ServletRequest servletRequest = WebUtils.getRequest(key);
-            if (!(servletRequest instanceof HttpServletRequest)) {
-                log.trace("Can not get sessionId from header, the request is not HttpServletRequest");
-                return null;
-            }
-            HttpServletRequest request = (HttpServletRequest) servletRequest;
-            // 浠巆ookie涓幏鍙栬璇�
-            javax.servlet.http.Cookie[] cookies = request.getCookies();
-            if (cookies != null) {
-                for (javax.servlet.http.Cookie cookie : cookies) {
-                    if (AUTH_TOKEN.equals(cookie.getName())) {
-                        return cookie.getValue();
-                    }
-                }
-            }
-            // 浠巋eader涓幏鍙栬璇�
-            return request.getHeader(AUTH_TOKEN);
-        }
-        return sessionId;
-    }
-
-    @Override
-    public boolean isServletContainerSessions() {
-        return false;
-    }
-
-    private void storeSessionId(Serializable currentId, HttpServletRequest request, HttpServletResponse response) {
-        if (currentId == null) {
-            String msg = "sessionId cannot be null when persisting for subsequent requests.";
-            throw new IllegalArgumentException(msg);
-        }
-        Cookie cookie = new SimpleCookie(AUTH_TOKEN);
-        cookie.setHttpOnly(false);
-        String idString = currentId.toString();
-        cookie.setValue(idString);
-        cookie.saveTo(request, response);
-        log.trace("Set session ID cookie for session with id {}", idString);
-    }
-}
diff --git a/server/web/src/main/java/com/doumee/config/shiro/ShiroTokenManager.java b/server/web/src/main/java/com/doumee/config/shiro/ShiroTokenManager.java
deleted file mode 100644
index d5f3b40..0000000
--- a/server/web/src/main/java/com/doumee/config/shiro/ShiroTokenManager.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.doumee.config.shiro;
-
-import com.doumee.core.exception.UnSafeSessionException;
-import org.springframework.stereotype.Component;
-
-import java.util.UUID;
-
-/**
- * 榛樿Token绠$悊鍣�
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49  36143 45311
- */
-@Component
-public class ShiroTokenManager {
-
-    String build() {
-        return UUID.randomUUID().toString();
-    }
-
-    void check(String token) throws UnSafeSessionException {
-        if (token == null || token.length() != 36) {
-            throw new UnSafeSessionException();
-        }
-    }
-}

--
Gitblit v1.9.3