用户管理中注销用户列表功能包括页面初始化,还原用户,删除用户

main
admin 5 days ago
parent ec839b84e7
commit 42d78211b0
  1. 19
      src/main/java/com/keyware/htey/controller/Department/DepartmentController.java
  2. 97
      src/main/java/com/keyware/htey/controller/user/UserController.java
  3. 15
      src/main/java/com/keyware/htey/entity/user/UserRole.java
  4. 4
      src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java
  5. 3
      src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java
  6. 17
      src/main/java/com/keyware/htey/mybatis/itf/UserRoleMapper.java
  7. 3
      src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java
  8. 4
      src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java
  9. 16
      src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java
  10. 6
      src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java
  11. 3
      src/main/java/com/keyware/htey/service/itf/DepartmentService.java
  12. 4
      src/main/java/com/keyware/htey/service/itf/UserService.java
  13. 3
      src/main/java/com/keyware/htey/service/itf/UsersecretService.java
  14. 12
      src/main/resources/mapper/DepartmentMapper.xml
  15. 23
      src/main/resources/mapper/UserMapper.xml
  16. 12
      src/main/resources/mapper/UserRoleMapper.xml
  17. 7
      src/main/resources/mapper/UsersecretMapper.xml

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.keyware.htey.entity.department.Department; import com.keyware.htey.entity.department.Department;
import com.keyware.htey.service.itf.DepartmentService; import com.keyware.htey.service.itf.DepartmentService;
import com.keyware.htey.utli.JsonUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -101,4 +102,22 @@ public class DepartmentController {
return departmentService.removeById(id); return departmentService.removeById(id);
} }
@RequestMapping(
value = {"/getParentId"},
method = {RequestMethod.GET},
produces = {"application/json; charset=utf-8"}
)
@ResponseBody
@Operation(summary = "查询部门父节点信息", description = "返回部门父节点信息")
@ApiResponse(responseCode = "200", description = "成功部门父节点信息")
public String getParentId(@RequestParam String id, @RequestParam String projectResource) {
String isSys = "";
//if ("sysadmin".equals(this.getUser_idFormSession("userId"))) {
// isSys = "sysadmin";
//}
List<?> department = this.departmentService.getParentId(id, isSys, projectResource);
return JsonUtils.arrayListToJsonString(department);
}
} }

