he2802 2 سال پیش
والد
کامیت
b18b44c5fe

+ 18 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/user/UserController.java

@@ -4,7 +4,10 @@ import cn.hutool.core.lang.Validator;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.domain.entity.SysUser;
+import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.user.bo.*;
@@ -19,6 +22,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
@@ -139,4 +143,18 @@ public class UserController extends BaseController {
         bo.setUserId(loginUser.getUser().getUserId());
         return toAjax(iUserService.editShareActivityCode(bo) ? 1 : 0);
     }
+
+    @ApiOperation("检查密码修改时间")
+    @PreAuthorize("@ss.hasPermi('system:user:list')")
+    @GetMapping("/checkPwdTime")
+    public AjaxResult<Boolean> checkPwdTime()
+    {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        UserVo userVo = iUserService.queryById(loginUser.getUser().getUserId());
+        boolean needUpdate = false;
+        if(Validator.isNotEmpty(userVo.getPwdTime())&&(DateUtils.getNowTime().longValue()-userVo.getPwdTime().longValue())>90*24*3600){
+            needUpdate = true;
+        }
+        return AjaxResult.success(needUpdate);
+    }
 }

+ 8 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -868,7 +868,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         {
             throw new BaseException("新密码格式错误");
         }
+        if(!ToolsUtils.verifPwd(bo.getNewPwd())){
+            throw new CustomException("密码应由8-16位数字、大小写字母、符号组成");
+        }
         user.setPassword(SecurityUtils.encryptPassword(bo.getNewPwd()));
+        user.setPwdTime(DateUtils.getNowTime());
         user.setUpdateTime(DateUtils.getNowTime());
         updateById(user);
         return true;
@@ -1041,6 +1045,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         if(bo.getPwd()==null){
             throw new CustomException("密码不能为空");
         }
+        if(!ToolsUtils.verifPwd(bo.getPwd())){
+            throw new CustomException("密码应由8-16位数字、大小写字母、符号组成");
+        }
         String key = Constants.FORGET_SMS + bo.getTel();
         String code =  redisCache.getCacheObject(key);
         if(code==null){
@@ -1056,6 +1063,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
             throw new CustomException("该手机号未注册");
         }
         user.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
+        user.setPwdTime(DateUtils.getNowTime());
         user.setUpdateTime(DateUtils.getNowTime());
         return userService.updateById(user);
     }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserAddBo.java

@@ -155,4 +155,8 @@ public class UserAddBo {
     /** 分销邀请码 */
     @ApiModelProperty("分销邀请码")
     private String shareCode;
+
+    /** 密码最后修改时间 */
+    @ApiModelProperty("密码最后修改时间")
+    private Long pwdTime;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserEditBo.java

@@ -199,4 +199,8 @@ public class UserEditBo {
     /** 活动分销邀请码 */
     @ApiModelProperty("活动分销邀请码")
     private String shareActivityCode;
+
+    /** 密码最后修改时间 */
+    @ApiModelProperty("密码最后修改时间")
+    private Long pwdTime;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/User.java

@@ -220,4 +220,6 @@ private static final long serialVersionUID=1L;
     private String shareCode;
     /** 分销活动邀请码 */
     private String shareActivityCode;
+    /** 密码最后修改时间 */
+    private Long pwdTime;
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserVo.java

@@ -289,6 +289,11 @@ public class UserVo {
 	@ApiModelProperty("活动分销邀请码")
 	private String shareActivityCode;
 
+	/** 密码最后修改时间 */
+	@Excel(name = "密码最后修改时间")
+	@ApiModelProperty("密码最后修改时间")
+	private Long pwdTime;
+
 	public void setNull(){
 		this.setOpenId(null);
 		this.setIdCardImg1(null);

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserMapper.xml

@@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="lastStudyTime" column="last_study_time"/>
         <result property="job" column="job"/>
         <result property="shareCode" column="share_code"/>
+        <result property="pwdTime" column="pwd_time"/>
     </resultMap>