lyfO_o
2022-07-16 108ed1c548b7dc17ce47dcadea80e4c42a2f29e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.gkhy.safePlatform.accountController;
 
 
import com.alibaba.fastjson.JSONObject;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountRoleService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.req.RoleAddRPCReqDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.model.req.RoleModRPCReqDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.RoleRPCRespDTO;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.security.Principal;
import java.util.List;
 
@RestController
@RequestMapping("/role")
public class RoleController {
 
    @DubboReference(check = false)
    private AccountRoleService accountRoleService;
 
 
    /**
     * @Description: 获取所有启用角色
     */
 
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public ResultVO<List<RoleRPCRespDTO>> addRole(Principal principal){
        return accountRoleService.getRoleList();
    }
 
 
 
 
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultVO<String> addRole(Authentication authentication, RoleAddRPCReqDTO roleAddRPCReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return accountRoleService.addRole(currentUser.getUid(),roleAddRPCReqDTO);
    }
 
 
 
    @RequestMapping(value = "/mod",method = RequestMethod.POST)
    public ResultVO<String> modRole(Authentication authentication, RoleModRPCReqDTO roleModRPCReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return accountRoleService.modRole(currentUser.getUid(),roleModRPCReqDTO);
    }
 
 
    @RequestMapping(value = "/del",method = RequestMethod.POST)
    public ResultVO<String> modRole(Authentication authentication, JSONObject json){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        Long depId = json.getLong("depId");
        return accountRoleService.delRole(currentUser.getUid(),depId);
    }
}