@ -26,9 +26,9 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -227,7 +227,7 @@ public class UserController {
produces = {"application/json; charset=utf-8"} produces = {"application/json; charset=utf-8"}
) )
@ResponseBody @ResponseBody
@Operation(summary = "用户注销", description = "返回用户注销信息") @Operation(summary = "用户注销还原", description = "返回用户注销信息")
@ApiResponse(responseCode = "200", description = "成功用户注销信息") @ApiResponse(responseCode = "200", description = "成功用户注销信息")
public String updateUser(@RequestBody List<User> users, String logOut) { public String updateUser(@RequestBody List<User> users, String logOut) {
String userNames = ""; String userNames = "";
@ -265,7 +265,7 @@ public class UserController {
this.userService.recovery(IdComposeListUtil.listId(users)); this.userService.recovery(IdComposeListUtil.listId(users));
userNames = ""; userNames = "";
for (User user : users) { for (User user : users) {
User u = this.userService.selectByPrimaryKey(user.getUserId()); User u = this.userService.selectByPrimaryKey(user.getId());
String logName = "还原人员"; String logName = "还原人员";
String logNameType = "注销用户列表"; String logNameType = "注销用户列表";
//String comments = userName + "还原了用户" + u.getUserName(); //String comments = userName + "还原了用户" + u.getUserName();
@ -397,12 +397,50 @@ public class UserController {
* @date 2025/1/7 * @date 2025/1/7
* @description 根据id进行删除 * @description 根据id进行删除
*/ */
@GetMapping("/deleteUser") @RequestMapping(
value = {"/delete"},
method = {RequestMethod.POST},
produces = {"application/json; charset=utf-8"}
)
@ResponseBody @ResponseBody
@Operation(summary = "根据id删除用户", description = "返回删除用户信息") @Operation(summary = "根据id删除用户", description = "返回删除用户信息")
@ApiResponse(responseCode = "200", description = "成功删除用户信息") @ApiResponse(responseCode = "200", description = "成功删除用户信息")
public boolean deleteUser(@RequestParam String id) { public String deleteUser(@RequestBody List<User> users) {
return userService.removeById(id); try {
List<String> listId = IdComposeListUtil.listId(users);
AuditLog auditLog = new AuditLog();
String userNames = "";
for (User user : users) {
User safeUser = this.userService.selectByPrimaryKey(user.getId());
if ("".equals(userNames)) {
userNames = safeUser.getUserName();
} else {
userNames = userNames + "," + safeUser.getUserName();
}
}
this.userService.deleteByPrimaryKey(listId);
String logName = "删除人员";
String logNameType = "用户列表";
//todo 登录人的用户名 userName
// String comments = userName + "删除了用户" + userNames;
String comments = "删除了用户" + userNames;
auditLog.setLogName(logName);
auditLog.setLogNameType(logNameType);
auditLog.setComments(comments);
auditLogService.addAuditLog(auditLog);
//todo 添加MESSAGE_TABLE表
//if (numCode != null && (numCode.equals("siyuan17suo") || numCode.equals("guiyangshiyuan"))) {
this.usersecretService.deleteByPrimaryKey(listId);
//}
for (String id : listId) {
this.userService.deleteUserRoleByUserId(id);
}
return "删除成功";
} catch (Exception var9) {
log.error("删除用户失败", var9);
return Constant.ERROE_MESSAGE;
}
} }
@RequestMapping( @RequestMapping(
@ -470,4 +508,51 @@ public class UserController {
//todo 添加MESSAGE_TABLE表 //todo 添加MESSAGE_TABLE表
return "重置成功"; return "重置成功";
} }
@GetMapping("/selectLogOutUser")
@ResponseBody
@Operation(summary = "注销用户列表", description = "返回注销用户列表信息")
@ApiResponse(responseCode = "200", description = "注销用户列表返回成功")
public Page<User> selectLogOutUser(@RequestParam(required = false) String name,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) {
if ("请输入姓名...".equals(name)) {
name = null;
}
// 创建分页对象
Page<User> pageParam = new Page<>(pageNum, pageSize);
// 创建查询条件
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
if (!StringUtils.isEmpty(name)) {
queryWrapper = queryWrapper.like("USER_NAME", name).orderByDesc("LOGOUT_TIME");// 模糊查询
} else {
queryWrapper = queryWrapper.orderByDesc("LOGOUT_TIME"); // 模糊查询
}
AuditLog auditLog = new AuditLog();
//List<User> userList = this.userService.selectLogOutUser(name);
//int startIndex = (pageNum - 1) * pageSize;
//int endIndex = Math.min(startIndex + pageSize, userList.size());
String logName = "查询注销用户列表";
String logNameType = "用户管理";
//todo 登录人的用户名 userName
//String comments = this.getUser_idFormSession("userName") + "查询注销用户列表,查询关键字为:" + name == null ? "" : name;
String comments = "查询注销用户列表,查询关键字为:" + name == null ? "" : name;
auditLog.setLogName(logName);
auditLog.setLogNameType(logNameType);
auditLog.setComments(comments);
auditLogService.addAuditLog(auditLog);
//if (startIndex >= userList.size()) {
// return Collections.emptyList(); // 如果起始索引超出列表范围,则返回空列表
//} else {
// return userList.subList(startIndex, endIndex);
//}
// 执行分页查询
return userService.page(pageParam, queryWrapper);
}
} }

@ -0,0 +1,15 @@
package com.keyware.htey.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("USER_ROLE")
public class UserRole {
private String userId;
private String roleId;
}

@ -17,4 +17,8 @@ public interface DepartmentMapper extends BaseMapper<Department> {
List<Department> selectByDeparmentName(@Param("deptName") String var1, @Param("projectSource") String var2); List<Department> selectByDeparmentName(@Param("deptName") String var1, @Param("projectSource") String var2);
Department selectByPrimaryKey(String var1); Department selectByPrimaryKey(String var1);
List<Department> getParentId(@Param("parentId") String var1, @Param("isSys") String var2,
@Param("projectSource") String var3);
} }

@ -34,4 +34,7 @@ public interface UserMapper extends BaseMapper<User> {
User selectByPrimaryKey(String var1); User selectByPrimaryKey(String var1);
int recovery(List var1); int recovery(List var1);
List<User> selectLogOutUser(@Param("userName") String var1, @Param("projectSource") String var2);
int deleteByPrimaryKey(List<String> var1);
} }

@ -0,0 +1,17 @@
package com.keyware.htey.mybatis.itf;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.keyware.htey.entity.user.User;
import com.keyware.htey.entity.user.UserRole;
import org.apache.ibatis.annotations.Mapper;
/**
* @author daijj8
* @version V1.0
* @Package com.keyware.htey.mybatis.itf
* @date 2025/1/14 17:11
*/
@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {
int deleteByUserId(String var1);
}

@ -1,5 +1,7 @@
package com.keyware.htey.mybatis.itf; package com.keyware.htey.mybatis.itf;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.keyware.htey.entity.usersecret.Usersecret; import com.keyware.htey.entity.usersecret.Usersecret;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -12,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface UsersecretMapper extends BaseMapper<Usersecret> { public interface UsersecretMapper extends BaseMapper<Usersecret> {
int insertSelective(Usersecret var1); int insertSelective(Usersecret var1);
void deleteByPrimaryKey(List<String> var1);
} }

@ -26,4 +26,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
public Department selectByPrimaryKey(String id) { public Department selectByPrimaryKey(String id) {
return this.departmentMapper.selectByPrimaryKey(id); return this.departmentMapper.selectByPrimaryKey(id);
} }
@Override
public List<Department> getParentId(String parentId, String isSys, String projectRsource) {
return this.departmentMapper.getParentId(parentId, isSys, projectRsource);
}
} }

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.keyware.htey.entity.user.User; import com.keyware.htey.entity.user.User;
import com.keyware.htey.mybatis.itf.UserMapper; import com.keyware.htey.mybatis.itf.UserMapper;
import com.keyware.htey.mybatis.itf.UserRoleMapper;
import com.keyware.htey.service.itf.UserService; import com.keyware.htey.service.itf.UserService;
import com.keyware.htey.utli.Constant; import com.keyware.htey.utli.Constant;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -17,7 +18,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Autowired @Autowired
private UserMapper userMapper; private UserMapper userMapper;
private static String projectName = "kdtr"; private static String projectName = "kdtr";
@Autowired
private UserRoleMapper userRoleMapper;
@Override @Override
public List<User> selectByUserInfo17suo(User user) { public List<User> selectByUserInfo17suo(User user) {
user.setProjectSource(projectName); user.setProjectSource(projectName);
@ -71,4 +73,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
public int recovery(List record) { public int recovery(List record) {
return this.userMapper.recovery(record); return this.userMapper.recovery(record);
} }
@Override
public List<User> selectLogOutUser(String userName) {
return this.userMapper.selectLogOutUser(userName, Constant.projectName);
}
@Override
public int deleteByPrimaryKey(List<String> id) {
return this.userMapper.deleteByPrimaryKey(id);
}
public void deleteUserRoleByUserId(String id) {
this.userRoleMapper.deleteByUserId(id);
}
} }

@ -1,5 +1,7 @@
package com.keyware.htey.service.impl; package com.keyware.htey.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.keyware.htey.entity.usersecret.Usersecret; import com.keyware.htey.entity.usersecret.Usersecret;
import com.keyware.htey.mybatis.itf.UsersecretMapper; import com.keyware.htey.mybatis.itf.UsersecretMapper;
@ -18,4 +20,8 @@ public class UsersecretServiceImpl extends ServiceImpl<UsersecretMapper, Usersec
public int insertSelective(Usersecret userSecret) { public int insertSelective(Usersecret userSecret) {
return this.usersecretMapper.insertSelective(userSecret); return this.usersecretMapper.insertSelective(userSecret);
} }
@Override
public void deleteByPrimaryKey(List<String> id) {
this.usersecretMapper.deleteByPrimaryKey(id);
}
} }

