瀏覽代碼

Merge branch 'master' of http://60.171.161.56:20000/tjf/jiaoyuju

wangmengwei 3 月之前
父節點
當前提交
ad96ce161d

+ 26 - 0
boman-api/boman-api-gen/src/main/java/com/boman/gen/api/RemoteLoadTableService.java

@@ -0,0 +1,26 @@
+package com.boman.gen.api;
+
+import com.boman.domain.GenTable;
+import com.boman.domain.constant.ServiceNameConstants;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+/**
+ * 生成代码模块,远程调用入口,如需其他接口,在此添加
+ *
+ * @author shiqian
+ * @date 2021年04月06日 14:22
+ **/
+@FeignClient(contextId = "remoteLoadTableService", value = ServiceNameConstants.GEN_SERVICE)
+public interface RemoteLoadTableService {
+
+    /**
+     * 功能描述: 查询代码生成列表,table中封装columnList
+     *
+     * @param genTable 查询条件
+     * @return AjaxResult
+     */
+    @GetMapping(value = "/init/loadTable")
+    void loadTable(GenTable genTable);
+}

+ 5 - 0
boman-auth/src/main/java/com/boman/auth/controller/TokenController.java

@@ -19,6 +19,8 @@ import com.boman.system.api.model.LoginUser;
 
 import java.util.Map;
 
