|
|
|
@ -2,6 +2,7 @@ package com.zh.project0512.controller.manage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
@ -32,6 +33,9 @@ import javax.validation.constraints.Min;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.LocalTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -55,25 +59,35 @@ public class ReferenceController {
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
static class AddRParam {
|
|
|
|
|
@NotNull(message = "id不能为空")
|
|
|
|
|
@Min(value = 1, message = "id最小值为1")
|
|
|
|
|
@Schema(title = "素材id")
|
|
|
|
|
@NotNull(message = "标题不能为空")
|
|
|
|
|
@Schema(title = "标题")
|
|
|
|
|
private String title;
|
|
|
|
|
@NotNull(message = "tagId不能为空")
|
|
|
|
|
@Min(value = 1, message = "tagId最小值为1")
|
|
|
|
|
@Schema(title = "标签id")
|
|
|
|
|
private Integer tagId;
|
|
|
|
|
@Schema(title = "素材分组id",description = "0为未分组")
|
|
|
|
|
private Integer groupId;
|
|
|
|
|
@Schema(title = "文件地址列表")
|
|
|
|
|
@NotNull(message = "fileUrl不能为空")
|
|
|
|
|
private List<String> fileUrlList;
|
|
|
|
|
@Schema(title = "封面图片地址",description = "视频文件请上传封面图片")
|
|
|
|
|
private String coverUrl;
|
|
|
|
|
@Schema(title = "标签id列表")
|
|
|
|
|
private List<Integer> tagList;
|
|
|
|
|
@Schema(title = "品牌id列表")
|
|
|
|
|
private List<Integer> brandList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "添加素材")
|
|
|
|
|
@PostMapping("/add")
|
|
|
|
|
@adminTokenValid
|
|
|
|
|
public Result add(@Validated @RequestBody Reference reference) {
|
|
|
|
|
String fileName = reference.getFileUrl();
|
|
|
|
|
reference.setType(FileTypeUtil.getcontentTypeNum(fileName.substring(fileName.lastIndexOf("."))));
|
|
|
|
|
referenceService.save(reference.setCreatAt(LocalDateTime.now()));
|
|
|
|
|
referenceTagService.addGroup(reference.getTagList(), reference.getId());
|
|
|
|
|
referenceBrandService.addGroup(reference.getBrandList(), reference.getId());
|
|
|
|
|
public Result add(@Validated @RequestBody AddRParam param) {
|
|
|
|
|
List<String> list = param.getFileUrlList();
|
|
|
|
|
Reference reference = new Reference().setTitle(param.getTitle()).setGroupId(param.getGroupId()).setCoverUrl(param.getCoverUrl());
|
|
|
|
|
List<Reference> l = new ArrayList<>();
|
|
|
|
|
for(String e :list){
|
|
|
|
|
l.add(reference.setFileUrl(e).setType(FileTypeUtil.getcontentTypeNum(e.substring(e.lastIndexOf(".")))));
|
|
|
|
|
}
|
|
|
|
|
referenceService.saveBatch(l);
|
|
|
|
|
// referenceTagService.addGroup(reference.getTagList(), reference.getId());
|
|
|
|
|
// referenceBrandService.addGroup(reference.getBrandList(), reference.getId());
|
|
|
|
|
return Result.success("添加完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|