瀏覽代碼

init: init project step4: biz code support

shc 1 年之前
父節點
當前提交
909dab8f63

+ 3 - 1
hnqz-auth/src/main/java/com/qunzhixinxi/hnqz/auth/service/HnqzUserDetailsServiceImpl.java

@@ -118,7 +118,9 @@ public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
                 user.getPlatId(),
                 user.getPlatId(),
                 user.getDrugEntId(),
                 user.getDrugEntId(),
                 info.getRoles(),
                 info.getRoles(),
-                user.getRealname());
+                user.getRealname(),
+                user.getLatestChangePwdTime());
+
     }
     }
 
 
 }
 }

+ 3 - 0
hnqz-common/hnqz-common-core/src/main/java/com/qunzhixinxi/hnqz/common/core/entity/BaseEntity.java

@@ -33,4 +33,7 @@ public abstract class BaseEntity implements Serializable {
 	// 创建
 	// 创建
 	public @interface Create {
 	public @interface Create {
 	}
 	}
+
+	public @interface Renew {
+	}
 }
 }

+ 10 - 1
hnqz-common/hnqz-common-security/src/main/java/com/qunzhixinxi/hnqz/common/security/component/HnqzUserAuthenticationConverter.java

@@ -1,6 +1,7 @@
 
 
 package com.qunzhixinxi.hnqz.common.security.component;
 package com.qunzhixinxi.hnqz.common.security.component;
 
 
+import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
 import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
@@ -19,6 +20,8 @@ import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map;
@@ -70,6 +73,12 @@ public class HnqzUserAuthenticationConverter implements UserAuthenticationConver
             if (StrUtil.isBlank(realName)) {
             if (StrUtil.isBlank(realName)) {
                 realName = MapUtil.getStr(map, "realname");
                 realName = MapUtil.getStr(map, "realname");
             }
             }
+            String changePwdTime = MapUtil.getStr(map, "latestChangePwdTime", "");
+            LocalDateTime latestChangePwdTime = null;
+            if (StrUtil.isNotBlank(changePwdTime)) {
+                latestChangePwdTime = LocalDateTime.parse(changePwdTime, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
+
+            }
             Integer id = MapUtil.getInt(map, SecurityConstants.DETAILS_USER_ID);
             Integer id = MapUtil.getInt(map, SecurityConstants.DETAILS_USER_ID);
             Integer deptId = MapUtil.getInt(map, SecurityConstants.DETAILS_DEPT_ID);
             Integer deptId = MapUtil.getInt(map, SecurityConstants.DETAILS_DEPT_ID);
             Integer tenantId = MapUtil.getInt(map, SecurityConstants.DETAILS_TENANT_ID);
             Integer tenantId = MapUtil.getInt(map, SecurityConstants.DETAILS_TENANT_ID);
@@ -80,7 +89,7 @@ public class HnqzUserAuthenticationConverter implements UserAuthenticationConver
 
 
 
 
             HnqzUser user = new HnqzUser(id, deptId, phone, avatar, tenantId, username, N_A, true, true, true, true,
             HnqzUser user = new HnqzUser(id, deptId, phone, avatar, tenantId, username, N_A, true, true, true, true,
-                    authorities, platId, drugEntId, null, realName);
+                    authorities, platId, drugEntId, null, realName, latestChangePwdTime);
             return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
             return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
         }
         }
         return null;
         return null;

+ 9 - 1
hnqz-common/hnqz-common-security/src/main/java/com/qunzhixinxi/hnqz/common/security/service/HnqzUser.java

@@ -6,6 +6,7 @@ import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.SpringSecurityCoreVersion;
 import org.springframework.security.core.SpringSecurityCoreVersion;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.User;
 
 
+import java.time.LocalDateTime;
 import java.util.Collection;
 import java.util.Collection;
 
 
 /**
 /**
@@ -63,6 +64,11 @@ public class HnqzUser extends User {
      */
      */
     private final Integer[] roles;
     private final Integer[] roles;
 
 
