Selaa lähdekoodia

(注释状态)正则表达式加入字典表后代码修改

zhanghang 4 vuotta sitten
vanhempi
commit
ec76753725

+ 0 - 13
src/main/java/com/diagbot/facade/SysDictionaryFacade.java

@@ -61,17 +61,4 @@ public class SysDictionaryFacade extends SysDictionaryInfoServiceImpl {
         return res;
     }
 
-    /**
-     * 返回字典信息
-     *
-     * @return
-     */
-    public Map<Long, List<SysDictionaryInfoDTO>> getDictionaryRegex() {
-        List<SysDictionaryInfo> list = this.list(new QueryWrapper<SysDictionaryInfo>()
-                .in("return_type", ListUtil.arrayToList(new Long[] { 4L }))
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .orderByAsc("group_type", "order_no"));
-        List<SysDictionaryInfoDTO> listRes = BeanUtil.listCopyTo(list, SysDictionaryInfoDTO.class);
-        return EntityUtil.makeEntityListMap(listRes, "groupType");
-    }
 }

+ 24 - 20
src/main/java/com/diagbot/facade/SysUserFacade.java

@@ -145,7 +145,17 @@ public class SysUserFacade extends SysUserServiceImpl {
         /***
          * 未加密密码复杂度判断
          */
-//        Boolean passwordRegular = passwordRegular(password);
+        //获取用户医院id
+//        String hospitalID = SysUserUtils.getCurrentHospitalID();
+//        Long id = user.getId();
+//        QueryWrapper<SysUserHospital> UserHospitalQueryWrapper = new QueryWrapper<>();
+//        UserHospitalQueryWrapper
+//                .eq("user_id", id)
+//                .eq("is_deleted", IsDeleteEnum.N.getKey());
+//        SysUserHospital userHospital = sysUserHospitalFacade.getOne(UserHospitalQueryWrapper, false);
+//        Long hospitalId = userHospital.getHospitalId();
+//        String idStr = String.valueOf(hospitalId);
+//        Boolean passwordRegular = passwordRegular(password,idStr);
 //        if(!passwordRegular){
 //            data.setPasswordComplexity("密码复杂度过低,请及时修改密码");
 //        }
@@ -257,10 +267,6 @@ public class SysUserFacade extends SysUserServiceImpl {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
                     "原密码和新密码不能相同");
         }
-//        Boolean regularBoolean = passwordRegular(modifyPassword);
-//        if(!regularBoolean){
-//            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "请输入正确格式的新密码");
-//        }
         String userId = SysUserUtils.getCurrentPrincipleID();
         SysUser user = this.getOne(new QueryWrapper<SysUser>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
@@ -269,13 +275,16 @@ public class SysUserFacade extends SysUserServiceImpl {
         if (null == user) {
             throw new CommonException(ServiceErrorCode.USER_NOT_FOUND);
         }
-
         PasswordEncoder passwordEncoder
                 = PasswordEncoderFactories.createDelegatingPasswordEncoder();
         if (!passwordEncoder.matches(password, user.getPassword())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "原密码错误");
         }
-
+//        String hospitalID = SysUserUtils.getCurrentHospitalID();
+//        Boolean regularBoolean = passwordRegular(modifyPassword,hospitalID);
+//        if(!regularBoolean){
+//            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "请输入正确格式的新密码");
+//        }
         String entryPassword = passwordEncoder.encode(modifyPassword);
         user.setPassword(entryPassword);
         user.setGmtModified(DateUtil.now());
@@ -285,24 +294,19 @@ public class SysUserFacade extends SysUserServiceImpl {
     }
 
     /**
-     * 未加密密文正则表达式  至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符:
+     * 未加密密文正则表达式  至少8个字符,1个大写字母,1个小写字母,1个数字和1个特殊字符:
      * @param password
      * @return
      */
-    public Boolean passwordRegular(String password){
+    public Boolean passwordRegular(String password,String hospitalId){
         //获取字点表中存储的正则表达式   "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{8,}"
         boolean check=true;
-        Map<Long, List<SysDictionaryInfoDTO>> dictionaryRegex = sysDictionaryFacade.getDictionaryRegex();
-        if(dictionaryRegex!=null){
-            List<SysDictionaryInfoDTO> sysDictionaryInfoDTOS = dictionaryRegex.get(30L);
-            if(ListUtil.isNotEmpty(sysDictionaryInfoDTOS)) {
-                for (SysDictionaryInfoDTO sysDictionaryInfoDTO : sysDictionaryInfoDTOS) {
-                    String name = sysDictionaryInfoDTO.getName();
-                    if ("密码复杂度".equals(name)) {
-                        String val = sysDictionaryInfoDTO.getVal();
-                        check = password.matches(val);
-                    }
-                }
+        Map<String, Map<String, String>> dictionaryWithKey = sysDictionaryFacade.getDictionaryWithKey();
+        if(dictionaryWithKey!=null){
+            Map<String, String> stringStringMap = dictionaryWithKey.get("30");
+            if(stringStringMap!=null) {
+                String regular = stringStringMap.get(hospitalId);
+                check = password.matches(regular);
             }
         }
         return check;