From 0eb7042e584d800c84b1c77d1787cdc830b02a44 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 18 十月 2024 18:19:31 +0800
Subject: [PATCH] 最新版本541200007

---
 server/system_service/src/main/java/com/doumee/biz/system/impl/SystemUserBizImpl.java               |   27 ++++++++
 server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java                        |    2 
 server/system_service/src/main/java/com/doumee/core/utils/ScientificNotationTUtil.java              |   59 +++++++++++++++++++
 server/system_service/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java                         |    1 
 server/system_service/src/main/java/com/doumee/core/utils/PwdCheckUtil.java                         |   16 ++--
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java |    5 +
 server/system_service/src/main/java/com/doumee/dao/system/dto/UpdatePwdDto.java                     |    5 +
 server/system_service/src/main/java/com/doumee/api/cloud/SystemCloudController.java                 |    3 
 server/visits/dmvisit_admin/src/main/resources/application.yml                                      |    9 +++
 server/system_service/src/main/java/com/doumee/api/BaseController.java                              |    5 -
 10 files changed, 115 insertions(+), 17 deletions(-)

diff --git a/server/system_service/src/main/java/com/doumee/api/BaseController.java b/server/system_service/src/main/java/com/doumee/api/BaseController.java
index 3001582..9e3ab4a 100644
--- a/server/system_service/src/main/java/com/doumee/api/BaseController.java
+++ b/server/system_service/src/main/java/com/doumee/api/BaseController.java
@@ -30,8 +30,6 @@
 
     @Autowired
     private RedisTemplate<String,Object> stringRedisTemplate;