+    /**
+     * 最新更新密码时间
+     */
+    private final LocalDateTime latestChangePwdTime;
+
     /**
     /**
      * Construct the <code>User</code> with the details required by
      * Construct the <code>User</code> with the details required by
      * {@link DaoAuthenticationProvider}.
      * {@link DaoAuthenticationProvider}.
@@ -71,6 +77,7 @@ public class HnqzUser extends User {
      * @param deptId                部门ID
      * @param deptId                部门ID
      * @param tenantId              租户ID
      * @param tenantId              租户ID
      * @param realName              真实名称
      * @param realName              真实名称
+     * @param latestChangePwdTime   最新更新密码时间
      * @param username              the username presented to the
      * @param username              the username presented to the
      *                              <code>DaoAuthenticationProvider</code>
      *                              <code>DaoAuthenticationProvider</code>
      * @param password              the password that should be presented to the
      * @param password              the password that should be presented to the
@@ -88,7 +95,7 @@ public class HnqzUser extends User {
     public HnqzUser(Integer id, Integer deptId, String phone, String avatar, Integer tenantId, String username,
     public HnqzUser(Integer id, Integer deptId, String phone, String avatar, Integer tenantId, String username,
                     String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired,
                     String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired,
                     boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, String platId,
                     boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, String platId,
-                    Integer drugEntId, Integer[] roles, String realName) {
+                    Integer drugEntId, Integer[] roles, String realName, LocalDateTime latestChangePwdTime) {
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
         this.id = id;
         this.id = id;
         this.deptId = deptId;
         this.deptId = deptId;
@@ -99,6 +106,7 @@ public class HnqzUser extends User {
         this.drugEntId = drugEntId;
         this.drugEntId = drugEntId;
         this.roles = roles;
         this.roles = roles;
         this.realName = realName;
         this.realName = realName;
+        this.latestChangePwdTime = latestChangePwdTime;
     }
     }
 
 
 }
 }

+ 3 - 2
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/dto/UserPwd.java

@@ -1,5 +1,6 @@
 package com.qunzhixinxi.hnqz.admin.api.dto;
 package com.qunzhixinxi.hnqz.admin.api.dto;
 
 
+import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
 import lombok.Data;
 import lombok.Data;
 
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotEmpty;
@@ -11,10 +12,10 @@ public class UserPwd {
 	@NotEmpty(message = "用户名不能为空")
 	@NotEmpty(message = "用户名不能为空")
 	private String userName;
 	private String userName;
 
 
-	@NotEmpty(message = "新密码不能为空")
+	@NotEmpty(message = "新密码不能为空", groups = {BaseEntity.Renew.class})
 	private String p1;
 	private String p1;
 
 
-	@NotEmpty(message = "新密码不能为空")
+	@NotEmpty(message = "新密码不能为空", groups = {BaseEntity.Renew.class})
 	private String p2;
 	private String p2;
 
 
 	@NotEmpty(message = "验证码不能为空")
 	@NotEmpty(message = "验证码不能为空")

+ 5 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/SysUser.java

@@ -30,6 +30,11 @@ public class SysUser implements Serializable {
     @TableId(value = "user_id", type = IdType.AUTO)
     @TableId(value = "user_id", type = IdType.AUTO)
     private Integer userId;
     private Integer userId;
 
 
+    /**
+     * 最新更新密码时间
+     */
+    private LocalDateTime latestChangePwdTime;
+
     /**
     /**
      * 用户名
      * 用户名
      */
      */

+ 168 - 163
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/vo/UserVO.java

