Browse Source

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

3.2.0-release
limaiwang 2 years ago committed by GitHub
parent
commit
ed1d1e8856
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 1
      dolphinscheduler-api/src/main/resources/i18n/messages.properties
  6. 1
      dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties
  7. 1
      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. 10
      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. 6
      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

@ -284,4 +284,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

@ -626,4 +626,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;
}
}

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

@ -302,3 +302,4 @@ 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
QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES=query all project list for dependent

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

@ -361,3 +361,4 @@ 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
QUERY_ALL_PROJECT_LIST_FOR_DEPENDENT_NOTES=query all project list for dependent

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

@ -358,3 +358,4 @@ PROCESS_TASK_RELATION_TAG=工作流关系相关操作
ENVIRONMENT_TAG=环境相关操作
GET_PROCESS_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);

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

@ -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

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

@ -137,4 +137,10 @@ public interface ProjectMapper extends BaseMapper<Project> {
* @return
*/
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