|
@@ -1,16 +1,20 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
import com.ruoyi.common.exception.CustomException;
|
|
|
import com.ruoyi.system.domain.SysPost;
|
|
|
+import com.ruoyi.system.domain.SysUserPost;
|
|
|
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 org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -20,8 +24,6 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService {
|
|
|
- @Autowired
|
|
|
- private SysPostMapper postMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SysUserPostMapper userPostMapper;
|
|
@@ -34,7 +36,10 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public List<SysPost> selectPostList(SysPost post) {
|
|
|
- return postMapper.selectPostList(post);
|
|
|
+ return list(new LambdaQueryWrapper<SysPost>()
|
|
|
+ .like(StrUtil.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
|
|
+ .eq(StrUtil.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
|
|
+ .like(StrUtil.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -44,7 +49,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public List<SysPost> selectPostAll() {
|
|
|
- return postMapper.selectPostAll();
|
|
|
+ return list();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -55,7 +60,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public SysPost selectPostById(Long postId) {
|
|
|
- return postMapper.selectPostById(postId);
|
|
|
+ return getById(postId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -66,7 +71,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public List<Integer> selectPostListByUserId(Long userId) {
|
|
|
- return postMapper.selectPostListByUserId(userId);
|
|
|
+ return baseMapper.selectPostListByUserId(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -78,7 +83,8 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
@Override
|
|
|
public String checkPostNameUnique(SysPost post) {
|
|
|
Long postId = Validator.isNull(post.getPostId()) ? -1L : post.getPostId();
|
|
|
- SysPost info = postMapper.checkPostNameUnique(post.getPostName());
|
|
|
+ SysPost info = getOne(new LambdaQueryWrapper<SysPost>()
|
|
|
+ .eq(SysPost::getPostName, post.getPostName()).last("limit 1"));
|
|
|
if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
}
|
|
@@ -94,7 +100,8 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
@Override
|
|
|
public String checkPostCodeUnique(SysPost post) {
|
|
|
Long postId = Validator.isNull(post.getPostId()) ? -1L : post.getPostId();
|
|
|
- SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
|
|
|
+ SysPost info = getOne(new LambdaQueryWrapper<SysPost>()
|
|
|
+ .eq(SysPost::getPostCode, post.getPostCode()).last("limit 1"));
|
|
|
if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
}
|
|
@@ -109,7 +116,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public int countUserPostById(Long postId) {
|
|
|
- return userPostMapper.countUserPostById(postId);
|
|
|
+ return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId,postId));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -120,7 +127,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public int deletePostById(Long postId) {
|
|
|
- return postMapper.deletePostById(postId);
|
|
|
+ return baseMapper.deleteById(postId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -138,7 +145,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
throw new CustomException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
|
|
}
|
|
|
}
|
|
|
- return postMapper.deletePostByIds(postIds);
|
|
|
+ return baseMapper.deleteBatchIds(Arrays.asList(postIds));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -149,7 +156,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertPost(SysPost post) {
|
|
|
- return postMapper.insertPost(post);
|
|
|
+ return baseMapper.insert(post);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -160,6 +167,6 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public int updatePost(SysPost post) {
|
|
|
- return postMapper.updatePost(post);
|
|
|
+ return baseMapper.updateById(post);
|
|
|
}
|
|
|
}
|