|
|
|
@ -2,12 +2,17 @@ package com.zh.project0512.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
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.service.*;
|
|
|
|
|
import com.zh.project0512.utils.FileTypeUtil;
|
|
|
|
|
import com.zh.project0512.utils.JwtUtil;
|
|
|
|
|
import com.zh.project0512.utils.MybatisPlusUtil;
|
|
|
|
|
import com.zh.project0512.utils.result.HttpStatusEnum;
|
|
|
|
@ -77,6 +82,123 @@ public class TaskController {
|
|
|
|
|
@Schema(title = "任务id")
|
|
|
|
|
private Integer id;
|
|
|
|
|
}
|
|
|
|
|
@Data
|
|
|
|
|
static class AddTaskTagParam {
|
|
|
|
|
@NotNull(message = "id不能为空")
|
|
|
|
|
@Min(value = 1, message = "id最小值为1")
|
|
|
|
|
@Schema(title = "任务id")
|
|
|
|
|
private Integer id;
|
|
|
|
|
@NotNull(message = "tagId不能为空")
|
|
|
|
|
@Min(value = 1, message = "tagId最小值为1")
|
|
|
|
|
@Schema(title = "标签id")
|
|
|
|
|
private Integer tagId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "新增任务标签")
|
|
|
|
|
@PostMapping("/addTag")
|
|
|
|
|
public Result addTag(@Validated @RequestBody AddTaskTagParam param) {
|
|
|
|
|
Integer taskId = param.getId();
|
|
|
|
|
Integer tagId = param.getTagId();
|
|
|
|
|
if (null != taskTagService.getMap(Wrappers.<TaskTag>query().lambda().eq(TaskTag::getTaskId, taskId).eq(TaskTag::getTagId, tagId))) {
|
|
|
|
|
return Result.success("数据已存在");
|
|
|
|
|
}
|
|
|
|
|
taskTagService.saveOrUpdate(new TaskTag().setTaskId(taskId).setTagId(tagId));
|
|
|
|
|
return Result.success("添加完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
static class AddTaskBrandParam {
|
|
|
|
|
@NotNull(message = "id不能为空")
|
|
|
|
|
@Min(value = 1, message = "id最小值为1")
|
|
|
|
|
@Schema(title = "任务id")
|
|
|
|
|
private Integer id;
|
|
|
|
|
@NotNull(message = "brandId不能为空")
|
|
|
|
|
@Min(value = 1, message = "brandId最小值为1")
|
|
|
|
|
@Schema(title = "品牌id")
|
|
|
|
|
private Integer brandId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "新增任务品牌")
|
|
|
|
|
@PostMapping("/addBrand")
|
|
|
|
|
public Result addBrand(@Validated @RequestBody AddTaskBrandParam param) {
|
|
|
|
|
Integer taskId = param.getId();
|
|
|
|
|
Integer brandId = param.getBrandId();
|
|
|
|
|
if (null != taskBrandService.getMap(Wrappers.<TaskBrand>query().lambda().eq(TaskBrand::getTaskId, taskId).eq(TaskBrand::getBrandId, brandId))) {
|
|
|
|
|
return Result.success("数据已存在");
|
|
|
|
|
}
|
|
|
|
|
taskBrandService.saveOrUpdate(new TaskBrand().setTaskId(taskId).setBrandId(brandId).setCreatAt(LocalDateTime.now()));
|
|
|
|
|
return Result.success("添加完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
static class DelTaskTagParam {
|
|
|
|
|
@NotNull(message = "id不能为空")
|
|
|
|
|
@Min(value = 1, message = "id最小值为1")
|
|
|
|
|
@Schema(title = "任务id")
|
|
|
|
|
private Integer id;
|
|
|
|
|
@NotNull(message = "tagId不能为空")
|
|
|
|
|
@Min(value = 1, message = "tagId最小值为1")
|
|
|
|
|
@Schema(title = "标签id")
|
|
|
|
|
private Integer tagId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除任务标签")
|
|
|
|
|
@PostMapping("/delTag")
|
|
|
|
|
public Result delTag(@Validated @RequestBody DelTaskTagParam param) {
|
|
|
|
|
return MybatisPlusUtil.sqlResult(taskTagService.remove(Wrappers.<TaskTag>query().lambda().eq(TaskTag::getTaskId, param.getId()).eq(TaskTag::getTagId, param.getTagId())), "删除");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
static class DelTaskBrandParam {
|
|
|
|
|
@NotNull(message = "id不能为空")
|
|
|
|
|
@Min(value = 1, message = "id最小值为1")
|
|
|
|
|
@Schema(title = "任务id")
|
|
|
|
|
private Integer id;
|
|
|
|
|
@NotNull(message = "brandId不能为空")
|
|
|
|
|
@Min(value = 1, message = "brandId最小值为1")
|
|
|
|
|
@Schema(title = "品牌id")
|
|
|
|
|
private Integer brandId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除任务品牌")
|
|
|
|
|
@PostMapping("/delBrand")
|
|
|
|
|
public Result delBrand(@Validated @RequestBody DelTaskBrandParam param) {
|
|
|
|
|
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), "修改");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@PostMapping("/del")
|
|
|
|
|