Browse Source

[Optimization] Config module resource relation fix. (#10718)

* Config module resource relation fix.

* Boolean judge fix

* e2e rerun

* e2e rerun

* e2e rerun

* ArrayList fix

* change variable name.

* Add transaction processing on create data resource method
3.1.0-release
WangJPLeo 2 years ago committed by GitHub
parent
commit
d2fe16d252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
  2. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
  3. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java
  4. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  5. 28
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/QueueServiceImpl.java
  6. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java
  7. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
  8. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java
  9. 27
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
  10. 14
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java
  11. 2
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/QueueServiceTest.java
  12. 2
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
  13. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/QueueMapper.java
  14. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/QueueMapper.xml
  15. 7
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java

@ -160,6 +160,7 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
* @return create result code * @return create result code
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createAlertgroup(User loginUser, String groupName, String desc, String alertInstanceIds) { public Map<String, Object> createAlertgroup(User loginUser, String groupName, String desc, String alertInstanceIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
//only admin can operate //only admin can operate
@ -191,6 +192,8 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
} catch (DuplicateKeyException ex) { } catch (DuplicateKeyException ex) {
logger.error("Create alert group error.", ex); logger.error("Create alert group error.", ex);
putMsg(result, Status.ALERT_GROUP_EXIST); putMsg(result, Status.ALERT_GROUP_EXIST);
} catch (RuntimeException e) {
throw new RuntimeException(e.getMessage());
} }
return result; return result;

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java

@ -100,6 +100,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
* @return create result code * @return create result code
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) { public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) {
DataSourceUtils.checkDatasourceParam(datasourceParam); DataSourceUtils.checkDatasourceParam(datasourceParam);
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
@ -139,6 +140,8 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
} catch (DuplicateKeyException ex) { } catch (DuplicateKeyException ex) {
logger.error("Create datasource error.", ex); logger.error("Create datasource error.", ex);
putMsg(result, Status.DATASOURCE_EXIST); putMsg(result, Status.DATASOURCE_EXIST);
} catch (RuntimeException e) {
throw new RuntimeException(e.getMessage());
} }
return result; return result;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java

