|
|
|
@ -1,15 +1,17 @@ |
|
|
|
|
package com.keyware.htey.controller.user; |
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Base64; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.keyware.htey.entity.department.Department; |
|
|
|
|
import com.keyware.htey.entity.user.AuditLog; |
|
|
|
|
import com.keyware.htey.entity.user.User; |
|
|
|
|
import com.keyware.htey.entity.usersecret.Usersecret; |
|
|
|
|
import com.keyware.htey.entity.usersecret.UserSecret; |
|
|
|
|
import com.keyware.htey.service.itf.AuditLogService; |
|
|
|
|
import com.keyware.htey.service.itf.DepartmentService; |
|
|
|
|
import com.keyware.htey.service.itf.UserService; |
|
|
|
@ -35,6 +37,9 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest; |
|
|
|
|
import org.springframework.web.util.WebUtils; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author yangmengchuan |
|
|
|
@ -201,7 +206,7 @@ public class UserController { |
|
|
|
|
// .getId(), "", "0", "K");
|
|
|
|
|
//}
|
|
|
|
|
//if (numCode != null && (numCode.equals("siyuan17suo") || numCode.equals("guiyangshiyuan"))) {
|
|
|
|
|
Usersecret userSecret = new Usersecret(); |
|
|
|
|
UserSecret userSecret = new UserSecret(); |
|
|
|
|
userSecret.setId(user.getId()); |
|
|
|
|
userSecret.setSecret(user.getSecret()); |
|
|
|
|
this.usersecretService.insertSelective(userSecret); |
|
|
|
@ -463,7 +468,7 @@ public class UserController { |
|
|
|
|
/** |
|
|
|
|
* @return null |
|
|
|
|
* @description 密码重置 |
|
|
|
|
* @Author daijj8 |
|
|
|
|
* @Author daijiajun |
|
|
|
|
* @Date 2025/1/13 17:50 |
|
|
|
|
**/ |
|
|
|
|
@GetMapping("/PwdReset") |
|
|
|
@ -512,7 +517,7 @@ public class UserController { |
|
|
|
|
* 注销用户列表 |
|
|
|
|
* |
|
|
|
|
* @return null |
|
|
|
|
* @Author daijj8 |
|
|
|
|
* @Author daijiajun |
|
|
|
|
* @Date 2025/1/15 10:03 |
|
|
|
|
**/ |
|
|
|
|
@GetMapping("/selectLogOutUser") |
|
|
|
@ -582,7 +587,7 @@ public class UserController { |
|
|
|
|
/** |
|
|
|
|
* @return null |
|
|
|
|
* @description 删除用户 |
|
|
|
|
* @Author daijj8 |
|
|
|
|
* @Author daijiajun |
|
|
|
|
* @Date 2025/1/13 17:50 |
|
|
|
|
**/ |
|
|
|
|
@RequestMapping( |
|
|
|
@ -593,7 +598,7 @@ public class UserController { |
|
|
|
|
@ResponseBody |
|
|
|
|
@Operation(summary = "删除用户", description = "返回删除用户信息") |
|
|
|
|
@ApiResponse(responseCode = "200", description = "删除用户成功") |
|
|
|
|
public String delPwdResetList(@RequestParam String userIds) { |
|
|
|
|
public String delPwdResetList(@RequestParam String userIds, HttpServletRequest request) { |
|
|
|
|
try { |
|
|
|
|
List<String> listId = IdComposeListUtil.listId(userIds); |
|
|
|
|
String userNames = ""; |
|
|
|
@ -632,4 +637,227 @@ public class UserController { |
|
|
|
|
return Constant.ERROE_MESSAGE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping( |
|
|
|
|
value = {"/edit"}, |
|
|
|
|
method = {RequestMethod.POST}, |
|
|
|
|
produces = {"application/json; charset=utf-8"} |
|
|
|
|
) |
|
|
|
|
@ResponseBody |
|
|
|
|
@Operation(summary = "修改人员", description = "返回修改人员信息") |
|
|
|
|
@ApiResponse(responseCode = "200", description = "修改人员成功") |
|
|
|
|
public AjaxMessage edit(@RequestBody User user, HttpServletRequest request) { |
|
|
|
|
AjaxMessage ajaxMessage = new AjaxMessage(); |
|
|
|
|
User oldUser = this.userService.selectByPrimaryKey(user.getId()); |
|
|
|
|
byte[] fileData = null; |
|
|
|
|
AuditLog auditLog = new AuditLog(); |
|
|
|
|
try { |
|
|
|
|
List<User> selectByUserNumber = this.userService.selectByUserNumber(user.getUserNumber()); |
|
|
|
|
if (selectByUserNumber.size() > 0) { |
|
|
|
|
if (selectByUserNumber.size() != 1) { |
|
|
|
|
ajaxMessage.setCode("0"); |
|
|
|
|
ajaxMessage.setMessage("员工编号已存在"); |
|
|
|
|
return ajaxMessage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
User user2 = (User)selectByUserNumber.get(0); |
|
|
|
|
if (!user2.getId().equals(user.getId())) { |
|
|
|
|
ajaxMessage.setCode("0"); |
|
|
|
|
ajaxMessage.setMessage("员工编号已存在"); |
|
|
|
|
return ajaxMessage; |
|
|
|
|
} |
|
|
|
|
String contentType = request.getContentType(); |
|
|
|
|
String comments; |
|
|
|
|
if (contentType != null && contentType.toLowerCase().startsWith("multipart/")) { |
|
|
|
|
MultipartHttpServletRequest multipartRequest |
|
|
|
|
= (MultipartHttpServletRequest)WebUtils.getNativeRequest(request, |
|
|
|
|
MultipartHttpServletRequest.class); |
|
|
|
|
MultipartFile file = multipartRequest.getFile("multipartfile"); |
|
|
|
|
comments = request.getParameter("changeFlg"); |
|
|
|
|
if (comments.equals("1")) { |
|
|
|
|
if (file != null) { |
|
|
|
|
fileData = file.getBytes(); |
|
|
|
|
} else { |
|
|
|
|
String signatureUrl = request.getParameter("signatureUrl"); |
|
|
|
|
Base64.Decoder decoder = Base64.getDecoder(); |
|
|
|
|
signatureUrl = signatureUrl.substring(signatureUrl.indexOf(",", 1) + 1, |
|
|
|
|
signatureUrl.length()); |
|
|
|
|
fileData = decoder.decode(signatureUrl); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < fileData.length; ++i) { |
|
|
|
|
if (fileData[i] < 0) { |
|
|
|
|
fileData[i] = (byte)(fileData[i] + 256); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
user.setImgData(fileData); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.userService.updateByPrimaryKey(user); |
|
|
|
|
StringBuilder info = new StringBuilder(); |
|
|
|
|
if (oldUser.getUserNumber() == null) { |
|
|
|
|
oldUser.setUserNumber(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getUserNumber().equals(user.getUserNumber())) { |
|
|
|
|
info.append("员工编号从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getUserName() == null) { |
|
|
|
|
oldUser.setUserName(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getUserName().equals(user.getUserName())) { |
|
|
|
|
info.append("姓名从" + oldUser.getUserName() + "修改为" + user.getUserName() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getIdCard() == null) { |
|
|
|
|
oldUser.setIdCard(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getIdCard().equals(user.getIdCard())) { |
|
|
|
|
info.append("身份证号码从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getEmail() == null) { |
|
|
|
|
oldUser.setEmail(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getEmail().equals(user.getEmail())) { |
|
|
|
|
info.append("电子邮件从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getDepartId() == null) { |
|
|
|
|
oldUser.setDepartId(""); |
|
|
|
|
} |
|
|
|
|
if (!oldUser.getDepartId().equals(user.getDepartId())) { |
|
|
|
|
Department department; |
|
|
|
|
if (org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) |
|
|
|
|
&& org.springframework.util.StringUtils.hasText(user.getDepartId())) { |
|
|
|
|
department = this.departmentService.selectByPrimaryKey(oldUser.getDepartId()); |
|
|
|
|
Department department1 = this.departmentService.selectByPrimaryKey(user.getDepartId()); |
|
|
|
|
if (department != null && department1 != null) { |
|
|
|
|
info.append( |
|
|
|
|
"所属部门从" + department.getDeptName() + "修改为" + department1.getDeptName() + ";"); |
|
|
|
|
} |
|
|
|
|
} else if (!org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) |
|
|
|
|
&& org.springframework.util.StringUtils.hasText(user.getDepartId())) { |
|
|
|
|
department = this.departmentService.selectByPrimaryKey(user.getDepartId()); |
|
|
|
|
if (department != null) { |
|
|
|
|
info.append("所属部门从空修改为" + department.getDeptName() + ";"); |
|
|
|
|
} |
|
|
|
|
} else if ( |
|
|
|
|
org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) |
|
|
|
|
&& !org.springframework.util.StringUtils.hasText(user.getDepartId())) { |
|
|
|
|
department = this.departmentService.selectByPrimaryKey(oldUser.getDepartId()); |
|
|
|
|
if (department != null) { |
|
|
|
|
info.append("所属部门从" + department.getDeptName() + "修改为空;"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getSex() == null) { |
|
|
|
|
oldUser.setSex(0L); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String oldUserRankId; |
|
|
|
|
String userRankId; |
|
|
|
|
if (!oldUser.getSex().equals(user.getSex())) { |
|
|
|
|
oldUserRankId = "女"; |
|
|
|
|
userRankId = "女"; |
|
|
|
|
if ("0".equals(oldUser.getSex())) { |
|
|
|
|
oldUserRankId = "男"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("0".equals(user.getSex())) { |
|
|
|
|
userRankId = "男"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
info.append("性别从" + oldUserRankId + "修改为" + userRankId + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getMobilePhone() == null) { |
|
|
|
|
oldUser.setMobilePhone(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getMobilePhone().equals(user.getMobilePhone())) { |
|
|
|
|
info.append("手机从" + oldUser.getMobilePhone() + "修改为" + user.getMobilePhone() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getOfficeTelephone() == null) { |
|
|
|
|
oldUser.setOfficeTelephone(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getOfficeTelephone().equals(user.getOfficeTelephone())) { |
|
|
|
|
info.append( |
|
|
|
|
"办公电话从" + oldUser.getOfficeTelephone() + "修改为" + user.getOfficeTelephone() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getHomePhone() == null) { |
|
|
|
|
oldUser.setHomePhone(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getHomePhone().equals(user.getHomePhone())) { |
|
|
|
|
info.append("家庭电话从" + oldUser.getHomePhone() + "修改为" + user.getHomePhone() + ";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oldUser.getUesrRankId() == null) { |
|
|
|
|
oldUser.setUesrRankId(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!oldUser.getUesrRankId().equals(user.getUesrRankId())) { |
|
|
|
|
oldUserRankId = "普通"; |
|
|
|
|
userRankId = "普通"; |
|
|
|
|
if ("d453bf52e571451996a8f5c251f7eb8d".equals(oldUser.getUesrRankId())) { |
|
|
|
|
oldUserRankId = "秘密"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("d453bf52e571451996a8f5c251f7eb8d".equals(user.getUesrRankId())) { |
|
|
|
|
userRankId = "秘密"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
info.append("密码密级从" + oldUserRankId + "修改为" + userRankId + ";"); |
|
|
|
|
} |
|
|
|
|
oldUserRankId = user.getSecret(); |
|
|
|
|
info.append("人员密级设置为" + oldUserRankId); |
|
|
|
|
String logName = "修改人员"; |
|
|
|
|
String logNameType = "用户列表"; |
|
|
|
|
//todo 登录人的用户名 userName
|
|
|
|
|
//String comments = userName + "修改了用户" + user.getUserName() + "的信息";
|
|
|
|
|
comments = "修改了用户" + user.getUserName() + "的信息"; |
|
|
|
|
auditLog.setLogName(logName); |
|
|
|
|
auditLog.setLogNameType(logNameType); |
|
|
|
|
auditLog.setComments(comments + ";" + info); |
|
|
|
|
auditLogService.addAuditLog(auditLog); |
|
|
|
|
//todo 添加MESSAGE_TABLE表
|
|
|
|
|
//if (userRankId != null && userRankId.equals("tianjin712suo")) {
|
|
|
|
|
// User safeUser = this.userService.selectUserByUserId("safesecret");
|
|
|
|
|
// this.messageService.insertMessage("修改用户" + user.getUserName() + "", "用户管理", (String)null,
|
|
|
|
|
// safeUser.getId(), "", "0", "K");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//todo customCode从Session中获取进行判断
|
|
|
|
|
//if (userRankId != null && (userRankId.equals("siyuan17suo") || userRankId.equals("guiyangshiyuan"))) {
|
|
|
|
|
UserSecret userSecret = this.usersecretService.selectByPrimaryKey(user.getId()); |
|
|
|
|
if (userSecret == null) { |
|
|
|
|
UserSecret secret = new UserSecret(); |
|
|
|
|
secret.setId(user.getId()); |
|
|
|
|
secret.setSecret(user.getSecret()); |
|
|
|
|
this.usersecretService.insertSelective(secret); |
|
|
|
|
} else { |
|
|
|
|
userSecret.setSecret(user.getSecret()); |
|
|
|
|
this.usersecretService.updateByPrimaryKey(userSecret); |
|
|
|
|
} |
|
|
|
|
//}
|
|
|
|
|
ajaxMessage.setCode("1"); |
|
|
|
|
ajaxMessage.setMessage("保存成功"); |
|
|
|
|
} |
|
|
|
|
} catch (Exception var16) { |
|
|
|
|
log.error("修改用户失败", var16); |
|
|
|
|
ajaxMessage.setCode("0"); |
|
|
|
|
ajaxMessage.setMessage(Constant.ERROE_MESSAGE); |
|
|
|
|
} |
|
|
|
|
return ajaxMessage; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|