@@ -18,168 +18,173 @@ import java.util.List;
 @Data
 @Data
 public class UserVO implements Serializable {
 public class UserVO implements Serializable {
 
 
-	private static final long serialVersionUID = 1L;
-
-	/**
-	 * 主键ID
-	 */
-	private Integer userId;
-
-	/**
-	 * 用户名
-	 */
-	private String username;
-
-	/**
-	 * 身份证号
-	 */
-	private String idCardNumber;
-
-	/**
-	 * 密码
-	 */
-	private String password;
-
-	/**
-	 * 随机盐
-	 */
-	private String salt;
-
-	/**
-	 * 微信openid
-	 */
-	private String wxOpenid;
-
-	/**
-	 * QQ openid
-	 */
-	private String qqOpenid;
-
-	/**
-	 * 创建时间
-	 */
-	private LocalDateTime createTime;
-
-	/**
-	 * 修改时间
-	 */
-	private LocalDateTime updateTime;
-
-	/**
-	 * 0-正常,1-删除
-	 */
-	private String delFlag;
-
-	/**
-	 * 锁定标记
-	 */
-	private String lockFlag;
-
-	/**
-	 * 手机号
-	 */
-	@Sensitive(type = SensitiveTypeEnum.MOBILE_PHONE)
-	private String phone;
-
-	/**
-	 * 头像
-	 */
-	private String avatar;
-
-	/**
-	 * 部门ID
-	 */
-	private Integer deptId;
-
-	/**
-	 * 租户ID
-	 */
-	private Integer tenantId;
-
-	/**
-	 * 部门名称
-	 */
-	private String deptName;
-
-	/**
-	 * 用户姓名
-	 */
-	private String realname;
-
-	/**
-	 * 地址
-	 */
-	private String address;
-	/**
-	 * 备用字段1
-	 */
-	private String temp1;
-	/**
-	 * 备用字段2
-	 */
-	private String temp2;
-	/**
-	 * 备用字段3
-	 */
-	private String temp3;
-	/**
-	 * 备用字段4
-	 */
-	private String temp4;
-	/**
-	 * 备用字段5
-	 */
-	private String temp5;
-
-	/**
-	 * 备用字段5
-	 */
-	private String platId;
-
-	/**
-	 * 备用字段5
-	 */
-	private Integer drugEntId;
-
-	/**
-	 * 角色列表
-	 */
-	private List<SysRole> roleList;
-
-	/**
-	 * 备用字段5
-	 */
-	private String w1;
-
-	private String userSign;
-
-
-	/**
-	 * 小程序签署协议信息
-	 */
-	private String signAgreement;
-
-	/**
-	 * 是否提醒年龄超60周岁
-	 */
-	private Boolean ageReminder;
-
-	/**
-	 * 是否已补签协议
-	 */
-	private Integer reSignedAgreement;
-
-	@TableField(exist = false)
-	private List<WmQuizResultModel> quizResult;
-
-	/**
-	 * 上级主管
-	 */
-	private List<Integer> parentIdList;
-
-	/**
-	 * 区域代码
-	 */
-	private List<Long> areaCodes;
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    private Integer userId;
+
+    /**
+     * 用户名
+     */
+    private String username;
+
+    /**
+     * 最近更新密码时间
+     */
+    private LocalDateTime latestChangePwdTime;
+
+    /**
+     * 身份证号
+     */
+    private String idCardNumber;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 随机盐
+     */
+    private String salt;
+
+    /**
+     * 微信openid
+     */
+    private String wxOpenid;
+
+    /**
+     * QQ openid
+     */
+    private String qqOpenid;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 0-正常,1-删除
+     */
+    private String delFlag;
+
+    /**
+     * 锁定标记
+     */
+    private String lockFlag;
+
+    /**
+     * 手机号
+     */
+    @Sensitive(type = SensitiveTypeEnum.MOBILE_PHONE)
+    private String phone;
+
+    /**
+     * 头像
+     */
+    private String avatar;
+
+    /**
+     * 部门ID
+     */
+    private Integer deptId;
+
+    /**
+     * 租户ID
+     */
+    private Integer tenantId;
+
+    /**
+     * 部门名称
+     */
+    private String deptName;
+
+    /**
+     * 用户姓名
+     */
+    private String realname;
+
+    /**
+     * 地址
+     */
+    private String address;
+    /**
+     * 备用字段1
+     */
+    private String temp1;
+    /**
+     * 备用字段2
+     */
+    private String temp2;
+    /**
+     * 备用字段3
+     */
+    private String temp3;
+    /**
+     * 备用字段4
+     */
+    private String temp4;
+    /**
+     * 备用字段5
+     */
+    private String temp5;
+
+    /**
+     * 备用字段5
+     */
+    private String platId;
+
+    /**
+     * 备用字段5
+     */
+    private Integer drugEntId;
+
+    /**
+     * 角色列表
+     */
+    private List<SysRole> roleList;
+
+    /**
+     * 备用字段5
+     */
+    private String w1;
+
+    private String userSign;
+
+
+    /**
+     * 小程序签署协议信息
+     */
+    private String signAgreement;
+
+    /**
+     * 是否提醒年龄超60周岁
+     */
+    private Boolean ageReminder;
+
+    /**
+     * 是否已补签协议
+     */
+    private Integer reSignedAgreement;
+
+    @TableField(exist = false)
+    private List<WmQuizResultModel> quizResult;
+
+    /**
+     * 上级主管
+     */
+    private List<Integer> parentIdList;
+
+    /**
+     * 区域代码
+     */
+    private List<Long> areaCodes;
 
 
 }
 }

+ 18 - 3
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/SysUserController.java

@@ -9,7 +9,6 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.nacos.common.utils.Md5Utils;
 import com.alibaba.nacos.common.utils.Md5Utils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.pig4cloud.plugin.excel.annotation.RequestExcel;
 import com.pig4cloud.plugin.excel.annotation.RequestExcel;
@@ -39,6 +38,7 @@ import com.qunzhixinxi.hnqz.admin.service.SysUserService;
 import com.qunzhixinxi.hnqz.admin.service.WmPlatformQuizTestResultService;
 import com.qunzhixinxi.hnqz.admin.service.WmPlatformQuizTestResultService;
 import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
 import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
 import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
 import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
+import com.qunzhixinxi.hnqz.common.core.exception.BizException;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
 import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
 import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
 import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
