From 3cd135850ec0f6d5d43027870de03a2b191388e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=B4=9E?= Date: Wed, 30 Mar 2022 17:21:24 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=85=B3=E8=81=94=E8=A1=A8=E7=BB=B4=E6=8A=A4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=B2=97=E4=BD=8D=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/ruoyi-vue-pro.sql | 19 ++++++ .../dal/dataobject/dept/UserPostDO.java | 35 +++++++++++ .../system/dal/mysql/dept/UserPostMapper.java | 10 ++++ .../dal/mysql/user/AdminUserMapper.java | 3 + .../system/service/dept/UserPostService.java | 16 +++++ .../service/dept/UserPostServiceImpl.java | 19 ++++++ .../service/user/AdminUserServiceImpl.java | 58 +++++++++++++++++-- 7 files changed, 154 insertions(+), 6 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/UserPostDO.java create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java diff --git a/sql/ruoyi-vue-pro.sql b/sql/ruoyi-vue-pro.sql index 96183a703..cee359d62 100644 --- a/sql/ruoyi-vue-pro.sql +++ b/sql/ruoyi-vue-pro.sql @@ -2414,6 +2414,25 @@ CREATE TABLE `pay_refund` ( BEGIN; COMMIT; + +-- ---------------------------- +-- Table structure for system_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `system_user_post`; +CREATE TABLE `system_user_post` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `user_id` bigint NOT NULL DEFAULT '0' COMMENT '用户ID', + `post_id` bigint NOT NULL DEFAULT '0' COMMENT '岗位ID', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `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='部门表'; + + -- ---------------------------- -- Table structure for system_dept -- ---------------------------- diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/UserPostDO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/UserPostDO.java new file mode 100644 index 000000000..02401977e --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/UserPostDO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.system.dal.dataobject.dept; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 用户和岗位关联 + * + * @author ruoyi + */ +@TableName("system_user_post") +@Data +@EqualsAndHashCode(callSuper = true) +public class UserPostDO extends BaseDO { + + /** + * 自增主键 + */ + @TableId + private Long id; + /** + * 用户 ID + */ + private Long userId; + /** + * 角色 ID + */ + private Long postId; + +} 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 new file mode 100644 index 000000000..0e9345a86 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.system.dal.mysql.dept; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface UserPostMapper extends BaseMapperX { + +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index be4b5ea21..68acb7dcd 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -61,5 +61,8 @@ public interface AdminUserMapper extends BaseMapperX { return selectList(AdminUserDO::getDeptId, deptIds); } + default List selectListByIds(List userIdList) { + return selectList(new LambdaQueryWrapperX().in(AdminUserDO::getId, userIdList)); + } } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java new file mode 100644 index 000000000..4299c5cbe --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.system.service.dept; + +import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 工作流的表单定义 Mapper 接口 + *

+ * + * @author anzhen + * @since 2022-03-03 + */ +public interface UserPostService extends IService { + +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java new file mode 100644 index 000000000..5be2e17d0 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.system.service.dept; + +import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 工作流的表单定义 Mapper 接口 + *

+ * + * @author anzhen + * @since 2022-03-03 + */ +@Service +public class UserPostServiceImpl extends ServiceImpl implements UserPostService { + +} 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 32f0a8e8c..6457e84e8 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 @@ -13,12 +13,15 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfi import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*; import cn.iocoder.yudao.module.system.convert.user.UserConvert; 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.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; 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.dept.UserPostService; 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; @@ -29,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.InputStream; import java.util.*; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; @@ -59,11 +63,14 @@ public class AdminUserServiceImpl implements AdminUserService { @Resource private TenantService tenantService; + @Resource + private UserPostService userPostService; + @Resource private FileApi fileApi; @Override - + @Transactional(rollbackFor = Exception.class) public Long createUser(UserCreateReqVO reqVO) { // 校验账户配合 tenantService.handleTenantInfo(tenant -> { @@ -80,10 +87,22 @@ public class AdminUserServiceImpl implements AdminUserService { user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 user.setPassword(passwordEncoder.encode(reqVO.getPassword())); // 加密密码 userMapper.insert(user); + Set postIds = user.getPostIds(); + if (!org.springframework.util.CollectionUtils.isEmpty(postIds)) { + ArrayList userPostList = new ArrayList<>(); + for (Long postId : postIds) { + UserPostDO entity = new UserPostDO(); + entity.setUserId(entity.getUserId()); + entity.setPostId(postId); + userPostList.add(entity); + } + userPostService.saveBatch(userPostList); + } return user.getId(); } @Override + @Transactional(rollbackFor = Exception.class) public void updateUser(UserUpdateReqVO reqVO) { // 校验正确性 this.checkCreateOrUpdate(reqVO.getId(), reqVO.getUsername(), reqVO.getMobile(), reqVO.getEmail(), @@ -91,6 +110,19 @@ public class AdminUserServiceImpl implements AdminUserService { // 更新用户 AdminUserDO updateObj = UserConvert.INSTANCE.convert(reqVO); userMapper.updateById(updateObj); + Set postIds = updateObj.getPostIds(); + if (!org.springframework.util.CollectionUtils.isEmpty(postIds)) { + for (Long postId : postIds) { + UserPostDO entity = new UserPostDO(); + entity.setUserId(reqVO.getId()); + entity.setPostId(postId); + userPostService.saveOrUpdate(entity, + Wrappers.lambdaUpdate(UserPostDO.class) + .eq(UserPostDO::getUserId, entity.getUserId()) + .eq(UserPostDO::getPostId, entity.getPostId()) + ); + } + } } @Override @@ -154,6 +186,7 @@ public class AdminUserServiceImpl implements AdminUserService { } @Override + @Transactional(rollbackFor = Exception.class) public void deleteUser(Long id) { // 校验用户存在 this.checkUserExists(id); @@ -161,6 +194,8 @@ public class AdminUserServiceImpl implements AdminUserService { userMapper.deleteById(id); // 删除用户关联数据 permissionService.processUserDeleted(id); + + userPostService.remove(Wrappers.lambdaUpdate(UserPostDO.class).eq(UserPostDO::getUserId, id)); } @Override @@ -191,11 +226,22 @@ public class AdminUserServiceImpl implements AdminUserService { if (CollUtil.isEmpty(postIds)) { return Collections.emptyList(); } - // 过滤不符合条件的 - // TODO 芋艿:暂时只能内存过滤。解决方案:1、新建一个关联表;2、基于 where + 函数;3、json 字段,适合 mysql 8+ 版本 - List users = userMapper.selectList(); - users.removeIf(user -> !CollUtil.containsAny(user.getPostIds(), postIds)); - return users; + List userIdList = userPostService + .lambdaQuery() + .in(UserPostDO::getPostId, postIds) + .list() + .stream() + .map(UserPostDO::getUserId) + .distinct() + .collect(Collectors.toList()); + if (userIdList.isEmpty()) { + return Collections.emptyList(); + } + return userMapper + .selectListByIds(userIdList) + .stream() + .peek(user -> user.setPassword(null)) + .collect(Collectors.toList()); } @Override From 5fc1101900cf929d1dde909254ac469610126db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=B4=9E?= Date: Thu, 31 Mar 2022 09:11:02 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1=E3=80=81=E5=85=B3=E8=81=94=E8=A1=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=A2=9D=E5=A4=96=E7=9A=84service=E3=80=82?= =?UTF-8?q?=202=E3=80=81service=E4=B8=AD=E5=88=A0=E9=99=A4mybatis=20plus?= =?UTF-8?q?=20=E7=9A=84=E6=93=8D=E4=BD=9C=EF=BC=8C=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=E5=92=8C=E4=B8=9A=E5=8A=A1=E8=A7=A3=E8=80=A6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/dal/mysql/dept/UserPostMapper.java | 43 ++++++++++ .../system/service/dept/UserPostService.java | 16 ---- .../service/dept/UserPostServiceImpl.java | 19 ---- .../service/user/AdminUserServiceImpl.java | 86 +++++++++++-------- .../src/test/resources/sql/clean.sql | 1 + .../src/test/resources/sql/create_tables.sql | 14 +++ 6 files changed, 107 insertions(+), 72 deletions(-) delete mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java delete mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java 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 0e9345a86..a5f1fce84 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 @@ -1,10 +1,53 @@ package cn.iocoder.yudao.module.system.dal.mysql.dept; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; import org.apache.ibatis.annotations.Mapper; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + @Mapper public interface UserPostMapper extends BaseMapperX { + default List selectIdList(Long id) { + return selectList(new LambdaQueryWrapperX() + .eq(UserPostDO::getUserId, id) + .select(UserPostDO::getPostId) + ) + .stream() + .map(UserPostDO::getPostId) + .collect(Collectors.toList()); + + } + + default void insertList(Long userId, Collection createPostIds) { + List list = createPostIds + .stream() + .map(postId -> { + UserPostDO entity = new UserPostDO(); + entity.setUserId(userId); + entity.setPostId(postId); + return entity; + }) + .collect(Collectors.toList()); + insertBatch(list); + } + + default void deleteByUserAndPost(Long userId, Collection deletePostIds) { + delete(new LambdaQueryWrapperX() + .eq(UserPostDO::getUserId, userId) + .in(UserPostDO::getPostId, deletePostIds)); + } + + default List getUserIdByPostIds(Collection postIds) { + return selectList(new LambdaQueryWrapperX() + .in(UserPostDO::getPostId, postIds)) + .stream() + .map(UserPostDO::getUserId) + .distinct() + .collect(Collectors.toList()); + } } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java deleted file mode 100644 index 4299c5cbe..000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostService.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dept; - -import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - *

- * 工作流的表单定义 Mapper 接口 - *

- * - * @author anzhen - * @since 2022-03-03 - */ -public interface UserPostService extends IService { - -} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java deleted file mode 100644 index 5be2e17d0..000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dept/UserPostServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dept; - -import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 工作流的表单定义 Mapper 接口 - *

- * - * @author anzhen - * @since 2022-03-03 - */ -@Service -public class UserPostServiceImpl extends ServiceImpl implements UserPostService { - -} 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 6457e84e8..29b842676 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.service.user; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; @@ -10,15 +11,20 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserCreateReqVO; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserExportReqVO; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportExcelVO; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserUpdateReqVO; import cn.iocoder.yudao.module.system.convert.user.UserConvert; 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.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; 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.dept.UserPostService; 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; @@ -31,15 +37,28 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_COUNT_MAX; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_EMAIL_EXISTS; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IS_DISABLE; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_MOBILE_EXISTS; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_PASSWORD_FAILED; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS; /** * 后台用户 Service 实现类 - * * @author 芋道源码 */ @Service("adminUserService") @@ -64,7 +83,7 @@ public class AdminUserServiceImpl implements AdminUserService { private TenantService tenantService; @Resource - private UserPostService userPostService; + private UserPostMapper userPostMapper; @Resource private FileApi fileApi; @@ -81,7 +100,7 @@ public class AdminUserServiceImpl implements AdminUserService { }); // 校验正确性 this.checkCreateOrUpdate(null, reqVO.getUsername(), reqVO.getMobile(), reqVO.getEmail(), - reqVO.getDeptId(), reqVO.getPostIds()); + reqVO.getDeptId(), reqVO.getPostIds()); // 插入用户 AdminUserDO user = UserConvert.INSTANCE.convert(reqVO); user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 @@ -89,14 +108,14 @@ public class AdminUserServiceImpl implements AdminUserService { userMapper.insert(user); Set postIds = user.getPostIds(); if (!org.springframework.util.CollectionUtils.isEmpty(postIds)) { - ArrayList userPostList = new ArrayList<>(); + List userPostList = new ArrayList<>(); for (Long postId : postIds) { UserPostDO entity = new UserPostDO(); entity.setUserId(entity.getUserId()); entity.setPostId(postId); userPostList.add(entity); } - userPostService.saveBatch(userPostList); + userPostMapper.insertBatch(userPostList); } return user.getId(); } @@ -106,23 +125,25 @@ public class AdminUserServiceImpl implements AdminUserService { public void updateUser(UserUpdateReqVO reqVO) { // 校验正确性 this.checkCreateOrUpdate(reqVO.getId(), reqVO.getUsername(), reqVO.getMobile(), reqVO.getEmail(), - reqVO.getDeptId(), reqVO.getPostIds()); + reqVO.getDeptId(), reqVO.getPostIds()); // 更新用户 AdminUserDO updateObj = UserConvert.INSTANCE.convert(reqVO); userMapper.updateById(updateObj); + // 更新岗位 Set postIds = updateObj.getPostIds(); - if (!org.springframework.util.CollectionUtils.isEmpty(postIds)) { - for (Long postId : postIds) { - UserPostDO entity = new UserPostDO(); - entity.setUserId(reqVO.getId()); - entity.setPostId(postId); - userPostService.saveOrUpdate(entity, - Wrappers.lambdaUpdate(UserPostDO.class) - .eq(UserPostDO::getUserId, entity.getUserId()) - .eq(UserPostDO::getPostId, entity.getPostId()) - ); - } + Long userId = reqVO.getId(); + List dbPostIds = userPostMapper.selectIdList(userId); + // 计算新增和删除的岗位编号 + Collection createPostIds = CollUtil.subtract(postIds, dbPostIds); + Collection deletePostIds = CollUtil.subtract(dbPostIds, postIds); + // 执行新增和删除。对于已经授权的菜单,不用做任何处理 + if (!CollectionUtil.isEmpty(createPostIds)) { + userPostMapper.insertList(userId, createPostIds); } + if (!CollectionUtil.isEmpty(deletePostIds)) { + userPostMapper.deleteByUserAndPost(userId, deletePostIds); + } + } @Override @@ -194,8 +215,8 @@ public class AdminUserServiceImpl implements AdminUserService { userMapper.deleteById(id); // 删除用户关联数据 permissionService.processUserDeleted(id); - - userPostService.remove(Wrappers.lambdaUpdate(UserPostDO.class).eq(UserPostDO::getUserId, id)); + // 删除用户岗位 + userPostMapper.delete(Wrappers.lambdaUpdate(UserPostDO.class).eq(UserPostDO::getUserId, id)); } @Override @@ -226,14 +247,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (CollUtil.isEmpty(postIds)) { return Collections.emptyList(); } - List userIdList = userPostService - .lambdaQuery() - .in(UserPostDO::getPostId, postIds) - .list() - .stream() - .map(UserPostDO::getUserId) - .distinct() - .collect(Collectors.toList()); + List userIdList = userPostMapper.getUserIdByPostIds(postIds); if (userIdList.isEmpty()) { return Collections.emptyList(); } @@ -289,7 +303,6 @@ public class AdminUserServiceImpl implements AdminUserService { /** * 获得部门条件:查询指定部门的子部门编号们,包括自身 - * * @param deptId 部门编号 * @return 部门编号集合 */ @@ -298,7 +311,7 @@ public class AdminUserServiceImpl implements AdminUserService { return Collections.emptySet(); } Set deptIds = CollectionUtils.convertSet(deptService.getDeptsByParentIdFromCache( - deptId, true), DeptDO::getId); + deptId, true), DeptDO::getId); deptIds.add(deptId); // 包括自身 return deptIds; } @@ -386,7 +399,6 @@ public class AdminUserServiceImpl implements AdminUserService { /** * 校验旧密码 - * * @param id 用户 id * @param oldPassword 旧密码 */ @@ -408,12 +420,12 @@ public class AdminUserServiceImpl implements AdminUserService { throw exception(USER_IMPORT_LIST_IS_EMPTY); } UserImportRespVO respVO = UserImportRespVO.builder().createUsernames(new ArrayList<>()) - .updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build(); + .updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build(); importUsers.forEach(importUser -> { // 校验,判断是否有不符合的原因 try { checkCreateOrUpdate(null, null, importUser.getMobile(), importUser.getEmail(), - importUser.getDeptId(), null); + importUser.getDeptId(), null); } catch (ServiceException ex) { respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage()); return; @@ -422,7 +434,7 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO existUser = userMapper.selectByUsername(importUser.getUsername()); if (existUser == null) { userMapper.insert(UserConvert.INSTANCE.convert(importUser) - .setPassword(passwordEncoder.encode(userInitPassword))); // 设置默认密码 + .setPassword(passwordEncoder.encode(userInitPassword))); // 设置默认密码 respVO.getCreateUsernames().add(importUser.getUsername()); return; } diff --git a/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/clean.sql b/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/clean.sql index c709513b1..23e8cda25 100644 --- a/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/clean.sql +++ b/yudao-module-system/yudao-module-system-impl/src/test/resources/sql/clean.sql @@ -4,6 +4,7 @@ DELETE FROM "system_role"; DELETE FROM "system_role_menu"; DELETE FROM "system_menu"; DELETE FROM "system_user_role"; +DELETE FROM "system_user_post"; DELETE FROM "system_dict_type"; DELETE FROM "system_user_session"; DELETE FROM "system_post"; 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 5db3692e5..cef6b1424 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 @@ -145,6 +145,20 @@ CREATE TABLE IF NOT EXISTS "system_post" ( PRIMARY KEY ("id") ) COMMENT '岗位信息表'; +CREATE TABLE IF NOT EXISTS `system_user_post`( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "user_id" bigint DEFAULT NULL, + "post_id" bigint DEFAULT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint not null default '0', + PRIMARY KEY (`id`) +) COMMENT ='部门表'; + + CREATE TABLE IF NOT EXISTS "system_notice" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "title" varchar(50) NOT NULL COMMENT '公告标题', From 78c132e68dd823bf059ae0fbe817eedeb22f619d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=B4=9E?= Date: Thu, 31 Mar 2022 13:18:37 +0800 Subject: [PATCH 3/5] fix user id is null --- .../yudao/module/system/service/user/AdminUserServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 29b842676..e651b1513 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 @@ -111,7 +111,7 @@ public class AdminUserServiceImpl implements AdminUserService { List userPostList = new ArrayList<>(); for (Long postId : postIds) { UserPostDO entity = new UserPostDO(); - entity.setUserId(entity.getUserId()); + entity.setUserId(user.getId()); entity.setPostId(postId); userPostList.add(entity); } From 47447ded6b771894ab0e9e8c2ad4e4be248b0547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=B4=9E?= Date: Wed, 6 Apr 2022 13:58:08 +0800 Subject: [PATCH 4/5] =?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 --- .../system/dal/mysql/dept/UserPostMapper.java | 37 ++++---------- .../dal/mysql/user/AdminUserMapper.java | 3 -- .../service/user/AdminUserServiceImpl.java | 51 +++++++++++++------ 3 files changed, 45 insertions(+), 46 deletions(-) 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 a5f1fce84..f91ce2ef6 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 @@ -3,51 +3,34 @@ package cn.iocoder.yudao.module.system.dal.mysql.dept; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.apache.ibatis.annotations.Mapper; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; @Mapper public interface UserPostMapper extends BaseMapperX { - default List selectIdList(Long id) { + default List selectIdList(Long id) { return selectList(new LambdaQueryWrapperX() .eq(UserPostDO::getUserId, id) - .select(UserPostDO::getPostId) - ) - .stream() - .map(UserPostDO::getPostId) - .collect(Collectors.toList()); + .select(UserPostDO::getPostId)); } - default void insertList(Long userId, Collection createPostIds) { - List list = createPostIds - .stream() - .map(postId -> { - UserPostDO entity = new UserPostDO(); - entity.setUserId(userId); - entity.setPostId(postId); - return entity; - }) - .collect(Collectors.toList()); - insertBatch(list); - } - - default void deleteByUserAndPost(Long userId, Collection deletePostIds) { + default void deleteByUserIdAndPostId(Long userId, Collection deletePostIds) { delete(new LambdaQueryWrapperX() .eq(UserPostDO::getUserId, userId) .in(UserPostDO::getPostId, deletePostIds)); } - default List getUserIdByPostIds(Collection postIds) { + default List selectUserIdByPostIds(Collection postIds) { return selectList(new LambdaQueryWrapperX() - .in(UserPostDO::getPostId, postIds)) - .stream() - .map(UserPostDO::getUserId) - .distinct() - .collect(Collectors.toList()); + .in(UserPostDO::getPostId, postIds)); + } + + default void deleteByUserId(Long userId){ + delete(Wrappers.lambdaUpdate(UserPostDO.class).eq(UserPostDO::getUserId, userId)); } } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index 68acb7dcd..be4b5ea21 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -61,8 +61,5 @@ public interface AdminUserMapper extends BaseMapperX { return selectList(AdminUserDO::getDeptId, deptIds); } - default List selectListByIds(List userIdList) { - return selectList(new LambdaQueryWrapperX().in(AdminUserDO::getId, userIdList)); - } } 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 e651b1513..5be5ff16f 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 @@ -107,15 +107,14 @@ public class AdminUserServiceImpl implements AdminUserService { user.setPassword(passwordEncoder.encode(reqVO.getPassword())); // 加密密码 userMapper.insert(user); Set postIds = user.getPostIds(); - if (!org.springframework.util.CollectionUtils.isEmpty(postIds)) { - List userPostList = new ArrayList<>(); - for (Long postId : postIds) { + if (CollectionUtil.isNotEmpty(postIds)) { + List insertUserPostList = CollectionUtils.convertList(postIds, postId -> { UserPostDO entity = new UserPostDO(); entity.setUserId(user.getId()); entity.setPostId(postId); - userPostList.add(entity); - } - userPostMapper.insertBatch(userPostList); + return entity; + }); + userPostMapper.insertBatch(insertUserPostList); } return user.getId(); } @@ -130,20 +129,40 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO updateObj = UserConvert.INSTANCE.convert(reqVO); userMapper.updateById(updateObj); // 更新岗位 + updateUserPost(reqVO, updateObj); + + } + + private void updateUserPost(UserUpdateReqVO reqVO, AdminUserDO updateObj) { Set postIds = updateObj.getPostIds(); Long userId = reqVO.getId(); - List dbPostIds = userPostMapper.selectIdList(userId); + List dbPostIds = userPostMapper.selectIdList(userId) + .stream() + .map(UserPostDO::getPostId) + .collect(Collectors.toList()); // 计算新增和删除的岗位编号 Collection createPostIds = CollUtil.subtract(postIds, dbPostIds); Collection deletePostIds = CollUtil.subtract(dbPostIds, postIds); // 执行新增和删除。对于已经授权的菜单,不用做任何处理 if (!CollectionUtil.isEmpty(createPostIds)) { - userPostMapper.insertList(userId, createPostIds); + List list = createUserPost(userId, createPostIds); + userPostMapper.insertBatch(list); } if (!CollectionUtil.isEmpty(deletePostIds)) { - userPostMapper.deleteByUserAndPost(userId, deletePostIds); + userPostMapper.deleteByUserIdAndPostId(userId, deletePostIds); } + } + private List createUserPost(Long userId, Collection createPostIds) { + return createPostIds + .stream() + .map(postId -> { + UserPostDO entity = new UserPostDO(); + entity.setUserId(userId); + entity.setPostId(postId); + return entity; + }) + .collect(Collectors.toList()); } @Override @@ -216,7 +235,7 @@ public class AdminUserServiceImpl implements AdminUserService { // 删除用户关联数据 permissionService.processUserDeleted(id); // 删除用户岗位 - userPostMapper.delete(Wrappers.lambdaUpdate(UserPostDO.class).eq(UserPostDO::getUserId, id)); + userPostMapper.deleteByUserId(id); } @Override @@ -247,15 +266,15 @@ public class AdminUserServiceImpl implements AdminUserService { if (CollUtil.isEmpty(postIds)) { return Collections.emptyList(); } - List userIdList = userPostMapper.getUserIdByPostIds(postIds); + List userIdList = userPostMapper.selectUserIdByPostIds(postIds) + .stream() + .map(UserPostDO::getUserId) + .distinct() + .collect(Collectors.toList());; if (userIdList.isEmpty()) { return Collections.emptyList(); } - return userMapper - .selectListByIds(userIdList) - .stream() - .peek(user -> user.setPassword(null)) - .collect(Collectors.toList()); + return userMapper.selectBatchIds(userIdList); } @Override From 17167c24d17647c0facb070b3cc741a34629ab43 Mon Sep 17 00:00:00 2001 From: anzhen Date: Fri, 15 Apr 2022 15:56:47 +0800 Subject: [PATCH 5/5] =?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" (