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

--no commit message

上级 5941249a
......@@ -17,7 +17,7 @@ public enum ResourceTypeEnum {
*/
ARTICLE(2, "文章"),
/**
* 文章
* 作者
*/
AUTHOR(3, "作者"),
/**
......
......@@ -9,8 +9,4 @@ public class IsExistForm {
private String name;
@ApiModelProperty(value = "推荐位代码")
private String code;
@ApiModelProperty(value = "民族 1蒙古族 2侗族 3藏族 4朝鲜族 5土家族 6回族 7满族 8汉族", required = true)
private Integer nationsType;
@ApiModelProperty(value = "推荐位类型:1公共推荐位 2民族推荐位 3民族主页推荐位", required = true)
private Integer recommendType;
}
......@@ -23,8 +23,4 @@ public class SaveRecommendForm {
private String descriptions;
@ApiModelProperty("状态:0禁用,1启用")
private Integer status;
@ApiModelProperty(value = "民族 1蒙古族 2侗族 3藏族 4朝鲜族 5土家族 6回族 7满族 8汉族")
private Integer nationsType;
@ApiModelProperty(value = "推荐位类型:1公共推荐位 2民族推荐位 3民族主页推荐位")
private Integer recommendType;
}
......@@ -170,15 +170,15 @@ public class ArticleLibraryController {
public CallBack<Boolean> delete(@PathVariable String oid) {
ArticleLibrary entity = service.selectByPrimaryKey(oid);
if (entity.getBookId() != null) {
throw new BusinessValidateException("图书内拆分出来的文章不支持单独上、下架、删除操作");
throw new BusinessValidateException("图书内拆分出来的文章不支持删除操作");
}
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
//这里需要级联删除其他接口关联资源
//----推荐位内容
recommendResourceService.delectByResourceIds(Arrays.asList(oid), entity.getResourceType());
return CallBack.success(service.deleteByPrimaryKey(oid));
if (!service.batchDelete(Arrays.asList(oid))) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success(true);
}
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.BATCH + ResourceRequestPath.DELETE)
......@@ -186,11 +186,23 @@ public class ArticleLibraryController {
if (ids.size() == 0) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "没有选中任何数据,请重新选择");
}
Example example = service.createExample();
example.createCriteria().andIn("id", ids);
List<ArticleLibrary> list = service.selectByExample(example);
for (ArticleLibrary entity : list) {
if(entity.getBookId() != null){
throw new BusinessValidateException("图书内拆分出来的文章不支持删除操作");
}
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
}
if (!service.batchDelete(ids)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "查询", notes = "根据ID查询")
@GetMapping(value = ResourceRequestPath.GET_OID)
public CallBack<ArticleLibraryOneVO> getById(@PathVariable String oid) {
......
......@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -61,6 +62,7 @@ import com.zrqx.resource.bg.service.ebook.EbookService;
import com.zrqx.resource.bg.service.imagelibrary.ImageLibraryDiyTypeRelationService;
import com.zrqx.resource.bg.service.imagelibrary.ImageLibraryService;
import com.zrqx.resource.bg.service.pdffilelibrary.PdfLibraryService;
import com.zrqx.resource.bg.service.recommend.RecommendResourceService;
import com.zrqx.resource.commons.Redis;
import io.swagger.annotations.Api;
......@@ -102,7 +104,9 @@ public class EbookController {
private ResourceRelationService resourceRelationService;
@Autowired
private ArticleLibraryService articleLibraryService;
/** 推荐位内容 */
@Autowired
private RecommendResourceService recommendResourceService;
@ApiOperation("保存/更新电子书")
@PostMapping(ResourceRequestPath.SAVE)
public CallBack<?> saveBook(@RequestBody SaveUpdateEbookForm form) {
......@@ -223,19 +227,27 @@ public class EbookController {
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.BATCH_DELETE)
public CallBack<Boolean> delete(@RequestBody List<String> ids) {
if (!listDelete(ids, EbookStatusEnum._6, true, EbookStatusEnum._4)) {// 如果状态是
// 4已上架
// 不能变更为6逻辑删除
throw new BusinessValidateException("请先下架,再删除数据。");
}
// 文章
// 修改文章状态
// 这里需要级联删除其他接口关联资源
// ----推荐位内容
recommendResourceService.delectByResourceIds(ids, AllResourceTypeEnum.TUSHU.getCode());
//
resourceService.delectByResourceIds(ids, AllResourceTypeEnum.TUSHU.getCode());
// 删除文章
Example example = alservice.createExample();
example.createCriteria().andIn("bookId", ids);
ArticleLibrary article = new ArticleLibrary();
article.setStatus(1);
alservice.UpdateByExampleSelective(article,example);
List<ArticleLibrary> articleList = alservice.selectByExample(example);
List<String> articleIds = articleList.stream().map(ArticleLibrary :: getId).collect(Collectors.toList());
alservice.batchDelete(articleIds);
// 删除图片
example = ilService.createExample();
example.createCriteria().andIn("bookId", ids);
List<ImageLibrary> imageList = ilService.selectByExample(example);
List<Integer> imageIds = imageList.stream().map(ImageLibrary :: getId).collect(Collectors.toList());
ilService.batchDelete(imageIds);
return CallBack.success();
}
@ApiOperation("查询电子书列表")
......
......@@ -129,17 +129,33 @@ public class ImageLibraryController {
public CallBack<Boolean> delete(@PathVariable Integer oid){
ImageLibrary entity = service.selectByPrimaryKey(oid);
if(entity.getBookId() != null){
throw new BusinessValidateException("图书内拆分出来的文章不支持单独上、下架、删除操作");
throw new BusinessValidateException("图书内拆分出来的文章不支持单独删除操作");
}
//还需删除与自定义分类关系
Example example = idrService.createExample();
example.createCriteria().andIn("ilId", Arrays.asList(oid));
idrService.deleteByExample(example);
return CallBack.success(service.deleteByPrimaryKey(oid));
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
if (!service.batchDelete(Arrays.asList(oid))) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success(true);
}
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.BATCH_DELETE)
public CallBack<Boolean> deleteByIds(@RequestBody List<Integer> ids) {
if (ids.size() == 0) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "没有选中任何数据,请重新选择");
}
Example example = service.createExample();
example.createCriteria().andIn("id", ids);
List<ImageLibrary> list = service.selectByExample(example);
for (ImageLibrary entity : list) {
if(entity.getBookId() != null){
throw new BusinessValidateException("图书内拆分出来的图片不支持单独删除操作");
}
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
}
return CallBack.success(service.batchDelete(ids));
}
@ApiOperation(value = "查询", notes = "根据ID查询")
......
......@@ -125,7 +125,7 @@ public class PdfLibraryController {
}
@ApiOperation(value = "查询", notes = "根据ID查询")
@GetMapping(value = ResourceRequestPath.GET_OID)
public CallBack<PdfLibraryOneVO> getById(@PathVariable Integer oid) {
public CallBack<PdfLibraryOneVO> getById(@PathVariable String oid) {
PdfLibrary entity = service.selectByPrimaryKey(oid);
PdfLibraryOneVO vo = new PdfLibraryOneVO();
BeanUtils.copyProperties(entity,vo);
......
......@@ -2,6 +2,7 @@ package com.zrqx.resource.bg.mapper.articlelibrary;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
......@@ -29,4 +30,25 @@ public interface ArticleResourceMapper extends BaseMapper<ArticleResource> {
+ "where objectId = #{objectId} and resourceId = #{resourceId}"
+ "</script>")
List<ArticleResource> queryByid(@Param("objectId")String objectId,@Param("resourceId")String resourceId);
@Delete("<script>"
+ "delete from res_article_resource "
+ "where 1 = 1 "
+ "<if test='type != null' >"
+ "and resourceType = #{type} "
+ "</if>"
+ "<if test='ids != null and ids.size > 0'>"
+ "and resourceId in "
+ " <foreach collection=\"ids\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\")\">"
+ "#{id}"
+ "</foreach>"
+ "</if>"
+ "<if test='ids != null and ids.size > 0'>"
+ "or ( articleId in "
+ " <foreach collection=\"ids\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\"))\">"
+ "#{id}"
+ "</foreach>"
+ "</if>"
+ "</script>")
boolean delectByResourceIds(@Param("ids")List<String> ids, @Param("type")Integer type);
}
......@@ -2,6 +2,7 @@ package com.zrqx.resource.bg.mapper.ebook;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
......@@ -30,4 +31,24 @@ public interface EbookResourceMapper extends BaseMapper<EbookResource> {
+ "where objectId = #{objectId} and resourceId = #{resourceId}"
+ "</script>")
List<EbookResource> queryByid(@Param("objectId")String objectId,@Param("resourceId")String resourceId);
@Delete("<script>"
+ "delete from res_ebook_resource "
+ "where 1 = 1 "
+ "<if test='type != null' >"
+ "and resourceType = #{type} "
+ "</if>"
+ "<if test='ids != null and ids.size > 0'>"
+ "and resourceId in "
+ " <foreach collection=\"ids\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\")\">"
+ "#{id}"
+ "</foreach>"
+ "</if>"
+ "<if test='ids != null and ids.size > 0'>"
+ "or ( ebookId in "
+ " <foreach collection=\"ids\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\"))\">"
+ "#{id}"
+ "</foreach>"
+ "</if>"
+ "</script>")
boolean delectByResourceIds(@Param("ids")List<String> ids, @Param("type")Integer type);
}
......@@ -9,11 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.enums.ArticleTypeEnum;
import com.zrqx.core.enums.AuditStatusEnum;
import com.zrqx.core.enums.ResponseCodeEnum;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.enums.resource.SalesWayEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.form.resource.bg.articlelibrary.QueryArticleLibraryForm;
......@@ -21,9 +18,7 @@ import com.zrqx.core.form.resource.bg.articlelibrary.SaveUpdateArticleLibraryFor
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.model.resource.audiolibrary.AudioLibrary;
import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
import com.zrqx.core.model.resource.videolibrary.VideoLibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryLabelContentDiyType;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
......@@ -32,8 +27,10 @@ import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryDiyTypeMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryLabelContentDiyTypeMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleResourceMapper;
import com.zrqx.resource.bg.mapper.audiolibrary.AudioLibraryMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
import com.zrqx.resource.bg.mapper.recommend.RecommendResourceMapper;
import com.zrqx.resource.bg.mapper.videolibrary.VideoLibraryMapper;
import tk.mybatis.mapper.entity.Example;
......@@ -56,6 +53,11 @@ public class ArticleLibrarySerivceImpl extends BaseServiceImpl<ArticleLibrary,St
private PdfLibraryMapper pdfLibraryMapper;
@Autowired
private VideoLibraryMapper videoLibraryMapper;
@Autowired
private ArticleResourceMapper arMapper;
@Autowired
private RecommendResourceMapper recommendResourceMapper;
@Override
public BaseMapper<ArticleLibrary> getMapper() {
return mapper;
......@@ -104,23 +106,19 @@ public class ArticleLibrarySerivceImpl extends BaseServiceImpl<ArticleLibrary,St
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "没有选中任何数据,请重新选择");
}
Example example = createExample();
example.createCriteria().andIn("id", ids);
List<ArticleLibrary> list = mapper.selectByExample(example);
for (ArticleLibrary entity : list) {
if(entity.getBookId() != null && entity.getBookId() != ""){
throw new BusinessValidateException("图书内拆分出来的文章不支持单独上、下架、删除操作");
}
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
//逻辑删除文章
entity.setIsDelete(2);
mapper.updateByPrimaryKey(entity);
//还需删除与自定义分类关系
example = new Example(ArticleLibraryDiyType.class);
example.createCriteria().andIn("alId", ids);
adrMapper.deleteByExample(example);
}
example.createCriteria().andIn("id", ids);
mapper.deleteByExample(example);
//还需删除与自定义分类关系
example = new Example(ArticleLibraryDiyType.class);
example.createCriteria().andIn("alId", ids);
adrMapper.deleteByExample(example);
//还需删除与标签关系
example = new Example(ArticleLibraryLabelContentDiyType.class);
example.createCriteria().andIn("alId", ids);
alcdMapper.deleteByExample(example);
// 删除推荐位,促销,关联资源
recommendResourceMapper.delectByResourceIds(ids, null);
arMapper.delectByResourceIds(ids, null);
return true;
}
@Override
......
......@@ -33,4 +33,5 @@ public interface EbookResourceService extends BaseService<EbookResource, Integer
*/
Integer getMaxOrderNum();
public List<EbookResource> queryByid(String objectId, String resourceId);
boolean delectByResourceIds(List<String> ids, Integer type);
}
......@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.zrqx.core.exception.BaseException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.ebook.EbookResource;
......@@ -58,5 +59,16 @@ public class EbookResourceServiceImpl extends BaseServiceImpl<EbookResource, Int
// TODO Auto-generated method stub
return bookResourceMapper.queryByid(objectId,resourceId);
}
@Override
public boolean delectByResourceIds(List<String> ids, Integer type) {
if(ids == null || ids.size() == 0 ){
throw new ParameterValidateException(1, "id不能为空");
}
if(type == null){
throw new ParameterValidateException(2, "资源类型不能为空");
}
return bookResourceMapper.delectByResourceIds(ids, type);
}
}
......@@ -135,7 +135,8 @@ public class EbookServiceImpl extends BaseServiceImpl<Ebook, String> implements
@Override
public PageInfo<EbookListVO> page(QueryEbookInfoForm form, PageParam pageParam) {
startPage(pageParam);
List<EbookListVO> list = ebookMapper.page(form);
List<EbookListVO> list = ebookMapper.
page(form);
return new PageInfo<EbookListVO>(list);
}
......
package com.zrqx.resource.commons.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
......@@ -44,21 +49,32 @@ public class Swagger2Config {
@Bean
public Docket createRestApi() {
//添加head参数start
ParameterBuilder tokenPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<Parameter>();
tokenPar.name("y-token").description("y令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
pars.add(tokenPar.build());
tokenPar.name("x-token").description("x令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
pars.add(tokenPar.build());
//添加head参数end
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(RequestHandlerSelectors.basePackage("com.zrqx"))
.paths(PathSelectors.any())
.build();
.build()
.globalOperationParameters(pars);
}
//构建 api文档的详细信息函数
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("resource 测试使用 Swagger2 构建RESTful API")
.title("sysUser 测试使用 Swagger2 构建RESTful API")
//描述
.description("resource服务 API 描述")
.description("sysUser服务 API 描述")
//创建人
.contact(new Contact("陈新昌", "www.baidu.com", "cxinchang@126.com"))
//版本号
......
......@@ -10,3 +10,4 @@ spring:
data:
solr:
host: http://admin:admin@localhost:8983/solr/zcq
solr-quartz: true
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论