提交 ca0dd345 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 9c1a0640
package com.zrqx.core.form.resource.bg.videolibrary;
import java.util.List;
import com.zrqx.core.model.resource.videolibrary.VideoLibraryDiyType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -16,12 +12,8 @@ public class SaveUpdateVideoLibraryForm {
private String name;
@ApiModelProperty("来源")
private String source;
@ApiModelProperty(value = "分类id")
private List<VideoLibraryDiyType> diyType;
@ApiModelProperty("封面")
private String img;
@ApiModelProperty("默认封面")
private String defaultImg;
@ApiModelProperty("简介")
private String synopsis;
@ApiModelProperty("video")
......@@ -32,5 +24,6 @@ public class SaveUpdateVideoLibraryForm {
private String timeLength;
@ApiModelProperty("文件大小")
private String size;
@ApiModelProperty("排序")
private String sort;
}
......@@ -28,4 +28,6 @@ public class SaveVideoLibraryForm {
private List<String> timeLength;
@ApiModelProperty("video名称")
private List<String> videoName;
@ApiModelProperty("排序")
private String sort;
}
......@@ -37,4 +37,6 @@ public class DiyType {
private Integer status;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty("封面")
private String cover;
}
......@@ -54,7 +54,7 @@ import tk.mybatis.mapper.entity.Example.Criteria;
*/
@RestController
@RequestMapping(ResourceRequestPath.BG + ResourceRequestPath.DIYTYPE)
@Api(description = "网站管理-自定义分类")
@Api(description = "网站管理-赛程回顾")
public class DiyTypeController {
@Autowired
......@@ -72,75 +72,34 @@ public class DiyTypeController {
@PostMapping(value = ResourceRequestPath.SAVE)
public CallBack<Boolean> save(@RequestBody DiyType entity) {
Example example = service.createExample();
example.createCriteria().andEqualTo("typeName", entity.getTypeName()).andEqualTo("parentId",
entity.getParentId());
if (service.selectOneByExample(example) != null) {
throw new BusinessValidateException("同级已存在" + entity.getTypeName());
example.createCriteria().andEqualTo("typeName", entity.getTypeName()).andEqualTo("parentId", entity.getParentId());
if(service.selectOneByExample(example) != null){
throw new BusinessValidateException("同级已存在"+entity.getTypeName());
}
/*
* if(entity.getParentId().equals(0) &&
* AllResourceTypeEnum.getCode(entity.getTypeName()) == null){ throw new
* BusinessValidateException("分类名称错误"); }
*/
// 分页排序查询当前子分类最大code值
//分页排序查询当前子分类最大code值
example = service.createExample();
example.createCriteria().andEqualTo("parentId", entity.getParentId());
PageParam pageParam = new PageParam();
pageParam.setPageSize(1);
pageParam.setOrderBy("code desc");
PageInfo<DiyType> page = service.queryExample(pageParam, example);
if (page.getList() != null && page.getList().size() > 0) {
// 查询到子分类,获取最大code生成新的code
String code = page.getList().get(0).getCode().toString();
PageInfo<DiyType> page = service.queryExample(pageParam,example);
if(page.getList() != null && page.getList().size() > 0){
//查询到子分类,获取最大code生成新的code
String code = page.getList().get(0).getCode();
entity.setCode(UUIDUtil.newCode(code));
} else {
// 没有查询到子分类,获取父类code 拼接 01
if (entity.getParentId() != 0) {
entity.setCode(service.selectByPrimaryKey(entity.getParentId()).getCode() + "01");
} else {
}else{
//没有查询到子分类,获取父类code 拼接 01
if(entity.getParentId()!=0){
entity.setCode(service.selectByPrimaryKey(entity.getParentId()).getCode()+ "01");
}else{
entity.setCode("01");
}
}
entity.setStatus(DiyTypeStatusEnum.STATUS_1.getCode());
entity.setCreateTime(new Date());
if (!service.insert(entity)) {
if(!service.insert(entity)){
throw new BusinessValidateException("操作失败");
}
System.out.println(entity.getCode().length());
if (entity.getCode().contains("0003")) {
if (entity.getCode().length() == 6) {
for (int i = 1; i <= 24; i++) {
DiyType diytype = new DiyType();
diytype.setParentId(entity.getId());
diytype.setTypeName(entity.getShowName().substring(0, 4) + "年第" + i + "期");
diytype.setShowName(entity.getShowName().substring(0, 4) + "年第" + i + "期");
diytype.setSort(i);
example = service.createExample();
System.out.println(entity.getId());
example.createCriteria().andEqualTo("parentId", entity.getId());
pageParam.setPageSize(1);
pageParam.setOrderBy("code desc");
page = service.queryExample(pageParam, example);
if (page.getList() != null && page.getList().size() > 0) {
// 查询到子分类,获取最大code生成新的code
String code = page.getList().get(0).getCode().toString();
diytype.setCode(UUIDUtil.newCode(code));
} else {
// 没有查询到子分类,获取父类code 拼接 01
if (entity.getParentId() != 0) {
diytype.setCode(service.selectByPrimaryKey(diytype.getParentId()).getCode() + "01");
} else {
diytype.setCode("01");
}
}
diytype.setStatus(DiyTypeStatusEnum.STATUS_1.getCode());
diytype.setCreateTime(new Date());
if (!service.insert(diytype)) {
throw new BusinessValidateException("操作失败");
}
}
}
}
return CallBack.success(true);
}
......
......@@ -55,10 +55,6 @@ public class VideoLibrarySerivceImpl extends BaseServiceImpl<VideoLibrary,String
public boolean saveOrUpdate(SaveUpdateVideoLibraryForm form) {
VideoLibrary entity = new VideoLibrary();
BeanUtils.copyProperties(form, entity);
if(StringUtils.isNotBlank(entity.getDefaultImg())) {
String defaultImg = entity.getDefaultImg() + "/" + entity.getVideo() +"/1.jpg";
entity.setDefaultImg(defaultImg);
}
if(StringUtils.isBlank(entity.getId())){
//添加
entity.setStatus(LibraryStatusEnum.STATUS_0.getCode());
......@@ -72,8 +68,6 @@ public class VideoLibrarySerivceImpl extends BaseServiceImpl<VideoLibrary,String
mapper.insert(entity);
}else{
//修改
/* entity = mapper.selectByPrimaryKey(form.getId());
BeanUtils.copyProperties(form, entity);*/
entity.setUpdateTime(new Date());
entity.setAdSlogan(form.getSource());
mapper.updateByPrimaryKeySelective(entity);
......@@ -111,9 +105,9 @@ public class VideoLibrarySerivceImpl extends BaseServiceImpl<VideoLibrary,String
obj.setSalesNum(0);
obj.setVideoName(form.getNames().get(i));
obj.setAdSlogan(form.getSource());
obj.setSort(this.getMaxSort());
mapper.insert(obj);
}
return true;
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论