@ -9,4 +9,7 @@ public interface DepartmentService extends IService<Department> {
List<Department> selectByDeparmentName(String var1); List<Department> selectByDeparmentName(String var1);
Department selectByPrimaryKey(String var1); Department selectByPrimaryKey(String var1);
List<Department> getParentId(String var1, String var2, String var3);
} }

@ -26,4 +26,8 @@ public interface UserService extends IService<User> {
User selectByPrimaryKey(String var1); User selectByPrimaryKey(String var1);
int recovery(List var1); int recovery(List var1);
List<User> selectLogOutUser(String var1);
int deleteByPrimaryKey(List<String> var1);
void deleteUserRoleByUserId(String var1);
} }

@ -1,8 +1,11 @@
package com.keyware.htey.service.itf; package com.keyware.htey.service.itf;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.keyware.htey.entity.usersecret.Usersecret; import com.keyware.htey.entity.usersecret.Usersecret;
public interface UsersecretService extends IService<Usersecret> { public interface UsersecretService extends IService<Usersecret> {
int insertSelective(Usersecret var1); int insertSelective(Usersecret var1);
void deleteByPrimaryKey(List<String> var1);
} }

@ -39,4 +39,16 @@
from DEPARTMENT from DEPARTMENT
where ID = #{id,jdbcType=VARCHAR} where ID = #{id,jdbcType=VARCHAR}
</select> </select>
<select id="getParentId" resultMap="BaseResultMap" >
select ID,DEPT_NAME,PARENT_ID,PROJECT_SOURCE
from DEPARTMENT
where 1=1
<if test="parentId != null" >
and ID != #{parentId,jdbcType=VARCHAR}
</if>
<if test="isSys != 'sysadmin'">
and IS_SYS = '0'
</if>
</select>
</mapper> </mapper>

