郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.gkhy.safePlatform.account.rpc.test;
 
import com.gkhy.safePlatform.account.model.dto.req.MenuAddReqDTO;
import com.gkhy.safePlatform.account.model.dto.req.MenuMetaReqDTO;
import com.gkhy.safePlatform.account.model.dto.req.MenuModReqDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountMenuService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.req.MenuAddRPCReqDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.model.req.MenuMetaRPCReqDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.MenuMetaRPCRespDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.MenuModRPCReqDTO;
import com.gkhy.safePlatform.account.service.MenuService;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.AusinessException;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
 
@DubboService
public class AccountMenuServiceProvider implements AccountMenuService {
 
    @Autowired
    private MenuService menuService;
 
 
 
    @Override
    public ResultVO<String> addMenu(ContextCacheUser currentUser, MenuAddRPCReqDTO menuAddRPCReqDTO) {
        ;
        ResultVO<String> result = new ResultVO<>(ResultCodes.OK);
        try {
            MenuAddReqDTO menuAddReqDTO = new MenuAddReqDTO();
            BeanUtils.copyProperties(menuAddRPCReqDTO, menuAddReqDTO);
            MenuMetaRPCReqDTO metaDTO = menuAddRPCReqDTO.getMeta();
            MenuMetaReqDTO meta = new MenuMetaReqDTO();
            BeanUtils.copyProperties(metaDTO,meta);
            menuAddReqDTO.setMeta(meta);
            menuService.addMenu(menuAddReqDTO, currentUser);
        } catch (AusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        } catch (Exception e) {
            result.setCode(ResultCodes.SERVER_ERROR.getCode());
            result.setMsg(ResultCodes.SERVER_ERROR.getDesc());
        }
 
        return result;
    }
 
 
    @Override
    public ResultVO<String> modMenu(ContextCacheUser currentUser, MenuModRPCReqDTO menuModRPCReqDTO) {
        ;
        ResultVO<String> result = new ResultVO<>(ResultCodes.OK);
        try {
            MenuModReqDTO menuModReqDTO = new MenuModReqDTO();
            BeanUtils.copyProperties(menuModRPCReqDTO, menuModReqDTO);
            MenuMetaRPCRespDTO metaDTO = menuModRPCReqDTO.getMeta();
            MenuMetaReqDTO meta = new MenuMetaReqDTO();
            BeanUtils.copyProperties(metaDTO,meta);
            menuModReqDTO.setMeta(meta);
            menuService.modMenu(menuModReqDTO, currentUser);
        } catch (AusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }catch (Exception e) {
            result.setCode(ResultCodes.SERVER_ERROR.getCode());
            result.setMsg(ResultCodes.SERVER_ERROR.getDesc());
        }
        return result;
    }
 
    @Override
    public ResultVO<String> delMenu(ContextCacheUser currentUser, Long menuId) {
        ;
        ResultVO<String> result = new ResultVO<>(ResultCodes.OK);
        try {
            menuService.delMenu(menuId,currentUser);
        } catch (AusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }catch (Exception e) {
            result.setCode(ResultCodes.SERVER_ERROR.getCode());
            result.setMsg(ResultCodes.SERVER_ERROR.getDesc());
        }
        return null;
    }
}