| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.project.system.mapper.SysPostMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserPostMapper;
|
| | | import com.ruoyi.project.system.service.ISysPostService;
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | @Autowired
|
| | | private SysPostMapper postMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysUserPostMapper userPostMapper;
|
| | |
|
| | | /**
|
| | | * 查询岗位信息集合
|
| | |
| | | return postMapper.selectPostListByUserId(userId);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 校验岗位名称是否唯一
|
| | | *
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 通过岗位ID查询岗位使用数量
|
| | | * |
| | | * @param postId 岗位ID
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public int countUserPostById(Long postId)
|
| | | {
|
| | | return userPostMapper.countUserPostById(postId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除岗位信息
|
| | | *
|
| | | * @param postId 岗位ID
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 批量删除岗位信息
|
| | | * |
| | | * @param postIds 需要删除的岗位ID
|
| | | * @return 结果
|
| | | * @throws Exception 异常
|
| | | */
|
| | | public int deletePostByIds(Long[] postIds)
|
| | | {
|
| | | for (Long postId : postIds)
|
| | | {
|
| | | SysPost post = selectPostById(postId);
|
| | | if (countUserPostById(postId) > 0)
|
| | | {
|
| | | throw new CustomException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
| | | }
|
| | | }
|
| | | return postMapper.deletePostByIds(postIds);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新增保存岗位信息
|
| | | *
|
| | | * @param post 岗位信息
|