@ -92,8 +92,8 @@ public class EnvironmentServiceImpl extends BaseServiceImpl implements Environme
* @param desc environment desc * @param desc environment desc
* @param workerGroups worker groups * @param workerGroups worker groups
*/ */
@Transactional(rollbackFor = RuntimeException.class)
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createEnvironment(User loginUser, String name, String config, String desc, String workerGroups) { public Map<String, Object> createEnvironment(User loginUser, String name, String config, String desc, String workerGroups) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!canOperatorPermissions(loginUser, null, AuthorizationType.ENVIRONMENT, ENVIRONMENT_CREATE)) { if (!canOperatorPermissions(loginUser, null, AuthorizationType.ENVIRONMENT, ENVIRONMENT_CREATE)) {

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

@ -41,6 +41,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -86,6 +87,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
* @return returns an error if it exists * @return returns an error if it exists
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createProject(User loginUser, String name, String desc) { public Map<String, Object> createProject(User loginUser, String name, String desc) {
Map<String, Object> result = checkDesc(desc); Map<String, Object> result = checkDesc(desc);

28
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/QueueServiceImpl.java

@ -17,22 +17,26 @@
package org.apache.dolphinscheduler.api.service.impl; package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.QueueService; import org.apache.dolphinscheduler.api.service.QueueService;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.QueueMapper; import org.apache.dolphinscheduler.dao.mapper.QueueMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.commons.lang3.StringUtils; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -41,11 +45,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.YARN_QUEUE_CREATE;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.YARN_QUEUE_UPDATE;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*;
/** /**
* queue service impl * queue service impl
@ -71,15 +74,13 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
public Map<String, Object> queryList(User loginUser) { public Map<String, Object> queryList(User loginUser) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.QUEUE, loginUser.getId(), logger); Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.QUEUE, loginUser.getId(), logger);
if (ids.isEmpty()) { if (loginUser.getUserType().equals(UserType.GENERAL_USER)) {
result.put(Constants.DATA_LIST, Collections.emptyList()); ids = ids.isEmpty() ? new HashSet<>() : ids;
putMsg(result, Status.SUCCESS); ids.add(Constants.DEFAULT_QUEUE_ID);
return result;
} }
List<Queue> queueList = queueMapper.selectBatchIds(ids); List<Queue> queueList = queueMapper.selectBatchIds(ids);
result.put(Constants.DATA_LIST, queueList); result.put(Constants.DATA_LIST, queueList);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
@ -103,7 +104,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
return result; return result;
} }
Page<Queue> page = new Page<>(pageNo, pageSize); Page<Queue> page = new Page<>(pageNo, pageSize);
IPage<Queue> queueList = queueMapper.queryQueuePaging(page, searchVal); IPage<Queue> queueList = queueMapper.queryQueuePaging(page, new ArrayList<>(ids), searchVal);
Integer count = (int) queueList.getTotal(); Integer count = (int) queueList.getTotal();
pageInfo.setTotal(count); pageInfo.setTotal(count);
pageInfo.setTotalList(queueList.getRecords()); pageInfo.setTotalList(queueList.getRecords());
@ -122,6 +123,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
* @return create result * @return create result
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) { public Map<String, Object> createQueue(User loginUser, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!canOperatorPermissions(loginUser,null, AuthorizationType.QUEUE,YARN_QUEUE_CREATE)) { if (!canOperatorPermissions(loginUser,null, AuthorizationType.QUEUE,YARN_QUEUE_CREATE)) {
@ -160,7 +162,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
queueMapper.insert(queueObj); queueMapper.insert(queueObj);
result.put(Constants.DATA_LIST, queueObj); result.put(Constants.DATA_LIST, queueObj);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.QUEUE, loginUser.getId(), Collections.singletonList(queueObj.getId()), logger);
return result; return result;
} }

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -78,6 +79,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
* @return the result code and msg * @return the result code and msg
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) { public Map<String, Object> createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java

@ -46,6 +46,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -132,6 +133,7 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
if (PropertyUtils.getResUploadStartupState()) { if (PropertyUtils.getResUploadStartupState()) {
storageOperate.createTenantDirIfNotExists(tenantCode); storageOperate.createTenantDirIfNotExists(tenantCode);
} }
permissionPostHandle(AuthorizationType.TENANT, loginUser.getId(), Collections.singletonList(tenant.getId()), logger);
result.put(Constants.DATA_LIST, tenant); result.put(Constants.DATA_LIST, tenant);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java

@ -77,6 +77,7 @@ public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncServic
* @return create result code * @return create result code
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> createUdfFunction(User loginUser, public Result<Object> createUdfFunction(User loginUser,
String funcName, String funcName,
String className, String className,

27
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java

@ -84,6 +84,7 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
* @return create or update result code * @return create or update result code
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> saveWorkerGroup(User loginUser, int id, String name, String addrList) { public Map<String, Object> saveWorkerGroup(User loginUser, int id, String name, String addrList) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!canOperatorPermissions(loginUser,null, AuthorizationType.WORKER_GROUP, WORKER_GROUP_CREATE)) { if (!canOperatorPermissions(loginUser,null, AuthorizationType.WORKER_GROUP, WORKER_GROUP_CREATE)) {
@ -191,14 +192,12 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
int toIndex = (pageNo - 1) * pageSize + pageSize; int toIndex = (pageNo - 1) * pageSize + pageSize;
Result result = new Result(); Result result = new Result();
List<WorkerGroup> workerGroups = new ArrayList<>(); List<WorkerGroup> workerGroups;
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
workerGroups = getWorkerGroups(true); workerGroups = getWorkerGroups(true, null);
} else { } else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger); Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger);
if (!ids.isEmpty()) { workerGroups = getWorkerGroups(true, ids.isEmpty() ? Collections.emptyList() : new ArrayList<>(ids));
workerGroups = workerGroupMapper.selectBatchIds(ids);
}
} }
List<WorkerGroup> resultDataList = new ArrayList<>(); List<WorkerGroup> resultDataList = new ArrayList<>();
int total = 0; int total = 0;
@ -244,15 +243,10 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
List<WorkerGroup> workerGroups; List<WorkerGroup> workerGroups;
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
workerGroups = getWorkerGroups(false); workerGroups = getWorkerGroups(false, null);
} else { } else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger); Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger);
if (ids.isEmpty()) { workerGroups = getWorkerGroups(false, ids.isEmpty() ? Collections.emptyList() : new ArrayList<>(ids));
result.put(Constants.DATA_LIST, Collections.emptyList());
putMsg(result, Status.SUCCESS);
return result;
}
workerGroups = workerGroupMapper.selectBatchIds(ids);
} }
List<String> availableWorkerGroupList = workerGroups.stream() List<String> availableWorkerGroupList = workerGroups.stream()
.map(WorkerGroup::getName) .map(WorkerGroup::getName)
@ -273,9 +267,14 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
* @param isPaging whether paging * @param isPaging whether paging
* @return WorkerGroup list * @return WorkerGroup list
*/ */
private List<WorkerGroup> getWorkerGroups(boolean isPaging) { private List<WorkerGroup> getWorkerGroups(boolean isPaging, List<Integer> ids) {
// worker groups from database // worker groups from database
List<WorkerGroup> workerGroups = workerGroupMapper.queryAllWorkerGroup(); List<WorkerGroup> workerGroups;
if (ids != null) {
workerGroups = ids.isEmpty() ? new ArrayList<>() : workerGroupMapper.selectBatchIds(ids);
} else {
workerGroups = workerGroupMapper.queryAllWorkerGroup();
}
// worker groups from zookeeper // worker groups from zookeeper
String workerPath = Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS; String workerPath = Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS;
Collection<String> workerGroupList = null; Collection<String> workerGroupList = null;

14
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java

@ -17,13 +17,19 @@
package org.apache.dolphinscheduler.api.permission; package org.apache.dolphinscheduler.api.permission;
import com.google.common.collect.Lists;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.process.ProcessService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -34,11 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import java.util.ArrayList; import com.google.common.collect.Lists;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* permission service test * permission service test

2
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/QueueServiceTest.java

@ -110,7 +110,7 @@ public class QueueServiceTest {
Set<Integer> ids = new HashSet<>(); Set<Integer> ids = new HashSet<>();
ids.add(1); ids.add(1);
Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.QUEUE, getLoginUser().getId(), queueServiceImplLogger)).thenReturn(ids); Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.QUEUE, getLoginUser().getId(), queueServiceImplLogger)).thenReturn(ids);
Mockito.when(queueMapper.queryQueuePaging(Mockito.any(Page.class), Mockito.eq(queueName))).thenReturn(page); Mockito.when(queueMapper.queryQueuePaging(Mockito.any(Page.class), Mockito.anyList(), Mockito.eq(queueName))).thenReturn(page);
Result result = queueService.queryList(getLoginUser(), queueName, 1, 10); Result result = queueService.queryList(getLoginUser(), queueName, 1, 10);
logger.info(result.toString()); logger.info(result.toString());
PageInfo<Queue> pageInfo = (PageInfo<Queue>) result.getData(); PageInfo<Queue> pageInfo = (PageInfo<Queue>) result.getData();

2
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

@ -833,4 +833,6 @@ public final class Constants {
public static final int USER_PASSWORD_MIN_LENGTH = 2; public static final int USER_PASSWORD_MIN_LENGTH = 2;
public static final String FUNCTION_START_WITH = "$"; public static final String FUNCTION_START_WITH = "$";
public static final Integer DEFAULT_QUEUE_ID = 1;
} }

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/QueueMapper.java

@ -34,7 +34,7 @@ public interface QueueMapper extends BaseMapper<Queue> {
* @param searchVal searchVal * @param searchVal searchVal
* @return queue IPage * @return queue IPage
*/ */
IPage<Queue> queryQueuePaging(IPage<Queue> page, IPage<Queue> queryQueuePaging(IPage<Queue> page, @Param("ids")List<Integer> ids,
@Param("searchVal") String searchVal); @Param("searchVal") String searchVal);
/** /**

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/QueueMapper.xml

@ -29,6 +29,12 @@
<if test="searchVal != null and searchVal != ''"> <if test="searchVal != null and searchVal != ''">
and queue_name like concat('%', #{searchVal}, '%') and queue_name like concat('%', #{searchVal}, '%')
</if> </if>
<if test="ids != null and ids.size() > 0">
and id in
<foreach collection="ids" item="i" open="(" close=")" separator=",">
#{i}
</foreach>
</if>
order by update_time desc order by update_time desc
</select> </select>
<select id="queryAllQueueList" resultType="org.apache.dolphinscheduler.dao.entity.Queue"> <select id="queryAllQueueList" resultType="org.apache.dolphinscheduler.dao.entity.Queue">

7
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java

@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Queue;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -94,12 +95,10 @@ public class QueueMapperTest extends BaseDaoTest {
Queue queue = insertOne(); Queue queue = insertOne();
Page<Queue> page = new Page(1,3); Page<Queue> page = new Page(1,3);
IPage<Queue> queueIPage= queueMapper.queryQueuePaging(page, IPage<Queue> queueIPage= queueMapper.queryQueuePaging(page, Collections.singletonList(queue.getId()), null);
null);
Assert.assertNotEquals(queueIPage.getTotal(), 0); Assert.assertNotEquals(queueIPage.getTotal(), 0);
queueIPage= queueMapper.queryQueuePaging(page, queueIPage= queueMapper.queryQueuePaging(page, Collections.singletonList(queue.getId()), queue.getQueueName());
queue.getQueueName());
Assert.assertNotEquals(queueIPage.getTotal(), 0); Assert.assertNotEquals(queueIPage.getTotal(), 0);
} }

Loading…
Cancel
Save