|
@@ -2,7 +2,9 @@ package com.hssx.cloudmodel.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.hssx.cloudmodel.entity.Role;
|
|
import com.hssx.cloudmodel.entity.Role;
|
|
|
|
+import com.hssx.cloudmodel.entity.User;
|
|
import com.hssx.cloudmodel.mapper.RoleMapper;
|
|
import com.hssx.cloudmodel.mapper.RoleMapper;
|
|
|
|
+import com.hssx.cloudmodel.mapper.UserMapper;
|
|
import com.hssx.cloudmodel.service.RoleService;
|
|
import com.hssx.cloudmodel.service.RoleService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
@@ -24,6 +26,8 @@ import java.util.List;
|
|
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
|
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
|
@Autowired
|
|
@Autowired
|
|
RoleMapper roleMapper;
|
|
RoleMapper roleMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ UserMapper userMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg addAndUpdateRole(Role role, Integer flag) {
|
|
public HttpRespMsg addAndUpdateRole(Role role, Integer flag) {
|
|
@@ -50,9 +54,9 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|
public HttpRespMsg pageList(PageUtil page, String keyName) {
|
|
public HttpRespMsg pageList(PageUtil page, String keyName) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
QueryWrapper<Role> qw = new QueryWrapper<>();
|
|
QueryWrapper<Role> qw = new QueryWrapper<>();
|
|
- Integer start = (page.getPageNum()-1)*page.getPageSize();
|
|
|
|
- if(keyName !=null && !"".equals(keyName)){
|
|
|
|
- qw.like("role_name",keyName);
|
|
|
|
|
|
+ Integer start = (page.getPageNum() - 1) * page.getPageSize();
|
|
|
|
+ if (keyName != null && !"".equals(keyName)) {
|
|
|
|
+ qw.like("role_name", keyName);
|
|
}
|
|
}
|
|
Integer count = roleMapper.selectCount(qw);
|
|
Integer count = roleMapper.selectCount(qw);
|
|
page.setTotal(count);
|
|
page.setTotal(count);
|
|
@@ -67,4 +71,16 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|
public List<Role> getIdAndNamelist() {
|
|
public List<Role> getIdAndNamelist() {
|
|
return roleMapper.selectIdAndNamelist();
|
|
return roleMapper.selectIdAndNamelist();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg deleteById(Integer id) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ Integer count = userMapper.selectCount(new QueryWrapper<User>().eq("role_type", id));
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ msg.setError("该角色已被应用到用户中,暂不提供删除操作");
|
|
|
|
+ } else {
|
|
|
|
+ roleMapper.deleteById(id);
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|