角色列表页面权限分配.
This commit is contained in:
@@ -2,6 +2,10 @@ package com.xuxd.kafka.console.beans.dto;
|
||||
|
||||
import com.xuxd.kafka.console.beans.dos.SysRoleDO;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: xuxd
|
||||
@@ -16,14 +20,16 @@ public class SysRoleDTO {
|
||||
|
||||
private String description;
|
||||
|
||||
private String permissionIds;
|
||||
private List<String> permissionIds;
|
||||
|
||||
public SysRoleDO toDO() {
|
||||
SysRoleDO roleDO = new SysRoleDO();
|
||||
roleDO.setId(this.id);
|
||||
roleDO.setRoleName(this.roleName);
|
||||
roleDO.setDescription(this.description);
|
||||
roleDO.setPermissionIds(this.permissionIds);
|
||||
if (CollectionUtils.isNotEmpty(permissionIds)) {
|
||||
roleDO.setPermissionIds(StringUtils.join(this.permissionIds, ","));
|
||||
}
|
||||
return roleDO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ public class UserManageController {
|
||||
return userManageService.addUser(userDTO);
|
||||
}
|
||||
|
||||
@ControllerLog("新增角色")
|
||||
@ControllerLog("新增/更新角色")
|
||||
@PostMapping("/role")
|
||||
public Object addRole(@RequestBody SysRoleDTO roleDTO) {
|
||||
return userManageService.addRole(roleDTO);
|
||||
public Object addOrUpdateRole(@RequestBody SysRoleDTO roleDTO) {
|
||||
return userManageService.addOrUdpateRole(roleDTO);
|
||||
}
|
||||
|
||||
@ControllerLog("新增权限")
|
||||
@@ -54,4 +54,9 @@ public class UserManageController {
|
||||
public Object selectPermission() {
|
||||
return userManageService.selectPermission();
|
||||
}
|
||||
|
||||
@DeleteMapping("/role")
|
||||
public Object deleteRole(@RequestParam Long id) {
|
||||
return userManageService.deleteRole(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface UserManageService {
|
||||
*/
|
||||
ResponseData addPermission(SysPermissionDTO permissionDTO);
|
||||
|
||||
ResponseData addRole(SysRoleDTO roleDTO);
|
||||
ResponseData addOrUdpateRole(SysRoleDTO roleDTO);
|
||||
|
||||
ResponseData addUser(SysUserDTO userDTO);
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface UserManageService {
|
||||
ResponseData updateUser(SysUserDTO userDTO);
|
||||
|
||||
ResponseData updateRole(SysRoleDTO roleDTO);
|
||||
|
||||
ResponseData deleteRole(Long id);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,13 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData addRole(SysRoleDTO roleDTO) {
|
||||
roleMapper.insert(roleDTO.toDO());
|
||||
public ResponseData addOrUdpateRole(SysRoleDTO roleDTO) {
|
||||
SysRoleDO roleDO = roleDTO.toDO();
|
||||
if (roleDO.getId() == null) {
|
||||
roleMapper.insert(roleDO);
|
||||
} else {
|
||||
roleMapper.updateById(roleDO);
|
||||
}
|
||||
return ResponseData.create().success();
|
||||
}
|
||||
|
||||
@@ -132,4 +137,10 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
roleMapper.updateById(roleDTO.toDO());
|
||||
return ResponseData.create().success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData deleteRole(Long id) {
|
||||
roleMapper.deleteById(id);
|
||||
return ResponseData.create().success();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user