-    @Resource
-    private JwtProperties jwtProperties;
     /**
      * 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
      * @author Eva.Caesar Liu
@@ -51,9 +49,6 @@
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛鐧婚檰宸插け鏁堬紝璇烽噸鏂扮櫥闄嗭紒");
         }
         return  user;
-    }
-    public void updateLoginUser (String token,LoginUserInfo userInfo) {
-        stringRedisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+token,JSONObject.toJSONString(userInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS);
     }
 
 
diff --git a/server/system_service/src/main/java/com/doumee/api/cloud/SystemCloudController.java b/server/system_service/src/main/java/com/doumee/api/cloud/SystemCloudController.java
index eee029f..ef10c47 100644
--- a/server/system_service/src/main/java/com/doumee/api/cloud/SystemCloudController.java
+++ b/server/system_service/src/main/java/com/doumee/api/cloud/SystemCloudController.java
@@ -38,9 +38,10 @@
     public ApiResponse updatePwd (@RequestHeader(Constants.HEADER_USER_TOKEN) String token, @Validated @RequestBody UpdatePwdDto dto) {
         LoginUserInfo userInfo = this.getLoginUser(token);
         dto.setUserId(userInfo.getId());
+        dto.setToken(token);
+        dto.setLoginUserInfo(userInfo);
         systemUserBiz.updatePwd(dto);
         userInfo.setNeedChangePwd(Constants.ONE);
-        updateLoginUser(token,userInfo);//鏇存柊鐧诲綍token涓粦瀹氱殑鐢ㄦ埛淇℃伅涓哄凡鏇存柊瀵嗙爜
         return ApiResponse.success(null);
     }
 
diff --git a/server/system_service/src/main/java/com/doumee/biz/system/impl/SystemUserBizImpl.java b/server/system_service/src/main/java/com/doumee/biz/system/impl/SystemUserBizImpl.java
index 071fe85..20e8eda 100644
--- a/server/system_service/src/main/java/com/doumee/biz/system/impl/SystemUserBizImpl.java
+++ b/server/system_service/src/main/java/com/doumee/biz/system/impl/SystemUserBizImpl.java
@@ -1,9 +1,11 @@
 package com.doumee.biz.system.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.biz.system.SystemUserBiz;
+import com.doumee.config.jwt.JwtProperties;
 import com.doumee.core.annotation.excel.ExcelImporter;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.constants.ResponseStatus;
@@ -16,23 +18,31 @@
 import com.doumee.dao.system.dto.UpdatePwdDto;
 import com.doumee.dao.system.model.*;
 import com.doumee.service.system.*;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @Service
+@Slf4j
 public class SystemUserBizImpl implements SystemUserBiz {
-
+    @Autowired
+    private RedisTemplate<String,Object> redisTemplate;
+    @Autowired
+    private JwtProperties jwtProperties;
     @Autowired
     private SystemUserService systemUserService;
 
@@ -86,7 +96,7 @@
         if(StringUtils.isBlank(dto.getNewPwd())
                 ||dto.getNewPwd().length()>20
                 ||dto.getNewPwd().length()<6
-                ||PwdCheckUtil.checkPassword(dto.getNewPwd())){
+                ||!PwdCheckUtil.checkPassword(dto.getNewPwd())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝瀵嗙爜澶嶆潅搴︿笉婊¤冻瑕佹眰锛�6-20涓瓧绗︼紝鑷冲皯鍖呭惈瀛楁瘝銆佹暟瀛楀強鐗规畩瀛楃2绉�");
         }
         SystemUser user = systemUserService.findById(dto.getUserId());
@@ -103,6 +113,19 @@
         newUser.setPassword(Utils.Secure.encryptPassword(dto.getNewPwd(), user.getSalt()));
         newUser.setNeedChangePwd(Constants.ONE);
         systemUserService.updateById(newUser);
+
+        log.info("===================鏇存柊淇℃伅");
+        try {
+//            log.error("redisTemplate:["+redisTemplate+"]\njwtProperties=:["+jwtProperties+"]\n"+"token:["+dto.getToken()+"]\nuser:"+dto.getLoginUserInfo());
+            if(redisTemplate!=null&&dto.getToken() !=null &&dto.getLoginUserInfo()!=null && jwtProperties!=null){
+                dto.getLoginUserInfo().setNeedChangePwd(Constants.ONE);
+                redisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+dto.getToken(),JSONObject.toJSONString(dto.getLoginUserInfo()),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS);
+            }
+        }catch (Exception e){
+//            log.error("redisTemplate:["+redisTemplate+"]\njwtProperties=:["+jwtProperties+"]\n"+"token:["+dto.getToken()+"]\nuser:"+dto.getLoginUserInfo());
+            e.printStackTrace();
+        }
+
     }
 
     @Override
diff --git a/server/system_service/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java b/server/system_service/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java
index 9198e09..f88920c 100644
--- a/server/system_service/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java
+++ b/server/system_service/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java
@@ -150,6 +150,7 @@
         return token;
     }
 
+
     /**
      * 浠庝护鐗屼腑鑾峰彇鏁版嵁澹版槑,楠岃瘉JWT绛惧悕
      *
diff --git a/server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java b/server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java
index 8cc71b7..ba4a587 100644
--- a/server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java
+++ b/server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java
@@ -1,5 +1,6 @@
 package com.doumee.core.model;
 
+import com.doumee.core.utils.Constants;
 import com.doumee.dao.business.model.Company;
 import com.doumee.dao.system.model.SystemPermission;
 import com.doumee.dao.system.model.SystemRole;
@@ -66,6 +67,7 @@
                 rs.add(role.getCode());
             }
         }
+        loginUserInfo.setNeedChangePwd(Constants.formatIntegerNum(user.getNeedChangePwd()));
         loginUserInfo.setSessionId(sessionId);
         loginUserInfo.setRoles(rs);
         // 璁剧疆鏉冮檺淇℃伅
diff --git a/server/system_service/src/main/java/com/doumee/core/utils/PwdCheckUtil.java b/server/system_service/src/main/java/com/doumee/core/utils/PwdCheckUtil.java
index 8ecd514..e71f277 100644
--- a/server/system_service/src/main/java/com/doumee/core/utils/PwdCheckUtil.java
+++ b/server/system_service/src/main/java/com/doumee/core/utils/PwdCheckUtil.java
@@ -65,14 +65,14 @@
     }
 
     public static void main(String[] args) {
-        checkPassword("fasdagd");
-        checkPassword("41234123");
-        checkPassword("#$%^&&*(");
-        checkPassword("fasd$$");
-        checkPassword("41234%%%");
-        checkPassword("fasd41^(324");
-        checkPassword("fa413%^&*");
-        checkPassword("&%fa413%^&*");
+        checkPassword("123456a");
+//        checkPassword("41234123");
+//        checkPassword("#$%^&&*(");
+//        checkPassword("fasd$$");
+//        checkPassword("41234%%%");
+//        checkPassword("fasd41^(324");
+//        checkPassword("fa413%^&*");
+//        checkPassword("&%fa413%^&*");
     }
 
 }
\ No newline at end of file
diff --git a/server/system_service/src/main/java/com/doumee/core/utils/ScientificNotationTUtil.java b/server/system_service/src/main/java/com/doumee/core/utils/ScientificNotationTUtil.java
new file mode 100644
index 0000000..a40cae1
--- /dev/null
+++ b/server/system_service/src/main/java/com/doumee/core/utils/ScientificNotationTUtil.java
@@ -0,0 +1,59 @@
+package com.doumee.core.utils;
+
+import java.util.regex.Pattern;
+
+/**
+ * Java姝e垯鏍¢獙瀵嗙爜鑷冲皯鍖呭惈锛氬瓧姣嶆暟瀛楃壒娈婄鍙蜂腑鐨�2绉�
+ */
+import java.math.BigDecimal;
+import java.util.regex.Pattern;
+
+    public class ScientificNotationTUtil {
+        private static final Pattern SCIENTIFIC_NOTATION_PATTERN =
+                Pattern.compile("[+-]?\\d*(\\.\\d+)?[eE][+-]?\\d+");
+
+        public static boolean isScientificNotation(String value) {
+            return SCIENTIFIC_NOTATION_PATTERN.matcher(value).matches();
+        }
+
+        public static double convertScientificNotationToDouble(String scientificNotation) {
+            if (isScientificNotation(scientificNotation)) {
+                return (Double.parseDouble(scientificNotation));
+            } else {
+                throw new IllegalArgumentException("The string is not in scientific notation.");
+            }
+        }
+        public static String convertToString(String numberStr) {
+            try {
+                // 灏濊瘯鐩存帴灏嗗瓧绗︿覆杞崲涓築igDecimal
+                return new BigDecimal(numberStr)+"";
+            } catch (NumberFormatException e) {
+                // 濡傛灉杞崲澶辫触锛屽垯灏濊瘯瑙f瀽绉戝璁℃暟娉�
+                String[] parts = numberStr.split("E");
+                if (parts.length == 2) {
+                    // 杩欐槸绉戝璁℃暟娉曪紝闇�瑕佽浆鎹�
+                    BigDecimal number = new BigDecimal(parts[0]);
+                    int exponent = Integer.parseInt(parts[1]);
+                    return number.scaleByPowerOfTen(exponent)+"";
+                }
+            }
+            return  numberStr;
+        }
+
+        public static BigDecimal convertScientificNotationToBigDecimal(String scientificNotation) {
+            if (isScientificNotation(scientificNotation)) {
+                return new BigDecimal(scientificNotation);
+            } else {
+                throw new IllegalArgumentException("The string is not in scientific notation.");
+            }
+        }
+
+        public static void main(String[] args) {
+//            String scientificNotation = "1.23e+3";
+//            String scientificNotation = "1.5345690888E10";
+            String scientificNotation = "15345690888";
+            System.out.println("Is scientific notation: " + isScientificNotation(scientificNotation));
+            System.out.println("Converted to String: " + convertToString(scientificNotation));
+//            System.out.println("Converted to BigDecimal: " + convertScientificNotationToBigDecimal(scientificNotation));
+        }
+    }
\ No newline at end of file
diff --git a/server/system_service/src/main/java/com/doumee/dao/system/dto/UpdatePwdDto.java b/server/system_service/src/main/java/com/doumee/dao/system/dto/UpdatePwdDto.java
index a3e8001..9335e62 100644
--- a/server/system_service/src/main/java/com/doumee/dao/system/dto/UpdatePwdDto.java
+++ b/server/system_service/src/main/java/com/doumee/dao/system/dto/UpdatePwdDto.java
@@ -1,5 +1,6 @@
 package com.doumee.dao.system.dto;
 
