疯狂的狮子li
2021-04-12 4500db395fdad42c7689e17ef6e3965a6caebdcc
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.lang.Validator;
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;
@@ -18,8 +19,7 @@
 * @author ruoyi
 */
@Service
public class SysPostServiceImpl implements ISysPostService
{
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService {
    @Autowired
    private SysPostMapper postMapper;
@@ -33,8 +33,7 @@
     * @return 岗位信息集合
     */
    @Override
    public List<SysPost> selectPostList(SysPost post)
    {
    public List<SysPost> selectPostList(SysPost post) {
        return postMapper.selectPostList(post);
    }
@@ -44,8 +43,7 @@
     * @return 岗位列表
     */
    @Override
    public List<SysPost> selectPostAll()
    {
    public List<SysPost> selectPostAll() {
        return postMapper.selectPostAll();
    }
@@ -56,8 +54,7 @@
     * @return 角色对象信息
     */
    @Override
    public SysPost selectPostById(Long postId)
    {
    public SysPost selectPostById(Long postId) {
        return postMapper.selectPostById(postId);
    }
@@ -68,8 +65,7 @@
     * @return 选中岗位ID列表
     */
    @Override
    public List<Integer> selectPostListByUserId(Long userId)
    {
    public List<Integer> selectPostListByUserId(Long userId) {
        return postMapper.selectPostListByUserId(userId);
    }
@@ -80,12 +76,10 @@
     * @return 结果
     */
    @Override
    public String checkPostNameUnique(SysPost post)
    {
    public String checkPostNameUnique(SysPost post) {
        Long postId = Validator.isNull(post.getPostId()) ? -1L : post.getPostId();
        SysPost info = postMapper.checkPostNameUnique(post.getPostName());
        if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
        {
        if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
@@ -98,12 +92,10 @@
     * @return 结果
     */
    @Override
    public String checkPostCodeUnique(SysPost post)
    {
    public String checkPostCodeUnique(SysPost post) {
        Long postId = Validator.isNull(post.getPostId()) ? -1L : post.getPostId();
        SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
        if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
        {
        if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
@@ -116,8 +108,7 @@
     * @return 结果
     */
    @Override
    public int countUserPostById(Long postId)
    {
    public int countUserPostById(Long postId) {
        return userPostMapper.countUserPostById(postId);
    }
@@ -128,8 +119,7 @@
     * @return 结果
     */
    @Override
    public int deletePostById(Long postId)
    {
    public int deletePostById(Long postId) {
        return postMapper.deletePostById(postId);
    }
@@ -141,13 +131,10 @@
     * @throws Exception 异常
     */
    @Override
    public int deletePostByIds(Long[] postIds)
    {
        for (Long postId : postIds)
        {
    public int deletePostByIds(Long[] postIds) {
        for (Long postId : postIds) {
            SysPost post = selectPostById(postId);
            if (countUserPostById(postId) > 0)
            {
            if (countUserPostById(postId) > 0) {
                throw new CustomException(String.format("%1$s已分配,不能删除", post.getPostName()));
            }
        }
@@ -161,8 +148,7 @@
     * @return 结果
     */
    @Override
    public int insertPost(SysPost post)
    {
    public int insertPost(SysPost post) {
        return postMapper.insertPost(post);
    }
@@ -173,8 +159,7 @@
     * @return 结果
     */
    @Override
    public int updatePost(SysPost post)
    {
    public int updatePost(SysPost post) {
        return postMapper.updatePost(post);
    }
}