Browse Source

修改密码

master
yangpeilai 1 month ago
parent
commit
01678490a5

+ 7
- 0
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/api/system/StaffController.java View File

@@ -118,4 +118,11 @@ public class StaffController extends MyValidController {
StaffListResponseDTO response = manager.staffList(dto);
return ApiResponse.of(response);
}

@ApiOperation("员工登录修改密码(只用新密码修改的)")
@PostMapping("/changePassword")
public ApiResponse changePassword(@Valid @RequestBody ChangePasswordRequestDTO dto) throws ManagerException {
manager.changePassword(dto);
return ApiResponse.success().setMessage("修改密码成功,请重新登录!");
}
}

+ 2
- 0
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/system/StaffManager.java View File

@@ -89,4 +89,6 @@ public interface StaffManager {
GetStaffInfoByOpenIdResponseDTO getinfobyopenid(GetStaffInfoByOpenIdRequestDTO dto) throws ServiceHandleException;

StaffListResponseDTO staffList(StaffListRequestDTO dto);

void changePassword(ChangePasswordRequestDTO dto) throws ManagerException;
}

+ 30
- 0
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/system/StaffManagerImpl.java View File

@@ -17,7 +17,9 @@ import cn.com.taiji.core.entity.user.AccountUserRole;
import cn.com.taiji.core.entity.user.Staff;
import cn.com.taiji.core.entity.user.UserRole;
import cn.com.taiji.core.manager.cache.RedisCacheManager;
import cn.com.taiji.core.manager.cache.RedisKeyGenerator;
import cn.com.taiji.core.manager.tools.DesensitizedUtil;
import cn.com.taiji.core.manager.tools.encryption.SM4Util;
import cn.com.taiji.core.manager.tools.minio.MinioUtil;
import cn.com.taiji.core.repo.jpa.basic.QtkAgencyRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallRepo;
@@ -547,6 +549,23 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager
return response;
}

@Override
public void changePassword(ChangePasswordRequestDTO dto) throws ManagerException {
AccountInfo accountInfo = findAccountInfoByToken(dto.getAccessToken());
if (accountInfo == null) throw new ManagerException("员工未注册");
if (!"1".equals(accountInfo.getNeedChangePasswordNow())) {
throw new ManagerException("当前用户不允许通过只输入新密码的方式修改密码!请更换其他的修改密码方式!");
}
if(!dto.getNewPassword().equals(dto.getAffirmNewPassword())){
throw new ManagerException("新密码和确认新密码不一致!");
}
accountInfo.setLoginPass(dto.getNewPassword());
accountInfo.setNeedChangePasswordNow("0");
accountInfo.setUpdateTime(LocalDateTime.now());
deleteTokenCache(dto.getAccessToken());
accountInfoRepo.save(accountInfo);
}

private boolean isMatch(RbacSource rbacSource, SystemType systemType) {
switch (rbacSource) {
case APP:
@@ -561,4 +580,15 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager
return false;
}
}

public static void main(String[] args) {
String s = "4aeb49ace971354d6fff839b804a63b5861f04074bb561f09364860d9113c62a";
String s1 = "17610023822";
try {
System.out.println(SM4Util.decrypt(s));
System.out.println(SM4Util.encrypt(s1));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

Loading…
Cancel
Save