+import com.doumee.core.model.LoginUserInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -16,6 +17,10 @@
 @ApiModel("淇敼瀵嗙爜鍙傛暟")
 public class UpdatePwdDto implements Serializable {
 
+    @ApiModelProperty(value = "loginUserInfo", hidden = true)
+    private LoginUserInfo loginUserInfo;
+    @ApiModelProperty(value = "token", hidden = true)
+    private String token;
     @ApiModelProperty(value = "鐢ㄦ埛ID", hidden = true)
     private Integer userId;
 
diff --git a/server/visits/dmvisit_admin/src/main/resources/application.yml b/server/visits/dmvisit_admin/src/main/resources/application.yml
index b09d0f7..a375639 100644
--- a/server/visits/dmvisit_admin/src/main/resources/application.yml
+++ b/server/visits/dmvisit_admin/src/main/resources/application.yml
@@ -74,5 +74,14 @@
   servlet:
     session:
       timeout: PT3H  #琛ㄧず12灏忔椂
+auth:
+  jwt:
+    enabled: true   #鏄惁寮�鍚疛WT鐧诲綍璁よ瘉鍔熻兘
+    secret: fjkfaf;afa  # JWT绉侀挜锛岀敤浜庢牎楠孞WT浠ょ墝鐨勫悎娉曟��
+    expiration: 36000000 #JWT浠ょ墝鐨勬湁鏁堟湡锛岀敤浜庢牎楠孞WT浠ょ墝鐨勫悎娉曟��
+    header: JWTHeaderName #HTTP璇锋眰鐨凥eader鍚嶇О锛岃Header浣滀负鍙傛暟浼犻�扟WT浠ょ墝
+    userParamName: username  #鐢ㄦ埛鐧诲綍璁よ瘉鐢ㄦ埛鍚嶅弬鏁板悕绉�
+    pwdParamName: password  #鐢ㄦ埛鐧诲綍璁よ瘉瀵嗙爜鍙傛暟鍚嶇О
+    useDefaultController: true # 鏄惁浣跨敤榛樿鐨凧wtAuthController
 
 
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
index 7316080..2785bef 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
@@ -167,6 +167,7 @@
         // 鐢熸垚瀵嗙爜
         user.setPassword(Utils.Secure.encryptPassword(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.INITIAL_PASSWORD).getCode(), salt));
         user.setSalt(salt);
