You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bsdgy-server/src/main/java/com/kiisoo/ic/system/controller/PrivilageRoleController.java

123 lines
3.4 KiB
Java

package com.kiisoo.ic.system.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.system.bean.PrivilageRoleAccountBean;
import com.kiisoo.ic.system.entity.PrivilageRoleDO;
import com.kiisoo.ic.system.service.PrivilageRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
*
* @author jinchaofan
* @since 2020-02-19
*/
@Slf4j
@RestController
@RequestMapping("/role")
public class PrivilageRoleController extends BaseController {
/**
* service
*/
@Autowired
private PrivilageRoleService privilageRoleService;
/**
*
* @param roleName
* @return
*/
@ResponseBody
@PostMapping("/add")
public Map<String, Object> addRole(@RequestParam("roleName") String roleName) {
try {
boolean flag = privilageRoleService.addRole(roleName);
//成功为0000失败为0002
return flag ? data(Boolean.TRUE) : fail(0);
} catch (Exception e) {
log.error("添加角色出错", e);
return fail();
}
}
/**
/**
*
* @param roleId id
* @return
*/
@ResponseBody
@GetMapping("/remove")
public Map<String, Object> removeRole(@RequestParam("roleId") Long roleId) {
try {
boolean flag = privilageRoleService.removeRole(roleId);
//成功为0000存在业务不能删除为0002
return flag ? data(Boolean.TRUE) : fail(0);
} catch (Exception e) {
log.error("添加角色出错", e);
return fail();
}
}
/**
*
* @return
*/
@ResponseBody
@GetMapping("/info/list")
public Map<String, Object> listRoleInfo() {
try {
List<PrivilageRoleDO> privilageRoleDOS = privilageRoleService.listRoleInfo();
return data(privilageRoleDOS);
} catch (Exception e) {
log.error("查询角色信息出错", e);
return fail();
}
}
/**
* code
* @param roleId id
* @param roleName
* @return
*/
@ResponseBody
@PostMapping("/modify/role")
public Map<String,Object> modifyRole(@RequestParam("roleId") Long roleId,@RequestParam("roleName") String roleName){
try{
boolean bl = privilageRoleService.modifyRole(roleId,roleName);
if(bl){
return success();
}else {
return fail();
}
}catch (Exception e){
log.error("修改角色失败",e);
return fail();
}
}
/**
*
* @return
*/
@ResponseBody
@GetMapping("/role/account/count")
public Map<String,Object> listOfRoleAndAccountCount(){
try{
List<PrivilageRoleAccountBean> accountBeans = privilageRoleService.listOfRoleAndAccountCount();
return data(accountBeans);
}catch (Exception e){
log.error("查询角色和角色的账户个数失败",e);
return fail();
}
}
}