添加了基础的增删改查
parent
5d1c1d3bf4
commit
abe62be3e0
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.common.domian.req.TaskInfoAddReq;
|
||||||
|
import com.muyu.common.domian.req.TaskInfoUpdReq;
|
||||||
import com.muyu.common.domian.resp.TaskInfoResp;
|
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
@ -24,7 +26,7 @@ public class TaskInfo extends BaseEntity {
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id",type = IdType.AUTO)
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
private Long Id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务名称
|
* 任务名称
|
||||||
|
@ -81,11 +83,25 @@ public class TaskInfo extends BaseEntity {
|
||||||
|
|
||||||
public static TaskInfoResp build(TaskInfo taskInfo){
|
public static TaskInfoResp build(TaskInfo taskInfo){
|
||||||
return TaskInfoResp.builder()
|
return TaskInfoResp.builder()
|
||||||
.Id(taskInfo.Id)
|
.Id(taskInfo.id)
|
||||||
.name(taskInfo.name)
|
.name(taskInfo.name)
|
||||||
.processStatus(taskInfo.processStatus)
|
.processStatus(taskInfo.processStatus)
|
||||||
.status(taskInfo.status)
|
.status(taskInfo.status)
|
||||||
.weight(taskInfo.weight)
|
.weight(taskInfo.weight)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TaskInfo addBuild(TaskInfoAddReq req) {
|
||||||
|
return TaskInfo.builder()
|
||||||
|
.name(req.getName())
|
||||||
|
.weight(req.getWeight())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
public static TaskInfo updBuild(TaskInfoUpdReq req, Supplier<Long> id){
|
||||||
|
return TaskInfo.builder()
|
||||||
|
.id(id.get())
|
||||||
|
.name(req.getName())
|
||||||
|
.weight(req.getWeight())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.common.domian.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "任务添加请求对象" )
|
||||||
|
public class TaskInfoAddReq {
|
||||||
|
/**
|
||||||
|
* 任务名称
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "任务名称不能为空")
|
||||||
|
@Schema(name = "name",description = "任务名称")
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 任务权重级别
|
||||||
|
*/
|
||||||
|
@Schema(name = "weight",description = "任务权重级别")
|
||||||
|
private Integer weight;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.common.domian.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "任务添加请求对象" )
|
||||||
|
public class TaskInfoUpdReq {
|
||||||
|
/**
|
||||||
|
* 任务名称
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "任务名称不能为空")
|
||||||
|
@Schema(name = "name",description = "任务名称")
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 任务权重级别
|
||||||
|
*/
|
||||||
|
@Schema(name = "weight",description = "任务权重级别")
|
||||||
|
private Integer weight;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,15 +2,17 @@ package com.muyu.task.server.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.domian.TaskInfo;
|
||||||
|
import com.muyu.common.domian.req.TaskInfoAddReq;
|
||||||
import com.muyu.common.domian.req.TaskInfoListReq;
|
import com.muyu.common.domian.req.TaskInfoListReq;
|
||||||
|
import com.muyu.common.domian.req.TaskInfoUpdReq;
|
||||||
import com.muyu.common.domian.resp.TaskInfoResp;
|
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||||
import com.muyu.task.server.service.TaskInfoService;
|
import com.muyu.task.server.service.TaskInfoService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -32,10 +34,35 @@ public class TaskInfoController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@Operation(summary = "查看任务", description = "根据任务名称 权重 状态 查询")
|
@Operation(summary = "查看任务", description = "根据任务名称 权重 状态 查询")
|
||||||
public Result<Page<TaskInfoResp>> selectList(TaskInfoListReq req) {
|
public Result<Page<TaskInfoResp>> selectList(@RequestBody TaskInfoListReq req) {
|
||||||
return Result.success(taskInfoService.selectList(req));
|
return Result.success(taskInfoService.selectList(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping()
|
||||||
|
@Operation(summary = "添加任务", description = "添加任务信息表")
|
||||||
|
public Result save(@RequestBody @Validated TaskInfoAddReq req) {
|
||||||
|
taskInfoService.save(TaskInfo.addBuild(req));
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<TaskInfoResp> selectById(@PathVariable("id") Long id) {
|
||||||
|
TaskInfo byId = taskInfoService.getById(id);
|
||||||
|
return Result.success(TaskInfo.build(byId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result delete(@PathVariable("id") Long id) {
|
||||||
|
taskInfoService.removeById(id);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public Result update(@PathVariable("id") Long id , @RequestBody TaskInfoUpdReq req){
|
||||||
|
taskInfoService.updateById(TaskInfo.updBuild(req,()->id));
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue