|
@@ -1,22 +1,26 @@
|
|
|
package com.hz.employmentsite.services.impl;
|
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.hz.employmentsite.enums.DataRangeEnum;
|
|
|
+import com.hz.employmentsite.filter.exception.BaseException;
|
|
|
import com.hz.employmentsite.mapper.*;
|
|
|
import com.hz.employmentsite.mapper.cquery.SysUserCQuery;
|
|
|
import com.hz.employmentsite.model.*;
|
|
|
+import com.hz.employmentsite.services.service.AccountService;
|
|
|
import com.hz.employmentsite.services.service.UserService;
|
|
|
import com.hz.employmentsite.services.service.system.RoleService;
|
|
|
import com.hz.employmentsite.util.DateUtils;
|
|
|
import com.hz.employmentsite.util.StringUtils;
|
|
|
+import com.hz.employmentsite.util.ip.IpUtils;
|
|
|
import com.hz.employmentsite.vo.user.DataRange;
|
|
|
import com.hz.employmentsite.vo.user.UserEditVo;
|
|
|
import com.hz.employmentsite.vo.user.UserInfoModel;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.DigestUtils;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -44,6 +48,12 @@ public class UserServiceImpl implements UserService {
|
|
|
@Autowired
|
|
|
private RoleService roleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AccountService accountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysLogMapper sysLogMapper;
|
|
|
+
|
|
|
private String defaultPassword = "52653B706ADC444F6660FAB66D6DC210";//Hjy@2024
|
|
|
|
|
|
private String siteRoleId = "10a12f77-0958-4220-b9ce-07b9215046f2"; //驿站工作者
|
|
@@ -313,15 +323,29 @@ public class UserServiceImpl implements UserService {
|
|
|
return sysUserMapper.updateByPrimaryKey(user);
|
|
|
}
|
|
|
|
|
|
- public Integer updatePassword(String userID, String newPassword, String updateBy) throws Exception {
|
|
|
+ public Integer updatePassword(HttpServletRequest request, String userID, String newPassword, String updateBy) throws Exception {
|
|
|
SysUser user = sysUserMapper.selectByPrimaryKey(userID);
|
|
|
if(newPassword.equals(user.getPassword())){
|
|
|
- throw new Exception("新密码与旧密码不能相同!");
|
|
|
+ throw new BaseException("100001", "新密码不能与旧密码相同");
|
|
|
}
|
|
|
user.setPassword(newPassword);
|
|
|
user.setUpdateBy(updateBy);
|
|
|
user.setUpdateTime(new Date());
|
|
|
- return sysUserMapper.updateByPrimaryKey(user);
|
|
|
+ Integer result = sysUserMapper.updateByPrimaryKey(user);
|
|
|
+ // 记录日志
|
|
|
+ if (result > 0) {
|
|
|
+ SysLog sysLog = new SysLog();
|
|
|
+ sysLog.setLogID(UUID.randomUUID().toString());
|
|
|
+ sysLog.setPageName("用户列表");
|
|
|
+ sysLog.setPageUrl("/sys/permission/userslist/updatePassword");
|
|
|
+ sysLog.setActionName("修改密码");
|
|
|
+ sysLog.setUserID(accountService.getLoginUserID());
|
|
|
+ sysLog.setLogTime(new Date());
|
|
|
+ sysLog.setIPAddress(IpUtils.getIpAddr(request));
|
|
|
+ sysLog.setOperationData("修改了" + user.getName() + "(" + user.getLoginID() + ")" + "的登录密码");
|
|
|
+ sysLogMapper.insert(sysLog);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|