+        user.setNeedChangePwd(Constants.ZERO);
         // 鍒涘缓鐢ㄦ埛璁板綍
         user.setType(insert.getType());
         user.setAvatar(insert.getFaceImg());
@@ -202,7 +203,7 @@
         insert.setCode(member.getCode());
         insert.setType(Constants.TWO);
         insert.setHkDate(new Date());
-        insert.setWorkStatus(Constants.ONE);//榛樿鍦ㄨ亴
+        insert.setWorkStatus(Constants.ZERO);//榛樿鍦ㄨ亴
         insert.setCanVisit(Constants.ZERO);//榛樿涓嶅彲璁块棶
         insert.setAuthStatus(Constants.ZERO);
         insert.setName(member.getName());
@@ -1856,6 +1857,8 @@
             List<Member> newList = new ArrayList<>();
             for(int i=0;i<dataList.size();i++){
                 MemberImport model = dataList.get(i);
+                model.setPhone(ScientificNotationTUtil.convertToString(model.getPhone()));
+                model.setIdcardNo(ScientificNotationTUtil.convertToString(model.getIdcardNo()));
                 if(StringUtils.isBlank(model.getName())
                        &&StringUtils.isBlank(model.getIdcardNo())
                         &&StringUtils.isBlank(model.getPhone())

--
Gitblit v1.9.3