cee572f2
RuoYi
若依 3.0
|
1
|
package com.ruoyi.system.service.impl;
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
2
3
4
5
6
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
|
bcee37b8
RuoYi
若依 1.1
|
7
|
import com.ruoyi.common.exception.CustomException;
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
8
|
import com.ruoyi.common.utils.StringUtils;
|
cee572f2
RuoYi
若依 3.0
|
9
10
11
12
|
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.ISysPostService;
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
13
14
15
16
17
18
19
20
21
22
23
24
|
/**
* 岗位信息 服务层处理
*
* @author ruoyi
*/
@Service
public class SysPostServiceImpl implements ISysPostService
{
@Autowired
private SysPostMapper postMapper;
|
bcee37b8
RuoYi
若依 1.1
|
25
26
27
|
@Autowired
private SysUserPostMapper userPostMapper;
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/**
* 查询岗位信息集合
*
* @param post 岗位信息
* @return 岗位信息集合
*/
@Override
public List<SysPost> selectPostList(SysPost post)
{
return postMapper.selectPostList(post);
}
/**
* 查询所有岗位
*
* @return 岗位列表
*/
@Override
public List<SysPost> selectPostAll()
{
return postMapper.selectPostAll();
}
/**
* 通过岗位ID查询岗位信息
*
* @param postId 岗位ID
* @return 角色对象信息
*/
@Override
public SysPost selectPostById(Long postId)
{
return postMapper.selectPostById(postId);
}
/**
* 根据用户ID获取岗位选择框列表
*
* @param userId 用户ID
* @return 选中岗位ID列表
*/
|
f39be3ab
Sxile
添加缺少的@ Override
|
69
|
@Override
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
70
71
72
73
74
|
public List<Integer> selectPostListByUserId(Long userId)
{
return postMapper.selectPostListByUserId(userId);
}
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/**
* 校验岗位名称是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostNameUnique(SysPost post)
{
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* 校验岗位编码是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostCodeUnique(SysPost post)
{
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
|
bcee37b8
RuoYi
若依 1.1
|
112
113
114
115
116
117
118
119
120
121
122
123
|
* 通过岗位ID查询岗位使用数量
*
* @param postId 岗位ID
* @return 结果
*/
@Override
public int countUserPostById(Long postId)
{
return userPostMapper.countUserPostById(postId);
}
/**
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
124
125
126
127
128
129
130
131
132
133
134
135
|
* 删除岗位信息
*
* @param postId 岗位ID
* @return 结果
*/
@Override
public int deletePostById(Long postId)
{
return postMapper.deletePostById(postId);
}
/**
|
bcee37b8
RuoYi
若依 1.1
|
136
137
138
139
140
141
|
* 批量删除岗位信息
*
* @param postIds 需要删除的岗位ID
* @return 结果
* @throws Exception 异常
*/
|
f39be3ab
Sxile
添加缺少的@ Override
|
142
|
@Override
|
bcee37b8
RuoYi
若依 1.1
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
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);
}
/**
|
46444bd0
RuoYi
RuoYi-Vue 1.0
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
* 新增保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
@Override
public int insertPost(SysPost post)
{
return postMapper.insertPost(post);
}
/**
* 修改保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
@Override
public int updatePost(SysPost post)
{
return postMapper.updatePost(post);
}
}
|