From 6502f2107229bd0e19a0ce5dd748b9e6e5e11367 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 26 十一月 2021 13:57:28 +0800
Subject: [PATCH] update 修改不规范命名
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 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 82d09e8..4e04f3a 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,7 @@
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysPost;
@@ -21,7 +21,7 @@
/**
* 宀椾綅淇℃伅 鏈嶅姟灞傚鐞�
*
- * @author ruoyi
+ * @author Lion Li
*/
@Service
public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost, SysPost> implements ISysPostService {
@@ -35,7 +35,7 @@
.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 PageUtils.buildDataInfo(page(PageUtils.buildPage(),lqw));
+ return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw));
}
/**
@@ -93,9 +93,10 @@
@Override
public String checkPostNameUnique(SysPost post) {
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
- SysPost info = getOne(new LambdaQueryWrapper<SysPost>()
- .eq(SysPost::getPostName, post.getPostName()).last("limit 1"));
- if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
+ long count = count(new LambdaQueryWrapper<SysPost>()
+ .eq(SysPost::getPostName, post.getPostName())
+ .ne(SysPost::getPostId, postId));
+ if (count > 0) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -110,9 +111,10 @@
@Override
public String checkPostCodeUnique(SysPost post) {
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
- SysPost info = getOne(new LambdaQueryWrapper<SysPost>()
- .eq(SysPost::getPostCode, post.getPostCode()).last("limit 1"));
- if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
+ long count = count(new LambdaQueryWrapper<SysPost>()
+ .eq(SysPost::getPostCode, post.getPostCode())
+ .ne(SysPost::getPostId, postId));
+ if (count > 0) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -125,8 +127,8 @@
* @return 缁撴灉
*/
@Override
- public int countUserPostById(Long postId) {
- return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId,postId));
+ public long countUserPostById(Long postId) {
+ return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId, postId));
}
/**
@@ -152,7 +154,7 @@
for (Long postId : postIds) {
SysPost post = selectPostById(postId);
if (countUserPostById(postId) > 0) {
- throw new CustomException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", post.getPostName()));
+ throw new ServiceException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", post.getPostName()));
}
}
return baseMapper.deleteBatchIds(Arrays.asList(postIds));
--
Gitblit v1.9.3