@@ -264,7 +264,7 @@ public class SysUserController {
     }
     }
 
 
     /**
     /**
-     * 添加用户
+     * 修改密码
      *
      *
      * @param userPwd 用户信息
      * @param userPwd 用户信息
      * @return success/false
      * @return success/false
@@ -272,7 +272,22 @@ public class SysUserController {
     @Inner(value = false)
     @Inner(value = false)
     @SysLog("修改密码")
     @SysLog("修改密码")
     @PostMapping("/upd")
     @PostMapping("/upd")
-    public R<?> updatePwd(@RequestBody @Valid UserPwd userPwd) {
+    public R<?> updatePwd(@RequestBody @Validated UserPwd userPwd) {
+
+        return userService.updatePwd(userPwd);
+    }
+
+    /**
+     * 添加用户
+     *
+     * @param userPwd 用户信息
+     * @return success/false
+     */
+    @SysLog("更新密码")
+    @PostMapping("/pwd/renew")
+    public R<?> renewPwd(@RequestBody @Validated(BaseEntity.Renew.class) UserPwd userPwd) {
+
+        userPwd.setUserName(SecurityUtils.getUser().getUsername());
 
 
         return userService.updatePwd(userPwd);
         return userService.updatePwd(userPwd);
     }
     }

+ 6 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysUserServiceImpl.java

@@ -915,10 +915,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
 
     @Override
     @Override
     public R<?> updatePwd(UserPwd userPwd) {
     public R<?> updatePwd(UserPwd userPwd) {
+
         String p1 = userPwd.getP1();
         String p1 = userPwd.getP1();
         String p2 = userPwd.getP2();
         String p2 = userPwd.getP2();
         String userName = userPwd.getUserName();
         String userName = userPwd.getUserName();
+
         List<SysUser> userList = baseMapper.selectList(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, userName));
         List<SysUser> userList = baseMapper.selectList(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, userName));
+
         if (CollectionUtils.isEmpty(userList)) {
         if (CollectionUtils.isEmpty(userList)) {
             return R.failed("用户不存在");
             return R.failed("用户不存在");
         }
         }
@@ -926,10 +929,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         if (!p1.equals(p2)) {
         if (!p1.equals(p2)) {
             return R.failed("两次密码输入不一致");
             return R.failed("两次密码输入不一致");
         }
         }
+        LocalDateTime now = LocalDateTime.now();
         for (SysUser sysUser : userList) {
         for (SysUser sysUser : userList) {
             sysUser.setUserId(sysUser.getUserId());
             sysUser.setUserId(sysUser.getUserId());
             sysUser.setW1(Md5Utils.getMD5(p1.getBytes()));
             sysUser.setW1(Md5Utils.getMD5(p1.getBytes()));
             sysUser.setPassword(ENCODER.encode(p1));
             sysUser.setPassword(ENCODER.encode(p1));
+            sysUser.setLatestChangePwdTime(now);
+            sysUser.setUpdateTime(now);
             baseMapper.updateById(sysUser);
             baseMapper.updateById(sysUser);
         }
         }
 
 

+ 3 - 0
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysUserMapper.xml

@@ -6,6 +6,7 @@
         <id column="user_id" property="userId"/>
         <id column="user_id" property="userId"/>
         <result column="username" property="username"/>
         <result column="username" property="username"/>
         <result column="password" property="password"/>
         <result column="password" property="password"/>
+        <result column="latest_change_pwd_time" property="latestChangePwdTime"/>
         <result column="salt" property="salt"/>
         <result column="salt" property="salt"/>
         <result column="phone" property="phone"/>
         <result column="phone" property="phone"/>
         <result column="id_card_number" property="idCardNumber"/>
         <result column="id_card_number" property="idCardNumber"/>
@@ -36,6 +37,7 @@
         <id column="user_id" property="userId"/>
         <id column="user_id" property="userId"/>
         <result column="username" property="username"/>
         <result column="username" property="username"/>
         <result column="password" property="password"/>
         <result column="password" property="password"/>
+        <result column="latest_change_pwd_time" property="latestChangePwdTime"/>
         <result column="salt" property="salt"/>
         <result column="salt" property="salt"/>
         <result column="phone" property="phone"/>
         <result column="phone" property="phone"/>
         <result column="id_card_number" property="idCardNumber"/>
         <result column="id_card_number" property="idCardNumber"/>
@@ -72,6 +74,7 @@
         <id column="user_id" property="userId"/>
         <id column="user_id" property="userId"/>
         <result column="username" property="username"/>
         <result column="username" property="username"/>
         <result column="password" property="password"/>
         <result column="password" property="password"/>
+        <result column="latest_change_pwd_time" property="latestChangePwdTime"/>
         <result column="salt" property="salt"/>
         <result column="salt" property="salt"/>
         <result column="phone" property="phone"/>
         <result column="phone" property="phone"/>
         <result column="id_card_number" property="idCardNumber"/>
         <result column="id_card_number" property="idCardNumber"/>