Browse Source

[Improvement][API] Improvement query all project list (#5169) (#5192)

pull/3/MERGE
wenjun 4 years ago committed by GitHub
parent
commit
f20bb54896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  2. 3
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java
  3. 6
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java
  4. 4
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

9
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -447,19 +447,14 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
}
/**
* query all project list that have one or more process definitions.
* query all project list
*
* @return project list
*/
@Override
public Map<String, Object> queryAllProjectList() {
Map<String, Object> result = new HashMap<>();
List<Project> projects = new ArrayList<>();
List<Integer> projectIds = processDefinitionMapper.listProjectIds();
if (CollectionUtils.isNotEmpty(projectIds)) {
projects = projectMapper.selectBatchIds(projectIds);
}
List<Project> projects = projectMapper.queryAllProject();
result.put(Constants.DATA_LIST, projects);
putMsg(result, Status.SUCCESS);

3
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java

@ -322,8 +322,7 @@ public class ProjectServiceTest {
@Test
public void testQueryAllProjectList() {
Mockito.when(processDefinitionMapper.listProjectIds()).thenReturn(getProjectIds());
Mockito.when(projectMapper.selectBatchIds(getProjectIds())).thenReturn(getList());
Mockito.when(projectMapper.queryAllProject()).thenReturn(getList());
Map<String, Object> result = projectService.queryAllProjectList();
logger.info(result.toString());

6
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java

@ -92,4 +92,10 @@ public interface ProjectMapper extends BaseMapper<Project> {
*/
ProjectUser queryProjectWithUserByProcessInstanceId(@Param("processInstanceId") int processInstanceId);
/**
* query all project
* @return projectList
*/
List<Project> queryAllProject();
}

4
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

@ -109,4 +109,8 @@
join t_ds_user u on dp.user_id = u.id
where di.id = #{processInstanceId};
</select>
<select id="queryAllProject" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select * from t_ds_project
</select>
</mapper>

Loading…
Cancel
Save