From cc2624d08e422c36a4f93cc15d0ca0f0b7b4951a Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期一, 17 一月 2022 15:46:28 +0800
Subject: [PATCH] update 优化加载字典缓存数据

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
index 058d7ed..968ce2b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
@@ -4,7 +4,6 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.PageQuery;
-import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.StringUtils;
@@ -13,7 +12,7 @@
 import com.ruoyi.system.mapper.SysPostMapper;
 import com.ruoyi.system.mapper.SysUserPostMapper;
 import com.ruoyi.system.service.ISysPostService;
-import org.springframework.beans.factory.annotation.Autowired;
+import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
 import java.util.Arrays;
@@ -24,19 +23,20 @@
  *
  * @author Lion Li
  */
+@RequiredArgsConstructor
 @Service
-public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost, SysPost> implements ISysPostService {
+public class SysPostServiceImpl implements ISysPostService {
 
-    @Autowired
-    private SysUserPostMapper userPostMapper;
+    private final SysPostMapper baseMapper;
+    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 = page(pageQuery.build(), lqw);
+            .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);
         return TableDataInfo.build(page);
     }
 
@@ -48,10 +48,10 @@
      */
     @Override
     public List<SysPost> selectPostList(SysPost post) {
-        return list(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()));
+        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()));
     }
 
     /**
@@ -61,7 +61,7 @@
      */
     @Override
     public List<SysPost> selectPostAll() {
-        return list();
+        return baseMapper.selectList();
     }
 
     /**
@@ -72,7 +72,7 @@
      */
     @Override
     public SysPost selectPostById(Long postId) {
-        return getById(postId);
+        return baseMapper.selectById(postId);
     }
 
     /**
@@ -95,10 +95,10 @@
     @Override
     public String checkPostNameUnique(SysPost post) {
         Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
-        long count = count(new LambdaQueryWrapper<SysPost>()
-                .eq(SysPost::getPostName, post.getPostName())
-                .ne(SysPost::getPostId, postId));
-        if (count > 0) {
+        boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
+            .eq(SysPost::getPostName, post.getPostName())
+            .ne(SysPost::getPostId, postId));
+        if (count) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -113,10 +113,10 @@
     @Override
     public String checkPostCodeUnique(SysPost post) {
         Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
-        long count = count(new LambdaQueryWrapper<SysPost>()
-                .eq(SysPost::getPostCode, post.getPostCode())
-                .ne(SysPost::getPostId, postId));
-        if (count > 0) {
+        boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
+            .eq(SysPost::getPostCode, post.getPostCode())
+            .ne(SysPost::getPostId, postId));
+        if (count) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;

--
Gitblit v1.9.3