|
|
@@ -51,6 +51,8 @@ public class SystemServiceImpl implements SystemService {
|
|
|
@Value("${jwt.expiration-time}")
|
|
|
private String effectiveTime;
|
|
|
|
|
|
+ private final String defaultPassword = "123456";
|
|
|
+
|
|
|
@Override
|
|
|
public SystemLoginVo login(String username, String password) {
|
|
|
int effectiveTimeInt = Integer.parseInt(effectiveTime.substring(0, effectiveTime.length() - 1));
|
|
|
@@ -176,7 +178,7 @@ public class SystemServiceImpl implements SystemService {
|
|
|
lifeSys.setEmail(addDto.getEmail());
|
|
|
// 密码使用MD5加密后存储
|
|
|
// lifeSys.setUserPassword(encryptToMD5(addDto.getPassword()));
|
|
|
- lifeSys.setUserPassword("123456");
|
|
|
+ lifeSys.setUserPassword(defaultPassword);
|
|
|
|
|
|
// 不再将角色ID保存到life_sys表的role_id字段,而是保存到中间关系表
|
|
|
// lifeSys.setRoleId(addDto.getRoleIds());
|
|
|
@@ -389,6 +391,32 @@ public class SystemServiceImpl implements SystemService {
|
|
|
return R.fail("修改状态失败,请稍后重试");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R resetPassword(Integer userId) {
|
|
|
+ // 校验用户ID
|
|
|
+ if (userId == null) {
|
|
|
+ return R.fail("用户ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询用户是否存在
|
|
|
+ LifeSys lifeSys = lifeSysMapper.selectById(userId);
|
|
|
+ if (lifeSys == null) {
|
|
|
+ return R.fail("用户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置密码为默认值(例如 "123456")
|
|
|
+ lifeSys.setUserPassword(defaultPassword);
|
|
|
+
|
|
|
+ // 执行更新
|
|
|
+ int result = lifeSysMapper.updateById(lifeSys);
|
|
|
+ if (result > 0) {
|
|
|
+ // 清除密码信息,避免返回到前端
|
|
|
+ lifeSys.setUserPassword(null);
|
|
|
+ return R.data(lifeSys, "密码重置成功,新密码为:" + defaultPassword);
|
|
|
+ }
|
|
|
+ return R.fail("密码重置失败,请稍后重试");
|
|
|
+ }
|
|
|
+
|
|
|
public static String encryptToMD5(String input) {
|
|
|
try {
|
|
|
// 获取 MD5 算法的 MessageDigest 实例
|