zhangjinli 3 years ago
parent 618718c1cb
commit eb21477e30

@ -205,7 +205,6 @@ public class ReferenceController {
@Operation(summary = "素材列表")
@PostMapping("/list")
@tokenValid
public Result list(@Validated @RequestBody ListRParam param,@RequestHeader("token") @Parameter(name = "登录token") String token) {
Claims claims = new JwtUtil().parseJWT(token);
QueryWrapper<Reference> queryWrapper = new QueryWrapper<>();

@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zh.project0512.annotation.tokenValid;
import com.zh.project0512.model.*;
import com.zh.project0512.model.validatedDemo.TaskValidGroup1;
import com.zh.project0512.model.validatedDemo.TaskValidGroup2;
import com.zh.project0512.service.*;
import com.zh.project0512.utils.FileTypeUtil;
import com.zh.project0512.utils.JwtUtil;
@ -66,7 +68,7 @@ public class TaskController {
@Operation(summary = "新增")
@PostMapping("/add")
public Result add(@Validated @RequestBody Task task) {
public Result add(@Validated(TaskValidGroup1.class) @RequestBody Task task) {
taskService.save(task);
int id = task.getId();
taskTagService.addGroup(task.getTagList(), id);
@ -166,38 +168,13 @@ public class TaskController {
return MybatisPlusUtil.sqlResult(taskBrandService.remove(Wrappers.<TaskBrand>query().lambda().eq(TaskBrand::getTaskId, param.getId()).eq(TaskBrand::getBrandId, param.getBrandId())), "删除");
}
@Data
static class UpdTaskParam {
@NotNull(message = "id不能为空")
@Min(value = 1, message = "id最小值为1")
@Schema(title = "任务id")
private Integer id;
@Schema(title = "标题")
private String title;
@Schema(title = "副标题")
private String subtitle;
@Schema(title = "封面图片地址")
private String coverUrl;
@Schema(title="开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime start;
@Schema(title="结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime end;
@Schema(title="奖励模版id")
private Integer rewardRuleTemplateId;
}
@Operation(summary = "更新")
@PostMapping("/upd")
public Result upd(@Validated @RequestBody UpdTaskParam param) {
int id = param.getId();
Task task = new Task().setTitle(param.getTitle());
// .setSubtitle(param.getSubtitle()).setCoverUrl(param.getCoverUrl())
// .setStart(param.getStart()).setEnd(param.getEnd()).setRewardRuleTemplateId(param.getRewardRuleTemplateId()).setUpdateAt(LocalDateTime.now());
UpdateWrapper<Task> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
return MybatisPlusUtil.sqlResult(taskService.update(task, updateWrapper), "修改");
public Result upd(@Validated(TaskValidGroup2.class) @RequestBody Task task) {
task.setUpdateAt(LocalDateTime.now());
// UpdateWrapper<Task> updateWrapper = new UpdateWrapper<>();
// updateWrapper.eq("id", id);
return MybatisPlusUtil.sqlResult(taskService.updateById(task), "修改");
}
@Operation(summary = "删除")

@ -8,6 +8,8 @@ import java.time.LocalDateTime;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zh.project0512.model.validatedDemo.TaskValidGroup1;
import com.zh.project0512.model.validatedDemo.TaskValidGroup2;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
@ -33,6 +35,7 @@ public class Task extends Model {
private static final long serialVersionUID = 1L;
@NotNull(message = "请输入任务id",groups = {TaskValidGroup2.class})
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ -40,14 +43,14 @@ public class Task extends Model {
*
*/
@Schema(title="标题",description = "标题不能为空")
@NotNull(message = "标题不能为空")
@NotNull(message = "标题不能为空",groups = {TaskValidGroup1.class})
private String title;
/**
*
*/
@Schema(title="副标题",description = "副标题不能为空")
@NotNull(message = "副标题不能为空")
@NotNull(message = "副标题不能为空",groups = {TaskValidGroup1.class})
private String subtitle;
/**
@ -55,7 +58,7 @@ public class Task extends Model {
*/
@Schema(title="封面",description = "封面不能为空")
@TableField("coverUrl")
@NotNull(message = "封面不能为空")
@NotNull(message = "封面不能为空",groups = {TaskValidGroup1.class})
private String coverUrl;
/**
@ -76,14 +79,14 @@ public class Task extends Model {
* 0线1线2
*/
@Schema(title="状态",description = "0未上线1已上线2已结束")
private int status;
private Integer status;
/**
* id
*/
@Schema(title="奖励模版id")
@TableField("rewardRuleTemplateId")
private int rewardRuleTemplateId;
private Integer rewardRuleTemplateId;
@TableField("creatAt")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

@ -0,0 +1,9 @@
package com.zh.project0512.model.validatedDemo;
/**
*
* add
*/
public interface TaskValidGroup1 {
}

@ -0,0 +1,8 @@
package com.zh.project0512.model.validatedDemo;
/**
*
* upd
*/
public interface TaskValidGroup2 {
}
Loading…
Cancel
Save