郑永安
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
package com.gkhy.safePlatform.account.rpc.test;
 
import com.gkhy.safePlatform.account.model.dto.resp.ProjectRespDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountMenuService;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountProjectService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.ProjectRPCRespDTO;
import com.gkhy.safePlatform.account.service.ProjectService;
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.utils.BeanCopyUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
 
import java.util.List;
 
@DubboService
public class AccountProjectProvider implements AccountProjectService {
 
    @Autowired
    private ProjectService projectService;
 
    @Override
    public ResultVO<List<ProjectRPCRespDTO>> getProjectList() {
        try {
            List<ProjectRespDTO> enableProjectList = projectService.getEnableProjectList();
            List<ProjectRPCRespDTO> data = BeanCopyUtils.copyBeanList(enableProjectList, ProjectRPCRespDTO.class);
            return new ResultVO<>(ResultCodes.OK, data);
        } catch (AusinessException e) {
            return new ResultVO<>(e.getCode(), e.getMessage());
        } catch (BusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (Exception e) {
//            return new ResultVO<>(ResultCodes.SERVER_ERROR);
            ResultVO resultVO = new ResultVO<>();
            resultVO.setCode(ResultCodes.SERVER_ERROR);
            return resultVO;
        }
 
    }
}