diff --git a/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java b/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java index ad74eee..2f0242a 100644 --- a/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java +++ b/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java @@ -5,6 +5,7 @@ import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.keyware.htey.entity.department.Department; 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.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; @@ -101,4 +102,22 @@ public class DepartmentController { 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); + } + } diff --git a/src/main/java/com/keyware/htey/controller/user/UserController.java b/src/main/java/com/keyware/htey/controller/user/UserController.java index 76eccbf..267ca36 100644 --- a/src/main/java/com/keyware/htey/controller/user/UserController.java +++ b/src/main/java/com/keyware/htey/controller/user/UserController.java @@ -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.tags.Tag; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -227,7 +227,7 @@ public class UserController { produces = {"application/json; charset=utf-8"} ) @ResponseBody - @Operation(summary = "用户注销", description = "返回用户注销信息") + @Operation(summary = "用户注销还原", description = "返回用户注销信息") @ApiResponse(responseCode = "200", description = "成功用户注销信息") public String updateUser(@RequestBody List users, String logOut) { String userNames = ""; @@ -265,7 +265,7 @@ public class UserController { this.userService.recovery(IdComposeListUtil.listId(users)); userNames = ""; for (User user : users) { - User u = this.userService.selectByPrimaryKey(user.getUserId()); + User u = this.userService.selectByPrimaryKey(user.getId()); String logName = "还原人员"; String logNameType = "注销用户列表"; //String comments = userName + "还原了用户" + u.getUserName(); @@ -397,12 +397,50 @@ public class UserController { * @date 2025/1/7 * @description 根据id进行删除 */ - @GetMapping("/deleteUser") + @RequestMapping( + value = {"/delete"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) @ResponseBody @Operation(summary = "根据id删除用户", description = "返回删除用户信息") @ApiResponse(responseCode = "200", description = "成功删除用户信息") - public boolean deleteUser(@RequestParam String id) { - return userService.removeById(id); + public String deleteUser(@RequestBody List users) { + try { + List 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( @@ -470,4 +508,51 @@ public class UserController { //todo 添加MESSAGE_TABLE表 return "重置成功"; } + + @GetMapping("/selectLogOutUser") + @ResponseBody + @Operation(summary = "注销用户列表", description = "返回注销用户列表信息") + @ApiResponse(responseCode = "200", description = "注销用户列表返回成功") + public Page selectLogOutUser(@RequestParam(required = false) String name, + @RequestParam(defaultValue = "1") int pageNum, + @RequestParam(defaultValue = "10") int pageSize) { + if ("请输入姓名...".equals(name)) { + name = null; + } + // 创建分页对象 + Page pageParam = new Page<>(pageNum, pageSize); + + // 创建查询条件 + QueryWrapper 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 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); + } + } diff --git a/src/main/java/com/keyware/htey/entity/user/UserRole.java b/src/main/java/com/keyware/htey/entity/user/UserRole.java new file mode 100644 index 0000000..70c6574 --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/user/UserRole.java @@ -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; +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java index d558aba..7fc0e1c 100644 --- a/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java +++ b/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java @@ -17,4 +17,8 @@ public interface DepartmentMapper extends BaseMapper { List selectByDeparmentName(@Param("deptName") String var1, @Param("projectSource") String var2); Department selectByPrimaryKey(String var1); + + List getParentId(@Param("parentId") String var1, @Param("isSys") String var2, + @Param("projectSource") String var3); + } diff --git a/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java index 31361b3..da34115 100644 --- a/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java +++ b/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java @@ -34,4 +34,7 @@ public interface UserMapper extends BaseMapper { User selectByPrimaryKey(String var1); int recovery(List var1); + + List selectLogOutUser(@Param("userName") String var1, @Param("projectSource") String var2); + int deleteByPrimaryKey(List var1); } diff --git a/src/main/java/com/keyware/htey/mybatis/itf/UserRoleMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/UserRoleMapper.java new file mode 100644 index 0000000..dd834e9 --- /dev/null +++ b/src/main/java/com/keyware/htey/mybatis/itf/UserRoleMapper.java @@ -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 { + int deleteByUserId(String var1); +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java index 50389f2..6a9ffd3 100644 --- a/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java +++ b/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java @@ -1,5 +1,7 @@ package com.keyware.htey.mybatis.itf; +import java.util.List; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.keyware.htey.entity.usersecret.Usersecret; import org.apache.ibatis.annotations.Mapper; @@ -12,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface UsersecretMapper extends BaseMapper { int insertSelective(Usersecret var1); + void deleteByPrimaryKey(List var1); } diff --git a/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java index 7be82f0..81465f7 100644 --- a/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java @@ -26,4 +26,8 @@ public class DepartmentServiceImpl extends ServiceImpl getParentId(String parentId, String isSys, String projectRsource) { + return this.departmentMapper.getParentId(parentId, isSys, projectRsource); + } } diff --git a/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java index f1789df..84f86d6 100644 --- a/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.keyware.htey.entity.user.User; 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.utli.Constant; import lombok.extern.slf4j.Slf4j; @@ -17,7 +18,8 @@ public class UserServiceImpl extends ServiceImpl implements Us @Autowired private UserMapper userMapper; private static String projectName = "kdtr"; - + @Autowired + private UserRoleMapper userRoleMapper; @Override public List selectByUserInfo17suo(User user) { user.setProjectSource(projectName); @@ -71,4 +73,16 @@ public class UserServiceImpl extends ServiceImpl implements Us public int recovery(List record) { return this.userMapper.recovery(record); } + @Override + public List selectLogOutUser(String userName) { + return this.userMapper.selectLogOutUser(userName, Constant.projectName); + } + @Override + public int deleteByPrimaryKey(List id) { + return this.userMapper.deleteByPrimaryKey(id); + } + public void deleteUserRoleByUserId(String id) { + this.userRoleMapper.deleteByUserId(id); + } + } diff --git a/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java index 5a8ea9b..e482edf 100644 --- a/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java @@ -1,5 +1,7 @@ package com.keyware.htey.service.impl; +import java.util.List; + import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.keyware.htey.entity.usersecret.Usersecret; import com.keyware.htey.mybatis.itf.UsersecretMapper; @@ -18,4 +20,8 @@ public class UsersecretServiceImpl extends ServiceImpl id) { + this.usersecretMapper.deleteByPrimaryKey(id); + } } diff --git a/src/main/java/com/keyware/htey/service/itf/DepartmentService.java b/src/main/java/com/keyware/htey/service/itf/DepartmentService.java index 5ecc0b4..388780b 100644 --- a/src/main/java/com/keyware/htey/service/itf/DepartmentService.java +++ b/src/main/java/com/keyware/htey/service/itf/DepartmentService.java @@ -9,4 +9,7 @@ public interface DepartmentService extends IService { List selectByDeparmentName(String var1); Department selectByPrimaryKey(String var1); + + + List getParentId(String var1, String var2, String var3); } diff --git a/src/main/java/com/keyware/htey/service/itf/UserService.java b/src/main/java/com/keyware/htey/service/itf/UserService.java index 67d82d2..95e196c 100644 --- a/src/main/java/com/keyware/htey/service/itf/UserService.java +++ b/src/main/java/com/keyware/htey/service/itf/UserService.java @@ -26,4 +26,8 @@ public interface UserService extends IService { User selectByPrimaryKey(String var1); int recovery(List var1); + + List selectLogOutUser(String var1); + int deleteByPrimaryKey(List var1); + void deleteUserRoleByUserId(String var1); } diff --git a/src/main/java/com/keyware/htey/service/itf/UsersecretService.java b/src/main/java/com/keyware/htey/service/itf/UsersecretService.java index e98fb58..18e32d4 100644 --- a/src/main/java/com/keyware/htey/service/itf/UsersecretService.java +++ b/src/main/java/com/keyware/htey/service/itf/UsersecretService.java @@ -1,8 +1,11 @@ package com.keyware.htey.service.itf; +import java.util.List; + import com.baomidou.mybatisplus.extension.service.IService; import com.keyware.htey.entity.usersecret.Usersecret; public interface UsersecretService extends IService { int insertSelective(Usersecret var1); + void deleteByPrimaryKey(List var1); } diff --git a/src/main/resources/mapper/DepartmentMapper.xml b/src/main/resources/mapper/DepartmentMapper.xml index babc600..595fe16 100644 --- a/src/main/resources/mapper/DepartmentMapper.xml +++ b/src/main/resources/mapper/DepartmentMapper.xml @@ -39,4 +39,16 @@ from DEPARTMENT where ID = #{id,jdbcType=VARCHAR} + + diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index ce19d05..6b0695d 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -378,4 +378,27 @@ #{item} + + + + + delete from K_USER + where ID in + + #{item} + + diff --git a/src/main/resources/mapper/UserRoleMapper.xml b/src/main/resources/mapper/UserRoleMapper.xml new file mode 100644 index 0000000..7dce0a8 --- /dev/null +++ b/src/main/resources/mapper/UserRoleMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + delete from USER_ROLE where USER_ID = #{userId,jdbcType=VARCHAR} + + diff --git a/src/main/resources/mapper/UsersecretMapper.xml b/src/main/resources/mapper/UsersecretMapper.xml index 0827ea2..ad26aff 100644 --- a/src/main/resources/mapper/UsersecretMapper.xml +++ b/src/main/resources/mapper/UsersecretMapper.xml @@ -9,4 +9,11 @@ insert into USERSECRET (ID, SECRET) values (#{id,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}) + + delete from USERSECRET + where ID in + + #{item} + +