+import static com.boman.common.core.utils.SecurityUtils.checkStrongPwd;
+
 /**
  * token 控制
  *
@@ -51,6 +53,9 @@ public class TokenController {
                 throw new BaseException("未获取到微信鉴权相关信息!");
             }
             openId = (String) jsonObject.get("openId");
+        }
+         if ("1".equals(checkStrongPwd(form.getPassword()))) {
+            return R.fail("密码必须包含数字、大小写字母、特殊符号且大于8位");
         }
         // 用户登录
         LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());

+ 111 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/PwdCheckUtil.java

@@ -0,0 +1,111 @@
+package com.boman.common.core.utils;
+
+/**
+ * @Author: tjf
+ * @Date: 2022/10/10 9:24
+ * @Describe:
+ */
+public class PwdCheckUtil {
+    //定义特殊字符
+    public static String SPECIAL_CHAR = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
+
+    /**
+     * @brief   检测密码中字符长度
+     * @param[in] password            密码字符串
+     * @return  符合长度要求 返回true
+     */
+    public static boolean checkPasswordLength(String password, String minNum, String maxNum) {
+        boolean flag =false;
+        if (StringUtils.isBlank(maxNum))  {
+            minNum = StringUtils.isBlank(minNum) ? "0":minNum;
+            if (password.length() >= Integer.parseInt(minNum)) {
+                flag = true;
+            }
+        } else {
+            minNum = StringUtils.isBlank(minNum) ? "0":minNum;
+            if (password.length() >= Integer.parseInt(minNum) &&
+                    password.length() <= Integer.parseInt(maxNum)) {
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    /**
+     * @brief   检测密码中是否包含数字
+     * @param[in] password            密码字符串
+     * @return  包含数字 返回true
+     */
+    public static boolean checkContainDigit(String password) {
+        char[] chPass = password.toCharArray();
+        for (int i = 0; i < chPass.length; i++) {
+            if (Character.isDigit(chPass[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * @brief   检测密码中是否包含字母(不区分大小写)
+     * @param[in] password            密码字符串
+     * @return  包含字母 返回true
+     */
+    public static boolean checkContainCase(String password) {
+        char[] chPass = password.toCharArray();
+        for (int i = 0; i < chPass.length; i++) {
+            if (Character.isLetter(chPass[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * @brief   检测密码中是否包含小写字母
+     * @param[in] password            密码字符串
+     * @return  包含小写字母 返回true
+     */
+    public static boolean checkContainLowerCase(String password) {
+        char[] chPass = password.toCharArray();
+        for (int i = 0; i < chPass.length; i++) {
+            if (Character.isLowerCase(chPass[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * @brief   检测密码中是否包含大写字母
+     * @param[in] password            密码字符串
+     * @return  包含大写字母 返回true
+     */
+    public static boolean checkContainUpperCase(String password) {
+        char[] chPass = password.toCharArray();
+        for (int i = 0; i < chPass.length; i++) {
+            if (Character.isUpperCase(chPass[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * @brief   检测密码中是否包含特殊符号
+     * @param[in] password            密码字符串
+     * @return  包含特殊符号 返回true
+     */
+    public static boolean checkContainSpecialChar(String password) {
+        char[] chPass = password.toCharArray();
+        for (int i = 0; i < chPass.length; i++) {
+            if (SPECIAL_CHAR.indexOf(chPass[i]) != -1) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 23 - 5
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/SecurityUtils.java

@@ -86,10 +86,28 @@ public class SecurityUtils
         BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
         return passwordEncoder.matches(rawPassword, encodedPassword);
     }
-
-    public static void main(String[] args) {
-        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
-        String encode = passwordEncoder.encode("123456");
-        System.out.println(encode);
+    /**
+     * @brief   检测密码复杂度是否为 强
+     * @param[in] password  密码字符串
+     * @return  符合长度要求 返回true
+     */
+    public static String checkStrongPwd(String pwd) {
+        try {
+            //如果密码为空返回1
+            if (StringUtils.isBlank(pwd)){
+                return "1";
+            }
+            if (!PwdCheckUtil.checkPasswordLength(pwd, "8", null)
+                    || !PwdCheckUtil.checkContainLowerCase(pwd)
+                    || !PwdCheckUtil.checkContainUpperCase(pwd)
+                    || !PwdCheckUtil.checkContainDigit(pwd)
+                    || !PwdCheckUtil.checkContainSpecialChar(pwd)
+            ) {
+                return "1";
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "0";
     }
 }

+ 5 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysProfileController.java

@@ -25,6 +25,8 @@ import com.boman.domain.SysUser;
 import com.boman.system.api.model.LoginUser;
 import com.boman.system.service.ISysUserService;
 
+import static com.boman.common.core.utils.SecurityUtils.checkStrongPwd;
+
 /**
  * 个人信息 业务处理
  * 
@@ -96,6 +98,9 @@ public class SysProfileController extends BaseController
         {
             return AjaxResult.error("新密码不能与旧密码相同");
         }
+        if ("1".equals(checkStrongPwd(user.getPassword()))) {
+            return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
+        }
         if (userService.resetUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0)
         {
             // 更新缓存用户密码

+ 35 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysUserController.java

@@ -30,6 +30,8 @@ import com.boman.domain.SysRole;
 import com.boman.domain.SysUser;
 import com.boman.system.api.model.LoginUser;
 
+import static com.boman.common.core.utils.SecurityUtils.checkStrongPwd;
+
 /**
  * 用户信息
  *
@@ -192,6 +194,8 @@ public class SysUserController extends BaseController {
         } else if (StringUtils.isNotEmpty(user.getEmail())
                 && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
             return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
+        }else if ("1".equals(checkStrongPwd(user.getPassword()))) {
+            return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
         }
         user.setCreateBy(SecurityUtils.getUsername());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
@@ -235,11 +239,42 @@ public class SysUserController extends BaseController {
     @PutMapping("/resetPwd")
     public AjaxResult resetPwd(@RequestBody SysUser user) {
 //        userService.checkUserAllowed(user);
+        if ("1".equals(checkStrongPwd(user.getPassword()))) {
+            return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
+        }
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         user.setUpdateBy(SecurityUtils.getUsername());
         return toAjax(userService.resetPwd(user));
     }
 
+    @PutMapping("/resetPwdLogin")
+    public AjaxResult resetPwdLogin(@RequestParam("userName") String userName,@RequestParam("oldPassword") String oldPassword,@RequestParam("newPassword") String newPassword) {
+        //userService.checkUserAllowed(user);
+        if ("admin".equals(userName)){
+            return AjaxResult.success("不允许操作超级管理员");
+        }
+        SysUser user = userService.selectUserByUserName(userName);
+        if (user == null){
+            return AjaxResult.success("当前用户不存在");
+        }
+        String password = user.getPassword();
+        if (!SecurityUtils.matchesPassword(oldPassword, password))
+        {
+            return AjaxResult.success("修改密码失败,旧密码错误");
+        }
+        if (SecurityUtils.matchesPassword(newPassword, password))
+        {
+            return AjaxResult.success("新密码不能与旧密码相同");
+        }
+
+        if ("1".equals(checkStrongPwd(newPassword))) {
+            return AjaxResult.success("密码必须包含数字、大小写字母、特殊符号且大于8位");
+        }
+        user.setPassword(SecurityUtils.encryptPassword(newPassword));
+        user.setUpdateBy(userName);
+        return toAjax(userService.resetPwdLogin(user));
+    }
+
     /**
      * 状态修改
      */

+ 2 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysUserMapper.java

@@ -56,6 +56,8 @@ public interface SysUserMapper
      */
     public int updateUser(SysUser user);
 
+    public int updateUserByUserName(SysUser user);
+
     /**
      * 修改用户头像
      * 

+ 8 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysUserService.java

@@ -143,6 +143,14 @@ public interface ISysUserService
      */
     public int resetPwd(SysUser user);
 
+    /**
+     * 登录页重置用户密码
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
+    public int resetPwdLogin(SysUser user);
+
     /**
      * 重置用户密码
      * 

+ 5 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysUserServiceImpl.java

@@ -323,6 +323,11 @@ public class SysUserServiceImpl implements ISysUserService
         return userMapper.updateUser(user);
     }
 
+    @Override
+    public int resetPwdLogin(SysUser user) {
+        return userMapper.updateUserByUserName(user);
+    }
+
     /**
      * 重置用户密码
      * 

+ 9 - 0
boman-modules/boman-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -168,6 +168,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		</set>
  		where id = #{id}
 	</update>
+
+	<update id="updateUserByUserName" parameterType="com.boman.domain.SysUser">
+		update sys_user
+		<set>
+			<if test="password != null and password != ''">password = #{password},</if>
+			update_time = sysdate()
+		</set>
+		where user_name = #{userName}
+	</update>
 	
 	<update id="updateUserStatus" parameterType="com.boman.domain.SysUser">
  		update sys_user set status = #{status} where id = #{id}

+ 5 - 0
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -22,6 +22,7 @@ import com.boman.domain.dto.*;
 import com.boman.domain.exception.NoSuchFunctionException;
 import com.boman.gen.api.RemoteGenTableColumnService;
 import com.boman.gen.api.RemoteGenTableService;
+import com.boman.gen.api.RemoteLoadTableService;
 import com.boman.jflow.api.RemoteJflowProcessService;
 import com.boman.system.api.RemoteMenuService;
 import com.boman.system.api.RemoteUserService;
@@ -104,6 +105,8 @@ public class TableServiceCmdService {
     private RemoteWechatService remoteWechatService;
     @Resource
     private MessageService messageService;
+    @Resource
+    private RemoteLoadTableService remoteLoadTableService;
 
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
@@ -406,6 +409,8 @@ public class TableServiceCmdService {
         List<String> showData = dto.getShowData();
         // 检查列
         checkColumn(showData, genTable.getColumns());
+        //处理之前,先刷新下缓存
+        remoteLoadTableService.loadTable(new GenTable());
         // 需要返回到前台的列, 需要判断是否是列表展示, 4为判断列表是否可见
         showData = filterData(columns, 4, showData, MaskConstant.LIST_VISIBLE::equals);
         // 表的id单独处理,不管mask,都查出来返给前台

+ 0 - 1
boman-web-core/src/main/java/com/boman/web/core/service/bomanMessageReceive/BomanMessageReceiveServiceImpl.java

@@ -9,7 +9,6 @@ import com.boman.domain.dto.UpdateDto;
 import com.boman.web.core.mapper.MessageMapper;
 import com.boman.web.core.service.common.ICommonService;
 import com.boman.web.core.service.select.IBaseSelectService;
-import com.sun.org.apache.regexp.internal.RE;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;