Browse Source

add(dependent node's add unprivileged project list): dependent node's add unprivileged project list (#12073)

3.1.0-release
limaiwang 2 years ago committed by caishunfeng
parent
commit
f0fda2a9aa
  1. 15
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectController.java
  2. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectV2Controller.java
  3. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java
  4. 15
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  5. 3
      dolphinscheduler-api/src/main/resources/i18n/messages.properties
  6. 3
      dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties
  7. 3
      dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties
  8. 11
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectControllerTest.java
  9. 14
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectV2ControllerTest.java
  10. 10
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java
  11. 10
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java
  12. 5
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml
  13. 7
      dolphinscheduler-ui/src/service/modules/projects/index.ts
  14. 4
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts

15
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectController.java

@ -279,4 +279,19 @@ public class ProjectController extends BaseController {
public Result queryAllProjectList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
return projectService.queryAllProjectList(loginUser);
}
/**
* query all project list for dependent
*
* @param loginUser login user
* @return all project list
*/
@ApiOperation(value = "queryAllProjectListForDependent", notes = "QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES")
@GetMapping(value = "/list-dependent")
@ResponseStatus(HttpStatus.OK)
@ApiException(LOGIN_USER_QUERY_PROJECT_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryAllProjectListForDependent(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
return projectService.queryAllProjectListForDependent();
}
}

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectV2Controller.java

@ -288,4 +288,20 @@ public class ProjectV2Controller extends BaseController {
Result result = projectService.queryAllProjectList(loginUser);
return new ProjectListResponse(result);
}
/**
* query all project list for dependent
*
* @param loginUser login user
* @return all project list
*/
@ApiOperation(value = "queryAllProjectListForDependent", notes = "QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES")
@GetMapping(value = "/list-dependent")
@ResponseStatus(HttpStatus.OK)
@ApiException(LOGIN_USER_QUERY_PROJECT_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public ProjectListResponse queryAllProjectListForDependent(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
Result result = projectService.queryAllProjectListForDependent();
return new ProjectListResponse(result);
}
}

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java

@ -174,4 +174,10 @@ public interface ProjectService {
*/
void checkProjectAndAuth(Result result, User loginUser, Project project, long projectCode, String perm);
/**
* the project list in dependent node's permissions should not be restricted
* @return project list
*/
Result queryAllProjectListForDependent();
}

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

@ -603,4 +603,19 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
}
}
/**
* query all project for dependent node
*
* @return project list
*/
@Override
public Result queryAllProjectListForDependent() {
Result result = new Result<>();
List<Project> projects =
projectMapper.queryAllProjectForDependent();
result.setData(projects);
putMsg(result, Status.SUCCESS);
return result;
}
}

3
dolphinscheduler-api/src/main/resources/i18n/messages.properties

@ -301,4 +301,5 @@ TASK_DEFINITION_TAG=task definition related operation
PROCESS_TASK_RELATION_TAG=process task relation related operation
ENVIRONMENT_TAG=environment related operation
GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES=query process definition list by project code
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=query task definition list by process definition code
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=query task definition list by process definition code
QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES=query all project list for dependent

3
dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties

@ -360,4 +360,5 @@ TASK_DEFINITION_TAG=task definition related operation
PROCESS_TASK_RELATION_TAG=process task relation related operation
ENVIRONMENT_TAG=environment related operation
GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES=query process definition list by project code
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=query task definition list by process definition code
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=query task definition list by process definition code
QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES=query all project list for dependent

3
dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties

@ -357,4 +357,5 @@ TASK_DEFINITION_TAG=任务定义相关操作
PROCESS_TASK_RELATION_TAG=工作流关系相关操作
ENVIRONMENT_TAG=环境相关操作
GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES=通过项目代码查询工作流定义
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=通过工作流定义代码查询任务定义
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=通过工作流定义代码查询任务定义
QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES=查询Dependent节点所有项目

11
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectControllerTest.java