@ -378,4 +378,27 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
<select id="selectLogOutUser" resultMap="BaseResultMap">
select ID, USER_ID, USER_NAME,
PASSWORD, DEPART_ID, USER_CREATION_TIME,
USER_PWD_MODIF_TIME, USER_STATUS, USER_LOCK,
USER_PWD_ERROR, USER_PWD_ERROR_DATE,EXIT_TIME,PASSWORD_OLD,
POST, EMAIL, OFFICE_TELEPHONE, USER_NUMBER, ID_CARD, MOBILE_PHONE, SEX, HOME_PHONE,LOGOUT,INIT_PWD_TIME
from K_USER where LOGOUT='1'
and PROJECT_SOURCE = #{projectSource,jdbcType=VARCHAR}
<if test="userName != null and userName != ''">
and USER_NAME like '%'||#{userName}||'%'
</if>
order by LOGOUT_TIME DESC
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from K_USER
where ID in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper> </mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.keyware.htey.mybatis.itf.UserRoleMapper" >
<resultMap id="BaseResultMap" type="com.keyware.htey.entity.user.UserRole" >
<result column="USER_ID" property="userId" jdbcType="VARCHAR" />
<result column="ROLE_ID" property="roleId" jdbcType="VARCHAR" />
</resultMap>
<delete id="deleteByUserId" parameterType="java.lang.String">
delete from USER_ROLE where USER_ID = #{userId,jdbcType=VARCHAR}
</delete>
</mapper>

@ -9,4 +9,11 @@
insert into USERSECRET (ID, SECRET) insert into USERSECRET (ID, SECRET)
values (#{id,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}) values (#{id,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR})
</insert> </insert>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from USERSECRET
where ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper> </mapper>

Loading…
Cancel
Save