From 17167c24d17647c0facb070b3cc741a34629ab43 Mon Sep 17 00:00:00 2001 From: anzhen Date: Fri, 15 Apr 2022 15:56:47 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E7=BC=96=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/ruoyi-vue-pro.sql | 6 ++++-- .../module/system/dal/mysql/dept/UserPostMapper.java | 10 ++++------ .../system/service/user/AdminUserServiceImpl.java | 3 +-- .../src/test/resources/sql/create_tables.sql | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/sql/ruoyi-vue-pro.sql b/sql/ruoyi-vue-pro.sql index cee359d62..1276115db 100644 --- a/sql/ruoyi-vue-pro.sql +++ b/sql/ruoyi-vue-pro.sql @@ -2430,8 +2430,10 @@ CREATE TABLE `system_user_post` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='部门表'; - +) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户岗位表'; +insert into system_user_post (user_id, post_id, creator, create_time, updater, update_time, deleted, tenant_id) value (1,1,'admin',current_timestamp,'admin',current_timestamp,false,1); +insert into system_user_post (user_id, post_id, creator, create_time, updater, update_time, deleted, tenant_id) value (100,1,'admin',current_timestamp,'admin',current_timestamp,false,1); +insert into system_user_post (user_id, post_id, creator, create_time, updater, update_time, deleted, tenant_id) value (114,3,'admin',current_timestamp,'admin',current_timestamp,false,1); -- ---------------------------- -- Table structure for system_dept diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java index f91ce2ef6..cf8112485 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java @@ -14,18 +14,16 @@ public interface UserPostMapper extends BaseMapperX { default List selectIdList(Long id) { return selectList(new LambdaQueryWrapperX() - .eq(UserPostDO::getUserId, id) - .select(UserPostDO::getPostId)); - + .eq(UserPostDO::getUserId, id)); } - default void deleteByUserIdAndPostId(Long userId, Collection deletePostIds) { + default void deleteByUserIdAndPostId(Long userId, Collection postIds) { delete(new LambdaQueryWrapperX() .eq(UserPostDO::getUserId, userId) - .in(UserPostDO::getPostId, deletePostIds)); + .in(UserPostDO::getPostId, postIds)); } - default List selectUserIdByPostIds(Collection postIds) { + default List selectListByPostIds(Collection postIds) { return selectList(new LambdaQueryWrapperX() .in(UserPostDO::getPostId, postIds)); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 5be5ff16f..b90d5cf73 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -27,7 +27,6 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService; import cn.iocoder.yudao.module.system.service.dept.PostService; import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -266,7 +265,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (CollUtil.isEmpty(postIds)) { return Collections.emptyList(); } - List userIdList = userPostMapper.selectUserIdByPostIds(postIds) + List userIdList = userPostMapper.selectListByPostIds(postIds) .stream() .map(UserPostDO::getUserId) .distinct() diff --git a/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/create_tables.sql b/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/create_tables.sql index cef6b1424..a3097b3ec 100644 --- a/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/create_tables.sql +++ b/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/create_tables.sql @@ -156,7 +156,7 @@ CREATE TABLE IF NOT EXISTS `system_user_post`( "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint not null default '0', PRIMARY KEY (`id`) -) COMMENT ='部门表'; +) COMMENT ='用户岗位表'; CREATE TABLE IF NOT EXISTS "system_notice" (