From 99a1938775ebbde2cb6a93128beac22bdb975570 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Tue, 25 Feb 2025 14:34:27 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enterprise/vo/EnterprisePageReqVO.java | 1 + .../mysql/enterprise/EnterpriseMapper.java | 6 +++ .../system/job/TaskSendStartMessageJob.java | 4 +- .../enterprise/EnterpriseServiceImpl.java | 25 +++---------- .../mapper/enterprise/EnterpriseMapper.xml | 37 +++++++++++++++++++ 5 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java index d48de4f..7da1f7c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java @@ -91,4 +91,5 @@ public class EnterprisePageReqVO extends PageParam { private List tagList; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java index 551e673..5a60ee5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java @@ -6,8 +6,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.*; +import org.apache.ibatis.annotations.Param; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; @@ -67,4 +71,6 @@ public interface EnterpriseMapper extends BaseMapperX { .inIfPresent(EnterpriseDO::getId,reqVO.getIds()) .orderByDesc(EnterpriseDO::getId)); } + + IPage getAppPage(Page page, @Param("params") EnterprisePageReqVO pageReqVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java index c350bf0..e972608 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java @@ -78,7 +78,7 @@ public class TaskSendStartMessageJob implements JobHandler { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getId()); List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); - if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0){ + if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0) { List list = new ArrayList<>(); for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) { //站内信发送通知 @@ -96,8 +96,6 @@ public class TaskSendStartMessageJob implements JobHandler { } enterpriseInspectionsMapper.updateBatch(list); } - - } }); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java index 757f156..3fe9620 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java @@ -24,6 +24,8 @@ import cn.iocoder.yudao.module.system.service.permission.RoleService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.tomcat.jni.FileInfo; import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; @@ -240,27 +242,12 @@ public class EnterpriseServiceImpl implements EnterpriseService { pageReqVO.setDepartmentId(typeVO.getValue()); } - final PageResult enterpriseDOPageResult = enterpriseMapper.selectPage(pageReqVO); + Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + final IPage appPage = enterpriseMapper.getAppPage(page, pageReqVO); + + return new PageResult<>(appPage.getRecords(), appPage.getTotal()); - if (pageReqVO.getTagList() != null && pageReqVO.getTagList().size() > 0) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(EnterpriseTagDO::getTagId, pageReqVO.getTagList()); - List enterpriseTagDOList = enterpriseTagMapper.selectList(wrapper); - //根据enterpriseTagDOList 筛选 - List enterpriseDOList = new ArrayList<>(); - for (EnterpriseDO enterpriseDO : enterpriseDOPageResult.getList()) { - for (EnterpriseTagDO enterpriseTagDO : enterpriseTagDOList) { - if (enterpriseTagDO.getEnterpriseId().equals(enterpriseDO.getId())) { - enterpriseDOList.add(enterpriseDO); - break; - } - } - } - enterpriseDOPageResult.setList(enterpriseDOList); - enterpriseDOPageResult.setTotal(Long.valueOf(enterpriseDOList.size())); - } - return enterpriseDOPageResult; } //审核状态 @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml new file mode 100644 index 0000000..0f23eca --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + From d05dea157674ed722bc832ddfe754381400b947c Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Tue, 25 Feb 2025 14:44:32 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/auth/AdminAuthServiceImpl.java | 62 +++++++------------ 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index bdfe6c1..97dbbaa 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -459,47 +459,31 @@ public class AdminAuthServiceImpl implements AdminAuthService { AdminUserDO user = userService.getUser(loginUserId); RoleNameAndSelectTypeVO roleNameAndSelectTypeVO = new RoleNameAndSelectTypeVO(); if (user != null) { - if (user.getPostIds() != null) { - if (user.getPostIds().contains(1L) || user.getPostIds().contains(2L)) { - // 全部权限,不需要设置任何条件 - roleNameAndSelectTypeVO.setRoleName("director"); - } else if (user.getPostIds().contains(4L)) { - // 本部门权限 - roleNameAndSelectTypeVO.setRoleName("queue"); - roleNameAndSelectTypeVO.setValue(user.getDeptId()); - } else { - // 仅自己权限 - roleNameAndSelectTypeVO.setRoleName("self"); - roleNameAndSelectTypeVO.setValue(loginUserId); - roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); - } - } else { - //如果岗位不存在查询角色 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(UserRoleDO::getUserId, loginUserId); - List userRoleDO = userRoleMapper.selectList(wrapper); - - if (userRoleDO == null) { - throw exception(ROLE_ERROR); - } - - List collect = userRoleDO.stream().map(item -> item.getRoleId()).collect(Collectors.toList()); - if (collect.contains(164l) || collect.contains(1l)) { - // 全部权限,不需要设置任何条件 - roleNameAndSelectTypeVO.setRoleName("director"); - } else if (collect.contains(163L)) { - // 本部门权限 - roleNameAndSelectTypeVO.setRoleName("queue"); - roleNameAndSelectTypeVO.setValue(user.getDeptId()); - } else { - // 仅自己权限 - roleNameAndSelectTypeVO.setRoleName("self"); - roleNameAndSelectTypeVO.setValue(loginUserId); - roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); - - } + //如果岗位不存在查询角色 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(UserRoleDO::getUserId, loginUserId); + List userRoleDO = userRoleMapper.selectList(wrapper); + + if (userRoleDO == null) { + throw exception(ROLE_ERROR); + } + + List collect = userRoleDO.stream().map(item -> item.getRoleId()).collect(Collectors.toList()); + if (collect.contains(164l) || collect.contains(1l)) { + // 全部权限,不需要设置任何条件 + roleNameAndSelectTypeVO.setRoleName("director"); + } else if (collect.contains(163L)) { + // 本部门权限 + roleNameAndSelectTypeVO.setRoleName("queue"); + roleNameAndSelectTypeVO.setValue(user.getDeptId()); + } else { + // 仅自己权限 + roleNameAndSelectTypeVO.setRoleName("self"); + roleNameAndSelectTypeVO.setValue(loginUserId); + roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); } + } else { throw exception(USER_NOT_EXISTS); } From 5983474cf4f5d21b27b81c4be601de2c9304822a Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Tue, 25 Feb 2025 17:38:47 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/taskinfo/TaskInfoController.java | 5 +- .../controller/admin/user/UserController.java | 9 +++ .../mysql/enterprise/EnterpriseMapper.java | 1 + .../dal/mysql/user/AdminUserMapper.java | 6 ++ .../system/job/TaskSendStartMessageJob.java | 7 +- .../EnterpriseInspectionsServiceImpl.java | 9 --- .../system/service/user/AdminUserService.java | 2 + .../service/user/AdminUserServiceImpl.java | 65 +++++++++++++++++++ 8 files changed, 92 insertions(+), 12 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java index 451ae55..b558b99 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java @@ -189,7 +189,10 @@ public class TaskInfoController { pageResult.getList().forEach(item->{ item.setPublishDep(dep.getName()); - item.setCreateName(adminUserService.getUser(Long.valueOf(item.getCreator())).getRealName()); + final AdminUserDO user1 = adminUserService.getUser(Long.valueOf(item.getCreator())); + if (user1 != null) { + item.setCreateName(user1.getRealName()); + } enterpriseInspectionsPageReqVO.setTaskId(item.getId()); List enterpriseInspectionsides=enterpriseInspectionsService.getEnterpriseInspectionsList(enterpriseInspectionsPageReqVO); EnterprisePageReqVO enterprisePageReqVO=new EnterprisePageReqVO(); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java index f14ac09..68ec662 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java @@ -77,6 +77,15 @@ public class UserController { return success(true); } + @DeleteMapping("/test_delete") + @Operation(summary = "测试时,删除用户所有信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:user:delete')") + public CommonResult testDeleteUser(@RequestParam("id") Long id) { + userService.testDeleteUser(id); + return success(true); + } + @PutMapping("/update-password") @Operation(summary = "重置用户密码") @PreAuthorize("@ss.hasPermission('system:user:update-password')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java index 5a60ee5..a4ea297 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java @@ -73,4 +73,5 @@ public interface EnterpriseMapper extends BaseMapperX { } IPage getAppPage(Page page, @Param("params") EnterprisePageReqVO pageReqVO); + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index bd4dcd1..950a1a8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import java.util.Collection; @@ -50,4 +51,9 @@ public interface AdminUserMapper extends BaseMapperX { return selectList(AdminUserDO::getDeptId, deptIds); } + @Delete("delete from system_oauth2_access_token where user_id = #{userId}") + Long deleteOauth2AccessAuth(Long userId); + + @Delete("delete from system_oauth2_refresh_token where user_id = #{userId}") + Long deleteOauth2RefreshAuth(Long userId); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java index e972608..2f1c69f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java @@ -76,7 +76,7 @@ public class TaskSendStartMessageJob implements JobHandler { //执法任务更改状态 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getId()); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getTaskId()); List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0) { List list = new ArrayList<>(); @@ -88,8 +88,11 @@ public class TaskSendStartMessageJob implements JobHandler { Map templateParams = new HashMap<>(); templateParams.put("title", beforeTaskInfo.getTitle()); templateParams.put("startTime", beforeTaskInfo.getStartDate()); + templateParams.put("endTime", beforeTaskInfo.getEndDate()); + templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId()); + notifyMessage.setTemplateParams(templateParams); - notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); + notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); enterpriseInspectionsDO.setStatus(2); list.add(enterpriseInspectionsDO); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java index 78b7293..e16f018 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java @@ -193,15 +193,6 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe } } -// if ("queue".equals(typeVO.getRoleName())) { -// pageReqVO.setDepartmentId(typeVO.getValue()); -// final List adminUserDOS = adminUserMapper.selectList(new QueryWrapper().eq("dept_id", typeVO.getValue())); -// if (adminUserDOS != null || adminUserDOS.size() > 0) { -// final List collect = adminUserDOS.stream().map(item -> item.getId()).collect(Collectors.toList()); -// pageReqVO.setUserIds(collect); -// } -// } - //按照部门查询 if (pageReqVO.getDepartmentId() != null) { final List adminUserDOS = adminUserMapper.selectList(new QueryWrapper().eq("dept_id", pageReqVO.getDepartmentId())); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java index 89dad96..1b53fb7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java @@ -230,4 +230,6 @@ public interface AdminUserService { List getSimpleUserZGList(); List getSimpleEnterpriseUserList(Integer type); + + void testDeleteUser(Long id); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 5383bc0..5c78025 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -23,12 +23,19 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*; import cn.iocoder.yudao.module.system.controller.admin.userAuditlog.vo.UserAuditLogSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; +import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.userAuditlog.UserAuditLogDO; import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; +import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; +import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper; import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; +import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper; +import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.dal.mysql.userAuditlog.UserAuditLogMapper; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; @@ -38,6 +45,7 @@ import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.tenant.TenantService; import cn.iocoder.yudao.module.system.service.userAuditlog.UserAuditLogService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.service.impl.DiffParseFunction; @@ -100,6 +108,15 @@ public class AdminUserServiceImpl implements AdminUserService { private AdminUserMapper adminUserMapper; @Resource private UserRoleMapper userRoleMapper; + @Resource + private SocialUserBindMapper socialUserBindMapper; + @Resource + private SocialUserMapper socialUserMapper; + @Resource + private EnterpriseMapper enterpriseMapper; + @Resource + private EnterpriseInspectionsMapper enterpriseInspectionsMapper; + @Override @Transactional(rollbackFor = Exception.class) @@ -288,6 +305,23 @@ public class AdminUserServiceImpl implements AdminUserService { permissionService.processUserDeleted(id); // 2.2 删除用户岗位 userPostMapper.deleteByUserId(id); + // 2.3 删除社交用户 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", id); + final SocialUserBindDO socialUserBindDO = socialUserBindMapper.selectById(wrapper); + socialUserMapper.deleteById(socialUserBindDO.getSocialUserId()); + socialUserBindMapper.deleteById(socialUserBindDO.getId()); + //2.4 删除 token 数据 + adminUserMapper.deleteOauth2AccessAuth(id); + adminUserMapper.deleteOauth2RefreshAuth(id); + //2.5 删除 企业 + QueryWrapper enterpriseDOQueryWrapper = new QueryWrapper<>(); + enterpriseDOQueryWrapper.eq("user_id", id); + enterpriseMapper.delete(enterpriseDOQueryWrapper); + //2.6 执法 + QueryWrapper inspectionsDOQueryWrapper = new QueryWrapper<>(); + inspectionsDOQueryWrapper.eq("user_id", id); + enterpriseInspectionsMapper.delete(inspectionsDOQueryWrapper); // 3. 记录操作日志上下文 LogRecordContext.putVariable("user", user); @@ -622,6 +656,37 @@ public class AdminUserServiceImpl implements AdminUserService { return adminUserMapper.selectList(wrapper); } + @Override + public void testDeleteUser(Long id) { + // 1. 校验用户存在 + AdminUserDO user = validateUserExists(id); + // 2.1 删除用户 + userMapper.deleteById(id); + // 2.2 删除用户关联数据 + permissionService.processUserDeleted(id); + // 2.2 删除用户岗位 + userPostMapper.deleteByUserId(id); + // 2.3 删除社交用户 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", id); + final SocialUserBindDO socialUserBindDO = socialUserBindMapper.selectOne(wrapper); + socialUserMapper.deleteById(socialUserBindDO.getSocialUserId()); + socialUserBindMapper.deleteById(socialUserBindDO.getId()); + //2.4 删除 token 数据 + adminUserMapper.deleteOauth2AccessAuth(id); + adminUserMapper.deleteOauth2RefreshAuth(id); + //2.5 删除 企业 + QueryWrapper enterpriseDOQueryWrapper = new QueryWrapper<>(); + enterpriseDOQueryWrapper.eq("user_id", id); + enterpriseMapper.delete(enterpriseDOQueryWrapper); + //2.6 执法 + QueryWrapper inspectionsDOQueryWrapper = new QueryWrapper<>(); + inspectionsDOQueryWrapper.eq("user_id", id); + enterpriseInspectionsMapper.delete(inspectionsDOQueryWrapper); + // 3. 记录操作日志上下文 + LogRecordContext.putVariable("user", user); + } + public void bindSocialUser(Long userId, AuthUser authUser) { // SocialUserDO socialUser = new SocialUserDO(); // socialUser.setUserId(userId); From eaca09cf91db1e286007f97240f1a67420828808 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Tue, 25 Feb 2025 18:03:00 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/enterprise/EnterpriseMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml index 0f23eca..433e850 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml @@ -11,7 +11,7 @@