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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.kiisoo.ic.system.controller ;
import com.kiisoo.ic.common.BaseController ;
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
//@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
@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 ( ) ;
}
}
}