From 45ac0f23e12ac2a45c6affe9e39d0897e4fad618 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期四, 16 二月 2023 17:06:10 +0800 Subject: [PATCH] !286 合并 多租户功能 * add 新增 ruoyi-common-tenant 多租户模块 全框架适配多租户改动 * update 优化 隐藏页面主键 * remove 移除 缓存列表功能(多租户缓存功能繁杂多样 没有办法在页面管理) * update 重构 全局缓存KEY 与 常用缓存KEY做区分 * update 重构 OssFactory 加载方式 改为每次比对配置做实例更新 * update 优化 SaTokenDao 改为 Bean 注入 便于扩展 * update 重构 项目初始化数据改为懒加载 不提供热加载 * update 重构 验证码开关使用配置文件(经调查少有动态开启需求) * update 优化 启用 sqlserver 高版本语法 简化sql脚本语法 * update 优化 DataPermissionHelper 增加 开启/关闭 忽略数据权限功能 * update 优化 连接池增加 keepaliveTime 探活参数 * update 优化 调整连接池最长生命周期 防止出现警告 * update 优化 代码生成页面模板 校验不必要的表单数据 * add 新增 StringUtils splitTo 与 splitList 方法 优化业务代码 --- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java | 55 +++++++++++++++++++++++++++++++++---------------------- 1 files changed, 33 insertions(+), 22 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 7d492d1..543946c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -1,7 +1,10 @@ package com.ruoyi.system.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.mybatis.core.page.PageQuery; @@ -10,6 +13,8 @@ import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysUserPost; +import com.ruoyi.system.domain.bo.SysPostBo; +import com.ruoyi.system.domain.vo.SysPostVo; import com.ruoyi.system.mapper.SysPostMapper; import com.ruoyi.system.mapper.SysUserPostMapper; import com.ruoyi.system.service.ISysPostService; @@ -32,12 +37,9 @@ private final SysUserPostMapper userPostMapper; @Override - public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) { - LambdaQueryWrapper<SysPost> lqw = new LambdaQueryWrapper<SysPost>() - .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) - .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) - .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); - Page<SysPost> page = baseMapper.selectPage(pageQuery.build(), lqw); + public TableDataInfo<SysPostVo> selectPagePostList(SysPostBo post, PageQuery pageQuery) { + LambdaQueryWrapper<SysPost> lqw = buildQueryWrapper(post); + Page<SysPostVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); return TableDataInfo.build(page); } @@ -48,11 +50,18 @@ * @return 宀椾綅淇℃伅闆嗗悎 */ @Override - public List<SysPost> selectPostList(SysPost post) { - return baseMapper.selectList(new LambdaQueryWrapper<SysPost>() - .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) - .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) - .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName())); + public List<SysPostVo> selectPostList(SysPostBo post) { + LambdaQueryWrapper<SysPost> lqw = buildQueryWrapper(post); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper<SysPost> buildQueryWrapper(SysPostBo bo) { + LambdaQueryWrapper<SysPost> lqw = Wrappers.lambdaQuery(); + lqw.like(StringUtils.isNotBlank(bo.getPostCode()), SysPost::getPostCode, bo.getPostCode()); + lqw.like(StringUtils.isNotBlank(bo.getPostName()), SysPost::getPostName, bo.getPostName()); + lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysPost::getStatus, bo.getStatus()); + lqw.orderByAsc(SysPost::getPostSort); + return lqw; } /** @@ -61,8 +70,8 @@ * @return 宀椾綅鍒楄〃 */ @Override - public List<SysPost> selectPostAll() { - return baseMapper.selectList(); + public List<SysPostVo> selectPostAll() { + return baseMapper.selectVoList(new QueryWrapper<>()); } /** @@ -72,8 +81,8 @@ * @return 瑙掕壊瀵硅薄淇℃伅 */ @Override - public SysPost selectPostById(Long postId) { - return baseMapper.selectById(postId); + public SysPostVo selectPostById(Long postId) { + return baseMapper.selectVoById(postId); } /** @@ -94,7 +103,7 @@ * @return 缁撴灉 */ @Override - public String checkPostNameUnique(SysPost post) { + public String checkPostNameUnique(SysPostBo post) { boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>() .eq(SysPost::getPostName, post.getPostName()) .ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId())); @@ -111,7 +120,7 @@ * @return 缁撴灉 */ @Override - public String checkPostCodeUnique(SysPost post) { + public String checkPostCodeUnique(SysPostBo post) { boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>() .eq(SysPost::getPostCode, post.getPostCode()) .ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId())); @@ -152,7 +161,7 @@ @Override public int deletePostByIds(Long[] postIds) { for (Long postId : postIds) { - SysPost post = selectPostById(postId); + SysPost post = baseMapper.selectById(postId); if (countUserPostById(postId) > 0) { throw new ServiceException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", post.getPostName())); } @@ -163,22 +172,24 @@ /** * 鏂板淇濆瓨宀椾綅淇℃伅 * - * @param post 宀椾綅淇℃伅 + * @param bo 宀椾綅淇℃伅 * @return 缁撴灉 */ @Override - public int insertPost(SysPost post) { + public int insertPost(SysPostBo bo) { + SysPost post = BeanUtil.toBean(bo, SysPost.class); return baseMapper.insert(post); } /** * 淇敼淇濆瓨宀椾綅淇℃伅 * - * @param post 宀椾綅淇℃伅 + * @param bo 宀椾綅淇℃伅 * @return 缁撴灉 */ @Override - public int updatePost(SysPost post) { + public int updatePost(SysPostBo bo) { + SysPost post = BeanUtil.toBean(bo, SysPost.class); return baseMapper.updateById(post); } } -- Gitblit v1.9.3