添加了查询所有任务信息接口
parent
f7121e13f3
commit
5d1c1d3bf4
|
@ -1,7 +0,0 @@
|
|||
package com.muyu;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.muyu.common.domian;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "etl_task" ,autoResultMap = true)
|
||||
public class TaskInfo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long Id;
|
||||
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 任务权重级别
|
||||
*/
|
||||
private Integer weight;
|
||||
/**
|
||||
* 任务执行状态
|
||||
*/
|
||||
private String processStatus;
|
||||
/**
|
||||
* 任务是否执行成功
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 总处理条数
|
||||
*/
|
||||
private Long total;
|
||||
/**
|
||||
* 已处理完条数
|
||||
*/
|
||||
private Long processTotal;
|
||||
/**
|
||||
* 错误条数
|
||||
*/
|
||||
private Long errorTotal;
|
||||
/**
|
||||
* 总执行次数
|
||||
*/
|
||||
private Long executeTotal;
|
||||
/**
|
||||
* 已完成执行次数
|
||||
*/
|
||||
private Long completeExecuteTotal;
|
||||
/**
|
||||
* 成功插入条数
|
||||
*/
|
||||
private Long successInsertTotal;
|
||||
/**
|
||||
* 成功修改条数
|
||||
*/
|
||||
private Long successUpdateTotal;
|
||||
/**
|
||||
* 成功删除条数
|
||||
*/
|
||||
private Long successDeleteTotal;
|
||||
/**
|
||||
* 累计处理时间
|
||||
*/
|
||||
private Date grandTotalTime;
|
||||
|
||||
public static TaskInfoResp build(TaskInfo taskInfo){
|
||||
return TaskInfoResp.builder()
|
||||
.Id(taskInfo.Id)
|
||||
.name(taskInfo.name)
|
||||
.processStatus(taskInfo.processStatus)
|
||||
.status(taskInfo.status)
|
||||
.weight(taskInfo.weight)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.common.domian.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "任务列表请求对象" )
|
||||
public class TaskInfoListReq {
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
@Schema(name = "name",description = "任务名称")
|
||||
private String name;
|
||||
/**
|
||||
* 任务权重级别
|
||||
*/
|
||||
@Schema(name = "weight",description = "任务权重级别")
|
||||
private Integer weight;
|
||||
/**
|
||||
* 任务执行状态
|
||||
*/
|
||||
@Schema(name = "processStatus",description = "任务执行状态")
|
||||
private String processStatus;
|
||||
|
||||
/**
|
||||
* 任务执行状态
|
||||
*/
|
||||
@Schema(name = "pageNum",description = "分页页数")
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 任务执行状态
|
||||
*/
|
||||
@Schema(name = "pageSize",description = "每页展示几条")
|
||||
private Integer pageSize;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.muyu.common.domian.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "任务列表返回对象" ,description = "负责任务信息查询的响应结果")
|
||||
public class TaskInfoResp {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long Id;
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 任务权重级别
|
||||
*/
|
||||
private Integer weight;
|
||||
/**
|
||||
* 任务执行状态
|
||||
*/
|
||||
private String processStatus;
|
||||
/**
|
||||
* 任务是否执行成功
|
||||
*/
|
||||
private String status;
|
||||
|
||||
}
|
|
@ -90,6 +90,10 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-nacos-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-task-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.muyu.task.server.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.domian.req.TaskInfoListReq;
|
||||
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||
import com.muyu.task.server.service.TaskInfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("taskInfo")
|
||||
@Tag(name = "任务控制层", description = "进行任务管理查询操作")
|
||||
public class TaskInfoController {
|
||||
|
||||
@Autowired
|
||||
private TaskInfoService taskInfoService;
|
||||
|
||||
/**
|
||||
* 获取所有的任务信息
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "查看任务", description = "根据任务名称 权重 状态 查询")
|
||||
public Result<Page<TaskInfoResp>> selectList(TaskInfoListReq req) {
|
||||
return Result.success(taskInfoService.selectList(req));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.muyu.task.server.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.domian.TaskInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskInfoMapper extends BaseMapper<TaskInfo> {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.task.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.domian.TaskInfo;
|
||||
import com.muyu.common.domian.req.TaskInfoListReq;
|
||||
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
public interface TaskInfoService extends IService<TaskInfo> {
|
||||
Page<TaskInfoResp> selectList(TaskInfoListReq req);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.task.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.domian.TaskInfo;
|
||||
import com.muyu.common.domian.req.TaskInfoListReq;
|
||||
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||
import com.muyu.task.server.mapper.TaskInfoMapper;
|
||||
import com.muyu.task.server.service.TaskInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Service
|
||||
public class TaskInfoServiceImpl extends ServiceImpl<TaskInfoMapper, TaskInfo> implements TaskInfoService {
|
||||
|
||||
@Resource
|
||||
private TaskInfoMapper taskInfoMapper;
|
||||
|
||||
@Override
|
||||
public Page<TaskInfoResp> selectList(TaskInfoListReq req) {
|
||||
LambdaQueryWrapper<TaskInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotEmpty(req.getName()), TaskInfo::getName, req.getName());
|
||||
queryWrapper.eq(req.getWeight()!=null, TaskInfo::getWeight, req.getWeight());
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(req.getProcessStatus()), TaskInfo::getProcessStatus, req.getProcessStatus());
|
||||
Page<TaskInfo> page = new Page<>(req.getPageNum(), req.getPageSize());
|
||||
Page<TaskInfo> taskInfoPage = taskInfoMapper.selectPage(page, queryWrapper);
|
||||
long total = taskInfoPage.getTotal();
|
||||
long pages = taskInfoPage.getPages();
|
||||
long size = taskInfoPage.getSize();
|
||||
long current = taskInfoPage.getCurrent();
|
||||
List<TaskInfoResp> list = taskInfoPage.getRecords().stream().map(taskInfo -> TaskInfo.build(taskInfo)).toList();
|
||||
Page<TaskInfoResp> respPage = new Page<>();
|
||||
respPage.setRecords(list);
|
||||
respPage.setCurrent(current);
|
||||
respPage.setSize(size);
|
||||
respPage.setTotal(total);
|
||||
respPage.setPages(pages);
|
||||
return respPage;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue