|
@@ -3,9 +3,10 @@ import com.gihon.common.web.response.Response;
|
|
|
import com.gihon.common.web.response.ResponseStatus;
|
|
|
import com.gihon.entity.Role;
|
|
|
import com.gihon.service.RoleService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
@@ -17,6 +18,7 @@ import java.util.List;
|
|
|
* @author: dl
|
|
|
* @create: 02月18日 15时
|
|
|
**/
|
|
|
+@Api(value = "角色接口", tags = "角色接口")
|
|
|
@RestController
|
|
|
public class RoleController {
|
|
|
@Autowired
|
|
@@ -30,8 +32,7 @@ public class RoleController {
|
|
|
* @param rolename 角色名称
|
|
|
* @return com.gihon.common.http.Response
|
|
|
*/
|
|
|
- @PreAuthorize("hasAuthority('addRole')")
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiOperation("增加角色")
|
|
|
@PostMapping(value = "/addRole")
|
|
|
public Response addRole(Long id, String rolename) {
|
|
|
Role role = new Role(id, rolename);
|
|
@@ -46,7 +47,9 @@ public class RoleController {
|
|
|
* @param id Role ID
|
|
|
* @return com.gihon.common.http.Response
|
|
|
*/
|
|
|
- public Response 删除角色(Long id){
|
|
|
+ @ApiOperation("删除角色")
|
|
|
+ @GetMapping("/removeRole")
|
|
|
+ public Response removeRole(Long id){
|
|
|
boolean is_remove = roleService.removeById(id);
|
|
|
if (!is_remove) {
|
|
|
return Response.error(ResponseStatus.MAPPER_ERROR);
|
|
@@ -62,6 +65,9 @@ public class RoleController {
|
|
|
* @param rolename
|
|
|
* @return com.gihon.common.http.Response
|
|
|
*/
|
|
|
+ @GetMapping("/setRole")
|
|
|
+ @ApiOperation("修改角色")
|
|
|
+
|
|
|
public Response setRole(long id,String rolename){
|
|
|
Role role = Role.builder()
|
|
|
.id(id)
|
|
@@ -81,7 +87,9 @@ public class RoleController {
|
|
|
* @param id
|
|
|
* @return com.gihon.common.http.Response
|
|
|
*/
|
|
|
- public Response findRole(Long id){
|
|
|
+ @GetMapping("/getRole")
|
|
|
+ @ApiOperation("根据ID查找角色信息")
|
|
|
+ public Response getRole(Long id){
|
|
|
Role role = roleService.getById(id);
|
|
|
return Response.ok(role);
|
|
|
}
|
|
@@ -93,8 +101,10 @@ public class RoleController {
|
|
|
* @param id
|
|
|
* @return com.gihon.common.http.Response
|
|
|
*/
|
|
|
- public Response findPermissionByRoleId(Long id){
|
|
|
- Response<List<Role>> permissionsByRoleId = roleService.findPermissionByRoleId(id);
|
|
|
+ @GetMapping("/getPermissionByRoleId")
|
|
|
+ @ApiOperation("查询角色对应权限")
|
|
|
+ public Response getPermissionByRoleId(Long id){
|
|
|
+ Response<List<Role>> permissionsByRoleId = roleService.getPermissionByRoleId(id);
|
|
|
return permissionsByRoleId;
|
|
|
}
|
|
|
|