@ -141,7 +141,16 @@ public class ProjectControllerTest {
Result response = projectController.queryAllProjectList(user);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}
@Test
public void testQueryAllProjectListForDependent() {
User user = new User();
user.setId(0);
Result result = new Result();
putMsg(result, Status.SUCCESS);
Mockito.when(projectService.queryAllProjectListForDependent()).thenReturn(result);
Result response = projectController.queryAllProjectListForDependent(user);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}
private Project getProject() {
Project project = new Project();
project.setCode(1L);

14
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectV2ControllerTest.java

@ -76,7 +76,7 @@ public class ProjectV2ControllerTest {
projectUpdateReq.setDescription("james lbj");
projectUpdateReq.setUserName("admin");
Mockito.when(projectService.update(user, projectCode, projectUpdateReq.getProjectName(),
projectUpdateReq.getDescription(), projectUpdateReq.getUserName())).thenReturn(result);
projectUpdateReq.getDescription(), projectUpdateReq.getUserName())).thenReturn(result);
Result response = projectV2Controller.updateProject(user, projectCode, projectUpdateReq);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}
@ -101,7 +101,7 @@ public class ProjectV2ControllerTest {
Result result = Result.success(new PageInfo<Resource>(1, 10));
Mockito.when(projectService.queryProjectListPaging(user, projectQueryReq.getPageSize(),
projectQueryReq.getPageNo(), projectQueryReq.getSearchVal())).thenReturn(result);
projectQueryReq.getPageNo(), projectQueryReq.getSearchVal())).thenReturn(result);
Result response = projectV2Controller.queryProjectListPaging(user, projectQueryReq);
Assert.assertTrue(response != null && response.isSuccess());
}
@ -144,6 +144,16 @@ public class ProjectV2ControllerTest {
Result response = projectV2Controller.queryAllProjectList(user);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}
@Test
public void testQueryAllProjectListForDependent() {
User user = new User();
user.setId(0);
Result result = new Result();
putMsg(result, Status.SUCCESS);
Mockito.when(projectService.queryAllProjectListForDependent()).thenReturn(result);
Result response = projectV2Controller.queryAllProjectListForDependent(user);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}
private Project getProject() {
Project project = new Project();

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

@ -403,6 +403,16 @@ public class ProjectServiceTest {
List<Project> projects = (List<Project>) result.getData();
Assert.assertTrue(CollectionUtils.isNotEmpty(projects));
}
@Test
public void queryAllProjectListForDependent() {
Mockito.when(projectMapper.queryAllProjectForDependent()).thenReturn(getList());
Result result = projectService.queryAllProjectListForDependent();
logger.info(result.toString());
List<Project> projects = (List<Project>) result.getData();
Assert.assertTrue(CollectionUtils.isNotEmpty(projects));
}
@Test

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

@ -32,6 +32,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
* project mapper interface
*/
public interface ProjectMapper extends BaseMapper<Project> {
/**
* query project detail by code
* @param projectCode projectCode
@ -128,7 +129,6 @@ public interface ProjectMapper extends BaseMapper<Project> {
*/
List<Project> queryAllProject(@Param("userId") int userId);
/**
* list authorized Projects
* @param userId
@ -136,5 +136,11 @@ public interface ProjectMapper extends BaseMapper<Project> {
* @param <T>
* @return
*/
List<Project> listAuthorizedProjects(@Param("userId") int userId, @Param("projectsIds")List<Integer> projectsIds);
List<Project> listAuthorizedProjects(@Param("userId") int userId, @Param("projectsIds") List<Integer> projectsIds);
/**
* query all project for dependent node
* @return projectList
*/
List<Project> queryAllProjectForDependent();
}

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

@ -180,4 +180,9 @@
union select id as project_id from t_ds_project where user_id=#{userId})
</if>
</select>
<select id="queryAllProjectForDependent" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select code, name
from t_ds_project
</select>
</mapper>

7
dolphinscheduler-ui/src/service/modules/projects/index.ts

@ -85,3 +85,10 @@ export function deleteProject(code: number): any {
method: 'delete'
})
}
export function queryAllProjectListForDependent(): any {
return axios({
url: '/projects/list-dependent',
method: 'get'
})
}

4
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts

@ -20,7 +20,7 @@ import { useI18n } from 'vue-i18n'
import { NEllipsis, NIcon } from 'naive-ui'
import { useRelationCustomParams, useDependentTimeout } from '.'
import { useTaskNodeStore } from '@/store/project/task-node'
import { queryAllProjectList } from '@/service/modules/projects'
import { queryAllProjectListForDependent } from '@/service/modules/projects'
import { tasksState } from '@/common/common'
import {
queryProcessDefinitionList,
@ -176,7 +176,7 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
} as { [key in IDateType]: { value: string; label: string }[] }
const getProjectList = async () => {
const result = await queryAllProjectList()
const result = await queryAllProjectListForDependent()
projectList.value = result.map((item: { code: number; name: string }) => ({
value: item.code,
label: () => h(NEllipsis, null, item.name)

Loading…
Cancel
Save