提交 03c060a3 authored 作者: yucaiwei's avatar yucaiwei

--no commit message

上级 56b76e89
......@@ -29,7 +29,13 @@ import com.zrqx.core.enums.resource.diytype.DiyTypeStatusEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.diytype.QueryDiyTypeForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.model.resource.audiolibrary.AudioLibraryDiyType;
import com.zrqx.core.model.resource.authorLibrary.AuthorLibraryDiytype;
import com.zrqx.core.model.resource.diytype.DiyType;
import com.zrqx.core.model.resource.ebook.EbookDiyType;
import com.zrqx.core.model.resource.imagelibrary.ImageLibraryDiyType;
import com.zrqx.core.model.resource.videolibrary.VideoLibraryDiyTypeRelation;
import com.zrqx.core.util.bean.BeanUtils;
import com.zrqx.core.util.bean.Copy;
import com.zrqx.core.util.datatype.ArrayUtils;
......@@ -38,7 +44,13 @@ import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.resource.diytype.DiyTypeVO;
import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryDiyTypeService;
import com.zrqx.resource.bg.service.audiolibrary.AudioLibraryDiyTypeService;
import com.zrqx.resource.bg.service.authorLibrary.AuthorLibraryDiytypeService;
import com.zrqx.resource.bg.service.diytype.DiyTypeService;
import com.zrqx.resource.bg.service.ebook.EbookDiyTypeService;
import com.zrqx.resource.bg.service.imagelibrary.ImageLibraryService;
import com.zrqx.resource.bg.service.videolibrary.VideoLibraryDiyTypeService;
/**
......@@ -51,6 +63,19 @@ public class DiyTypeController {
@Autowired
private DiyTypeService service;
@Autowired
private EbookDiyTypeService ebookDiyTypeService;
@Autowired
private ArticleLibraryDiyTypeService articleLibraryDiyTypeService;
@Autowired
private AudioLibraryDiyTypeService audioLibraryDiyTypeService;
@Autowired
private AuthorLibraryDiytypeService authorLibraryDiytypeService;
@Autowired
private VideoLibraryDiyTypeService videoLibraryDiyTypeService;
@Autowired
private ImageLibraryService imageLibraryService;
@ApiOperation(value = "新增自定义分类", notes = "新增一个")
@PostMapping(value = ResourceRequestPath.SAVE)
......@@ -132,6 +157,8 @@ public class DiyTypeController {
if(!service.deleteByExample(example)){
throw new BusinessValidateException("操作失败");
}
// 将数据内容中已经关联的分类一并删除
this.deleteAllResourceDiyType(id);
return CallBack.success(true);
}
......@@ -291,4 +318,39 @@ public class DiyTypeController {
tree(list,voList);
return voList;
}
/**
* 删除分类时需要将资源数据内容中已经关联的分类一并删除
* @param ids
* @return
* @author ycw
* @date: 2019年6月19日 上午11:40:04
*/
private boolean deleteAllResourceDiyType(List<String> ids){
// 图书
Example example = new Example(EbookDiyType.class);
example.createCriteria().andIn("diytypeid", ids);
ebookDiyTypeService.deleteByExample(example);
// 文章
example = new Example(ArticleLibraryDiyType.class);
example.createCriteria().andIn("dtid", ids);
articleLibraryDiyTypeService.deleteByExample(example);
// 音频
example = new Example(AudioLibraryDiyType.class);
example.createCriteria().andIn("dtid", ids);
audioLibraryDiyTypeService.deleteByExample(example);
// 作者
example = new Example(AuthorLibraryDiytype.class);
example.createCriteria().andIn("diytypeId", ids);
authorLibraryDiytypeService.deleteByExample(example);
// 视频
example = new Example(VideoLibraryDiyTypeRelation.class);
example.createCriteria().andIn("dtid", ids);
videoLibraryDiyTypeService.deleteByExample(example);
// 图片
example = new Example(ImageLibraryDiyType.class);
example.createCriteria().andIn("dtid", ids);
imageLibraryService.deleteByExample(example);
return true;
}
}
......@@ -16,10 +16,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.form.resource.bg.label.SaveUpdateLabelContentForm;
import com.zrqx.core.form.resource.bg.label.SaveUpdateLabelForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryLabelContentDiyType;
import com.zrqx.core.model.resource.authorLibrary.AuthorLibraryLabelContentDiyType;
import com.zrqx.core.model.resource.ebook.EbookLabelContentDiyType;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
......@@ -27,6 +32,9 @@ import com.zrqx.core.vo.resource.label.LabelAndContentByDataTypeVO;
import com.zrqx.core.vo.resource.label.LabelContentDiyTypeVO;
import com.zrqx.core.vo.resource.label.LabelListVO;
import com.zrqx.core.vo.resource.label.LabelOneVO;
import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryLabelContentDiyTypeService;
import com.zrqx.resource.bg.service.authorLibrary.AuthorLibraryLabelContentDiyTypeService;
import com.zrqx.resource.bg.service.ebook.EbookLabelContentDiyTypeService;
import com.zrqx.resource.bg.service.label.LabelContentDiyTypeService;
import com.zrqx.resource.bg.service.label.LabelDataTypeService;
import com.zrqx.resource.bg.service.label.LabelService;
......@@ -45,6 +53,13 @@ public class LabelController {
private LabelDataTypeService adrService;
@Autowired
private LabelContentDiyTypeService labelContentDiyTypeService;
@Autowired
private EbookLabelContentDiyTypeService ebookLabelContentDiyTypeService;
@Autowired
private ArticleLibraryLabelContentDiyTypeService articleLibraryLabelContentDiyTypeService;
@Autowired
private AuthorLibraryLabelContentDiyTypeService authorLibraryLabelContentDiyTypeService;
@ApiOperation(value = "查询标签", notes = "根据ID查询")
@GetMapping(value = ResourceRequestPath.GET_OID)
......@@ -88,13 +103,19 @@ public class LabelController {
@ApiOperation(value = "删除标签", notes = "删除标签")
@PostMapping(value = ResourceRequestPath.DELETE_OID)
public CallBack<Boolean> delete(@PathVariable Integer oid) {
return CallBack.success(service.batchDelete(Arrays.asList(oid)));
if(service.batchDelete(Arrays.asList(oid))){
this.deleteAllResourceLabelOrContent(Arrays.asList(oid), "labelId");
}
return CallBack.success(true);
}
@ApiOperation(value = "批量删除标签", notes = "批量删除标签")
@PostMapping(value = ResourceRequestPath.BATCH + ResourceRequestPath.DELETE)
public CallBack<Boolean> deleteByIds(@RequestBody List<Integer> ids) {
return CallBack.success(service.batchDelete(ids));
if(service.batchDelete(ids)){
this.deleteAllResourceLabelOrContent(ids, "labelId");
}
return CallBack.success(true);
}
@ApiOperation(value = "查询标签内容", notes = "根据标签id查询列表")
......@@ -124,7 +145,32 @@ public class LabelController {
@ApiOperation(value = "批量删除标签内容", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.CONTENT + ResourceRequestPath.DELETE)
public CallBack<Boolean> delete(@RequestBody List<Integer> ids) {
return CallBack.success(labelContentDiyTypeService.batchDelete(ids));
if(labelContentDiyTypeService.batchDelete(ids)){
this.deleteAllResourceLabelOrContent(ids, "labelContentDiyTypeId");
}
return CallBack.success(true);
}
/**
* 删除分类时需要将资源数据内容中已经关联的分类一并删除
* @param ids
* @return
* @author ycw
* @date: 2019年7月23日 上午10:40:04
*/
private boolean deleteAllResourceLabelOrContent(List<Integer> ids, String field){
// 医著
Example example = new Example(EbookLabelContentDiyType.class);
example.createCriteria().andIn(field, ids);
ebookLabelContentDiyTypeService.deleteByExample(example);
// 文章
example = new Example(ArticleLibraryLabelContentDiyType.class);
example.createCriteria().andIn(field, ids);
articleLibraryLabelContentDiyTypeService.deleteByExample(example);
// 作者
example = new Example(AuthorLibraryLabelContentDiyType.class);
example.createCriteria().andIn(field, ids);
authorLibraryLabelContentDiyTypeService.deleteByExample(example);
return true;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论