提交 173184c7 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 1c244f2f
package com.zrqx.core.enums;
import java.util.HashMap;
import org.apache.commons.lang3.StringUtils;
/**
* 销售方式 0 内容公开 1普通会员免费 2VIP会员免费 3购买单品4:不可售
* @author ycw
* @date 2019年3月15日上午9:23:49
*/
public enum SalesWayEnum {
/** 0:会员可见*/
STATUS_0(0,"内容公开"),
/** 1:普通会员免费*/
STATUS_1(1,"普通会员免费"),
/** 2:VIP会员免费*/
STATUS_2(2,"VIP会员免费"),
/** 3:购买单品*/
STATUS_3(3,"购买单品"),
/** 4:不可售*/
STATUS_4(4,"不可售");
private final Integer code;
private final String name;
private SalesWayEnum(Integer code,String name){
this.code=code;
this.name=name;
}
public static SalesWayEnum valueOfCode(String code) {
if (StringUtils.isBlank(code)) {
throw new IllegalArgumentException("Library Status " + code + " is blank");
}
for (SalesWayEnum mt : values()) {
if (mt.getCode().toString().equals(code)) {
return mt;
}
}
throw new IllegalArgumentException("Library Status " + code + " is not exist");
}
/**
* 通过ID获取中文名称
* @param code
* @return
*/
public static String getName(Integer code) {
if (code == null) {
return null;
}
for (SalesWayEnum mt : values()) {
if (mt.getCode().equals(code)) {
return mt.getName();
}
}
return null;
}
/**
* 获取所有的枚举,以MAP返回
* @return
*/
public static HashMap<String,String> getAllEnumMap() {
HashMap<String,String> map = new HashMap<String,String>();
for (SalesWayEnum mt : values()) {
map.put(mt.getCode()+"", mt.getName());
}
return map;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
......@@ -4,7 +4,6 @@ import java.math.BigDecimal;
import java.util.List;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryLabelContentDiyType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
......@@ -51,6 +52,7 @@ import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryService;
import com.zrqx.resource.bg.service.articlelibrary.ArticleResourceService;
import com.zrqx.resource.bg.service.audiolibrary.AudioLibraryService;
import com.zrqx.resource.bg.service.pdffilelibrary.PdfLibraryService;
import com.zrqx.resource.bg.service.recommend.RecommendResourceService;
import com.zrqx.resource.bg.service.videolibrary.VideoLibraryService;
/**
......@@ -71,7 +73,9 @@ public class ArticleLibraryController {
private ResourceRelationService resourceRelationService;
@Autowired
private ArticleLibraryLabelContentDiyTypeService alcdService;
/** 推荐位内容*/
@Autowired
private RecommendResourceService recommendResourceService;
@Autowired
private AudioLibraryService audioLibraryService;
......@@ -158,6 +162,21 @@ public class ArticleLibraryController {
}
return CallBack.success();
}
@ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = ResourceRequestPath.DELETE_OID)
public CallBack<Boolean> delete(@PathVariable String oid) {
ArticleLibrary entity = service.selectByPrimaryKey(oid);
if (entity.getBookId() != null) {
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));
}
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.BATCH + ResourceRequestPath.DELETE)
public CallBack<Boolean> deleteByIds(@RequestBody List<String> ids) {
......
......@@ -32,6 +32,9 @@ public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
+ "on a.id = ad.alid "
+ "where 1=1 and a.isDelete = 1 "
+ "</if>"
+ "<if test='form.resourceType != null' >"
+ "and a.resourceType = #{form.resourceType} "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.diyTypeCode)'>"
+ "and ad.code like concat(#{form.diyTypeCode},'%') "
+ "</if>"
......@@ -41,23 +44,15 @@ public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
+ "#{id}"
+ "</foreach>"
+ "</if>"
+ "<if test = 'form.option!=null'>"
+ "<if test='form.option==1'>"
+ "<if test = '" + NOTBLANK + "(form.title)'>"
+ " and a.title like concat('%',#{form.title},'%') "
+ "</if>"
+ "</if>"
+ "<if test='form.option==2'>"
+ "<if test = '" + NOTBLANK + "(form.author)'>"
+ " and a.author like concat('%',#{form.author},'%') "
+ "</if>"
+ "</if>"
+ "<if test='form.option==3'>"
+ "<if test = '" + NOTBLANK + "(form.source)'>"
+ " and a.source like concat('%',#{form.source},'%') "
+ "</if>"
+ "</if>"
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.name)'>"
+ "and a.name like concat('%',#{form.name},'%') "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.author)'>"
+ "and a.author like concat('%',#{form.author},'%') "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.source)'>"
+ "and ( a.source like concat('%',#{form.source},'%') or a.bookName like concat('%',#{form.source},'%') ) "
+ "</if>"
+ "<if test='form.status != null'>"
+ "and a.status = #{form.status}"
+ "</if>"
......
......@@ -8,11 +8,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
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;
......@@ -36,6 +36,8 @@ import com.zrqx.resource.bg.mapper.audiolibrary.AudioLibraryMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
import com.zrqx.resource.bg.mapper.videolibrary.VideoLibraryMapper;
import tk.mybatis.mapper.entity.Example;
/**
* 文章库
*/
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论