郑永安
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
package com.gkhy.safePlatform.account.service.impl;
 
import com.gkhy.safePlatform.account.model.dto.resp.ProjectRespDTO;
import com.gkhy.safePlatform.account.entity.user.ProjectInfo;
import com.gkhy.safePlatform.account.enums.ProjectStatusEnum;
import com.gkhy.safePlatform.account.service.ProjectService;
import com.gkhy.safePlatform.account.service.baseService.ProjectInfoService;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service("projectService")
public class ProjectServiceImpl implements ProjectService {
 
    @Autowired
    private ProjectInfoService projectInfoService;
 
    @Override
    public List<ProjectRespDTO> getEnableProjectList() {
        List<ProjectInfo> sources = projectInfoService.getAllProject(ProjectStatusEnum.ENABLED);
        List<ProjectRespDTO> result = new ArrayList<>();
        ProjectRespDTO projectRespDTO;
        for (ProjectInfo projectInfo :
                sources) {
            projectRespDTO = new ProjectRespDTO();
            projectRespDTO.setProjectId(projectInfo.getId());
            projectRespDTO.setProjectCode(projectInfo.getCode());
            projectRespDTO.setProjectName(projectInfo.getName());
            projectRespDTO.setStatus(projectInfo.getStatus());
            ProjectStatusEnum statusEnum = ProjectStatusEnum.parse(projectInfo.getStatus());
            assert statusEnum != null;
            projectRespDTO.setStatusDesc(statusEnum.getValue());
            result.add(projectRespDTO);
        }
        return result;
    }
}