use of com.baomidou.mybatisplus.core.metadata.IPage in project dolphinscheduler by apache.
the class QueueMapperTest method testQueryQueuePaging.
/**
* test page
*/
@Test
public void testQueryQueuePaging() {
Queue queue = insertOne();
Page<Queue> page = new Page(1, 3);
IPage<Queue> queueIPage = queueMapper.queryQueuePaging(page, null);
Assert.assertNotEquals(queueIPage.getTotal(), 0);
queueIPage = queueMapper.queryQueuePaging(page, queue.getQueueName());
Assert.assertNotEquals(queueIPage.getTotal(), 0);
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project dolphinscheduler by apache.
the class ProjectService method queryProjectListPaging.
/**
* admin can view all projects
*
* @param loginUser login user
* @param searchVal search value
* @param pageSize page size
* @param pageNo page number
* @return project list which the login user have permission to see
*/
public Map<String, Object> queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
Map<String, Object> result = new HashMap<>();
PageInfo pageInfo = new PageInfo<Project>(pageNo, pageSize);
Page<Project> page = new Page(pageNo, pageSize);
int userId = loginUser.getUserType() == UserType.ADMIN_USER ? 0 : loginUser.getId();
IPage<Project> projectIPage = projectMapper.queryProjectListPaging(page, userId, searchVal);
List<Project> projectList = projectIPage.getRecords();
if (userId != 0) {
for (Project project : projectList) {
project.setPerm(org.apache.dolphinscheduler.common.Constants.DEFAULT_ADMIN_PERMISSION);
}
}
pageInfo.setTotalCount((int) projectIPage.getTotal());
pageInfo.setLists(projectList);
result.put(Constants.COUNT, (int) projectIPage.getTotal());
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project dolphinscheduler by apache.
the class ResourcesService method queryResourceListPaging.
/**
* query resources list paging
*
* @param loginUser login user
* @param type resource type
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return resource list page
*/
public Map<String, Object> queryResourceListPaging(User loginUser, int direcotryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
HashMap<String, Object> result = new HashMap<>(5);
Page<Resource> page = new Page(pageNo, pageSize);
int userId = loginUser.getId();
if (isAdmin(loginUser)) {
userId = 0;
}
if (direcotryId != -1) {
Resource directory = resourcesMapper.selectById(direcotryId);
if (directory == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, direcotryId, type.ordinal(), searchVal);
PageInfo pageInfo = new PageInfo<Resource>(pageNo, pageSize);
pageInfo.setTotalCount((int) resourceIPage.getTotal());
pageInfo.setLists(resourceIPage.getRecords());
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project dolphinscheduler by apache.
the class TaskInstanceService method queryTaskListPaging.
/**
* query task list by project, process instance, task name, task start time, task end time, task status, keyword paging
*
* @param loginUser login user
* @param projectName project name
* @param processInstanceId process instance id
* @param searchVal search value
* @param taskName task name
* @param stateType state type
* @param host host
* @param startDate start time
* @param endDate end time
* @param pageNo page number
* @param pageSize page size
* @return task list page
*/
public Map<String, Object> queryTaskListPaging(User loginUser, String projectName, Integer processInstanceId, String taskName, String executorName, String startDate, String endDate, String searchVal, ExecutionStatus stateType, String host, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(5);
Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Status status = (Status) checkResult.get(Constants.STATUS);
if (status != Status.SUCCESS) {
return checkResult;
}
int[] statusArray = null;
if (stateType != null) {
statusArray = new int[] { stateType.ordinal() };
}
Date start = null;
Date end = null;
try {
if (StringUtils.isNotEmpty(startDate)) {
start = DateUtils.getScheduleDate(startDate);
}
if (StringUtils.isNotEmpty(endDate)) {
end = DateUtils.getScheduleDate(endDate);
}
} catch (Exception e) {
result.put(Constants.STATUS, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
result.put(Constants.MSG, MessageFormat.format(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getMsg(), "startDate,endDate"));
return result;
}
Page<TaskInstance> page = new Page(pageNo, pageSize);
PageInfo pageInfo = new PageInfo<TaskInstance>(pageNo, pageSize);
int executorId = usersService.getUserIdByName(executorName);
IPage<TaskInstance> taskInstanceIPage = taskInstanceMapper.queryTaskInstanceListPaging(page, project.getId(), processInstanceId, searchVal, taskName, executorId, statusArray, host, start, end);
Set<String> exclusionSet = new HashSet<>();
exclusionSet.add(Constants.CLASS);
exclusionSet.add("taskJson");
List<TaskInstance> taskInstanceList = taskInstanceIPage.getRecords();
for (TaskInstance taskInstance : taskInstanceList) {
taskInstance.setDuration(DateUtils.differSec(taskInstance.getStartTime(), taskInstance.getEndTime()));
User executor = usersService.queryUser(taskInstance.getExecutorId());
if (null != executor) {
taskInstance.setExecutorName(executor.getUserName());
}
}
pageInfo.setTotalCount((int) taskInstanceIPage.getTotal());
pageInfo.setLists(CollectionUtils.getListByExclusion(taskInstanceIPage.getRecords(), exclusionSet));
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project lamp-util by zuihou.
the class EchoService method parse.
/**
* 1,遍历字段,解析出那些字段上标记了@Echo注解
*
* @param obj 对象
* @param typeMap 数据
* @param depth 当前递归深度
* @param ignoreFields 忽略回显的字段
*/
private void parse(Object obj, Map<LoadKey, Map<Serializable, Object>> typeMap, int depth, String... ignoreFields) {
if (obj == null) {
return;
}
if (depth > ips.getMaxDepth()) {
log.info("出现循环依赖,最多执行 {} 次, 已执行 {} 次,已为您跳出循环", ips.getMaxDepth(), depth);
return;
}
if (obj instanceof IPage) {
List<?> records = ((IPage<?>) obj).getRecords();
parseList(records, typeMap, depth, ignoreFields);
return;
}
if (obj instanceof Collection) {
parseList((Collection<?>) obj, typeMap, depth, ignoreFields);
return;
}
// 解析方法上的注解,计算出obj对象中所有需要查询的数据
List<Field> fields = ClassManager.getFields(obj.getClass());
for (Field field : fields) {
FieldParam fieldParam = getFieldParam(obj, field, typeMap, innerTypeMap -> parse(ReflectUtil.getFieldValue(obj, field), innerTypeMap, depth + 1, ignoreFields), ignoreFields);
if (fieldParam == null) {
continue;
}
LoadKey type = fieldParam.getLoadKey();
Map<Serializable, Object> valueMap = typeMap.getOrDefault(type, new ConcurrentHashMap<>(DEF_MAP_SIZE));
valueMap.put(fieldParam.getActualValue(), Collections.emptyMap());
typeMap.put(type, valueMap);
}
}
Aggregations