update 优化 岗位如果绑定了用户则不允许禁用
This commit is contained in:
parent
dc752ade25
commit
2f3dbbfe32
@ -88,6 +88,9 @@ public class SysPostController extends BaseController {
|
|||||||
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (!postService.checkPostCodeUnique(post)) {
|
} else if (!postService.checkPostCodeUnique(post)) {
|
||||||
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
|
} else if (UserConstants.POST_DISABLE.equals(post.getStatus())
|
||||||
|
&& postService.countUserPostById(post.getPostId()) > 0) {
|
||||||
|
return R.fail("该岗位下存在已分配用户,不能禁用!");
|
||||||
}
|
}
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}
|
}
|
||||||
@ -109,7 +112,9 @@ public class SysPostController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysPost>> optionselect() {
|
public R<List<SysPost>> optionselect() {
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
SysPost post = new SysPost();
|
||||||
|
post.setStatus(UserConstants.POST_NORMAL);
|
||||||
|
List<SysPost> posts = postService.selectPostList(post);
|
||||||
return R.ok(posts);
|
return R.ok(posts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,16 @@ public interface UserConstants {
|
|||||||
*/
|
*/
|
||||||
String DEPT_DISABLE = "1";
|
String DEPT_DISABLE = "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位正常状态
|
||||||
|
*/
|
||||||
|
String POST_NORMAL = "0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位停用状态
|
||||||
|
*/
|
||||||
|
String POST_DISABLE = "1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典正常状态
|
* 字典正常状态
|
||||||
*/
|
*/
|
||||||
|
@ -147,7 +147,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||||||
for (Long postId : postIds) {
|
for (Long postId : postIds) {
|
||||||
SysPost post = selectPostById(postId);
|
SysPost post = selectPostById(postId);
|
||||||
if (countUserPostById(postId) > 0) {
|
if (countUserPostById(postId) > 0) {
|
||||||
throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return baseMapper.deleteBatchIds(Arrays.asList(postIds));
|
return baseMapper.deleteBatchIds(Arrays.asList(postIds));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user