提交 6a75b7b0 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 2ddc41d3
......@@ -10,12 +10,10 @@ import java.util.HashMap;
*/
public enum LibraryStatusEnum {
/** 已录入 */
STATUS_0(0, "已录入"),
/** 已上架*/
STATUS_1(1, "已上架"),
/** 未上架 */
STATUS_2(2, "未上架");
STATUS_0(0, "未上架");
private final Integer code;
private final String name;
......
package com.zrqx.core.form.resource.bg.articlelibrary;
import java.math.BigDecimal;
import java.util.List;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
......@@ -17,10 +16,5 @@ public class BatchUpdateArticleLibraryForm {
private Integer status;
@ApiModelProperty(value = "分类id")
private List<ArticleLibraryDiyType> diyType;
@ApiModelProperty("定价")
private BigDecimal price;
@ApiModelProperty("售价")
private BigDecimal realPrice;
@ApiModelProperty("全文阅读权限 0 游客可见 1会员可见")
private Integer readTextPower;
}
......@@ -8,13 +8,9 @@ import lombok.Data;
@Data
@ApiModel(value="QueryArticleLibraryForm",description="文章库")
public class QueryArticleLibraryForm {
@ApiModelProperty(value = "文章标题")
@ApiModelProperty(value = "文章标题、作者、所属杂志")
private String name;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("所属图书")
private String source;
@ApiModelProperty("状态:0待审核,1已上架,2已下架")
@ApiModelProperty("状态:0已下架,1已上架")
private String status;
@ApiModelProperty(value="上传时间-开始")
private String beginTime;
......@@ -24,6 +20,4 @@ public class QueryArticleLibraryForm {
private List<Integer> diyTypeId;
@ApiModelProperty("自定义分类code")
private String diyTypeCode;
@ApiModelProperty("资源类型 0全部 1图书、2医家、3文章、4图片、5视频、6音频、7附件资源 ")
private Integer resourceType;
}
......@@ -23,8 +23,6 @@ public class SaveUpdateArticleLibraryForm {
private String source;
@ApiModelProperty("关键词")
private String keywords;
@ApiModelProperty("定价")
private BigDecimal price;
@ApiModelProperty("简介")
private String synopsis;
@ApiModelProperty("正文")
......@@ -33,23 +31,8 @@ public class SaveUpdateArticleLibraryForm {
private String pdf;
@ApiModelProperty("封面")
private String img;
@ApiModelProperty("音频文件")
private String audio;
@ApiModelProperty("视频文件")
private String video;
@ApiModelProperty("售价")
private BigDecimal realPrice;
@ApiModelProperty("全文阅读权限 0 游客可见 1会员可见")
private Integer readTextPower;
@ApiModelProperty(value = "分类id")
private List<ArticleLibraryDiyType> diyType;
@ApiModelProperty(value = "预览文章")
private String previewText;
@ApiModelProperty("售价选项 0 免费,1收费")
private Integer priceOption;
@ApiModelProperty("pdf名称")
private String pdfName;
@ApiModelProperty(value = "作者名称和id(用,隔开)")
private String authorNameAndId;
}
......@@ -2,8 +2,6 @@ package com.zrqx.core.form.resource.bg.ebook;
import java.util.List;
import com.zrqx.core.model.resource.ebook.EbookDiyType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......
......@@ -37,7 +37,7 @@ public class ArticleLibrary {
private String text;
@ApiModelProperty("pdf")
private String pdf;
@ApiModelProperty("状态:0待审核,1已上架,2已下架")
@ApiModelProperty("状态:0已下架、1已上架")
private Integer status;
@ApiModelProperty("图书id")
private String bookId;
......
......@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
......@@ -14,9 +15,9 @@ import lombok.Data;
@Table(name = "res_Article_Library_Diy_Type")
public class ArticleLibraryDiyType {
@Id
@GeneratedValue(generator="JDBC")
@GeneratedValue(strategy =GenerationType.IDENTITY, generator = "SELECT REPLACE (UUID(), '-', '')")
@ApiModelProperty("文章与自定义分类关系表id")
private Integer id;
private String id;
@ApiModelProperty("文章库id")
private String alId;
@ApiModelProperty("自定义分类id")
......
......@@ -15,7 +15,7 @@ import lombok.Data;
public class PdfLibraryDiyType {
@Id
@GeneratedValue(strategy =GenerationType.IDENTITY, generator = "SELECT REPLACE (UUID(), '-', '')")
@ApiModelProperty("文章id,新增时不需要填写")
@ApiModelProperty("pdfId,新增时不需要填写")
private String id;
@ApiModelProperty("PDF库id")
private String plId;
......
......@@ -12,24 +12,10 @@ public class ArticleLibraryListVO {
private String name;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("来源")
@ApiModelProperty("所属杂志")
private String source;
@ApiModelProperty("所属图书")
private String bookName;
@ApiModelProperty("定价")
private String price;
@ApiModelProperty("售价")
private String realPrice;
@ApiModelProperty("上传时间")
private String uploadTime;
@ApiModelProperty("状态:0待审核,1已上架,2已下架")
@ApiModelProperty("状态:0已下架,1已上架")
private String status;
@ApiModelProperty("状态:0待审核,1已上架,2已下架")
private String status_zh;
@ApiModelProperty("封面图片")
private String img;
@ApiModelProperty("民族 1蒙古族 2侗族 3藏族 4朝鲜族 5土家族 6回族 7满族 8汉族")
private Integer nationsType;
@ApiModelProperty("1图书、2医家、3文章、4图片、5视频、6音频、7附件")
private Integer resourceType;
}
package com.zrqx.resource.bg.controller.articlelibrary;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -18,24 +16,17 @@ import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.enums.ResponseCodeEnum;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.exception.BaseException;
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.QueryResourceRelationForm;
import com.zrqx.core.form.resource.bg.SaveResourceRelationForm;
import com.zrqx.core.form.resource.bg.articlelibrary.BatchUpdateArticleLibraryForm;
import com.zrqx.core.form.resource.bg.articlelibrary.QueryArticleLibraryForm;
import com.zrqx.core.form.resource.bg.articlelibrary.SaveUpdateArticleLibraryForm;
import com.zrqx.core.form.resource.bg.articlelibrary.UpdateArticleImgForm;
import com.zrqx.core.form.resource.bg.ebook.UpdateEbookRelationForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.model.resource.articlelibrary.ArticleResource;
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.ResourceRelationVo;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryOneVO;
import com.zrqx.resource.bg.service.ResourceRelationService;
......@@ -59,10 +50,6 @@ public class ArticleLibraryController {
private ArticleLibraryService service;
@Autowired
private ArticleLibraryDiyTypeService adrService;
@Autowired
private ArticleResourceService resourceService;
@Autowired
private ResourceRelationService resourceRelationService;
@ApiOperation(value = "新增", notes = "新增一个")
@PostMapping(value = ResourceRequestPath.SAVE)
public CallBack<Boolean> save(@RequestBody SaveUpdateArticleLibraryForm form) {
......@@ -78,7 +65,6 @@ public class ArticleLibraryController {
if (!service.saveOrUpdate(form)) {
throw new BusinessValidateException("操作失败");
}
ArticleLibrary entity = service.selectByPrimaryKey(form.getId());
return CallBack.success();
}
......@@ -94,49 +80,6 @@ public class ArticleLibraryController {
return CallBack.success();
}
@ApiOperation(value = "批量审核", notes = "批量审核")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE_STATUS)
public CallBack<Boolean> updateArray(@RequestBody List<String> ids) {
Example example = service.createExample();
example.createCriteria().andIn("id", ids);
ArticleLibrary entity = new ArticleLibrary();
entity.setStatus(LibraryStatusEnum.STATUS_1.getCode());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity,example)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改阅读权限", notes = "批量修改阅读权限")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE_READ)
public CallBack<Boolean> updateReadTextPower(@RequestBody BatchUpdateArticleLibraryForm form) {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
ArticleLibrary entity = new ArticleLibrary();
entity.setReadTextPower(form.getReadTextPower());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity,example)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改价格", notes = "批量修改价格")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE_PRICE)
public CallBack<Boolean> updatePrice(@RequestBody BatchUpdateArticleLibraryForm form) {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
ArticleLibrary entity = new ArticleLibrary();
entity.setRealPrice(form.getRealPrice());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity,example)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改分类", notes = "批量修改分类")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE_DIYTIPE)
public CallBack<Boolean> updateDivType(@RequestBody BatchUpdateArticleLibraryForm form) {
......@@ -163,14 +106,14 @@ public class ArticleLibraryController {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
List<ArticleLibrary> list = service.selectByExample(example);
for (ArticleLibrary entity : list) {
/* for (ArticleLibrary entity : list) {
if (entity.getStatus() == LibraryStatusEnum.STATUS_0.getCode()) {
throw new BusinessValidateException("待审核状态的文章不能直接操作上架状态需通过批量审核操作上架");
}
if (entity.getBookId() != null) {
throw new BusinessValidateException("图书内拆分出来的文章不支持单独上、下架、删除操作");
}
}
}*/
for (ArticleLibrary entity : list) {
entity.setStatus(form.getStatus());
entity.setUpdateTime(new Date());
......@@ -185,9 +128,9 @@ public class ArticleLibraryController {
@PostMapping(value = ResourceRequestPath.DELETE_OID)
public CallBack<Boolean> delete(@PathVariable String oid) {
ArticleLibrary entity = service.selectByPrimaryKey(oid);
if (entity.getBookId() != null) {
/*if (entity.getBookId() != null) {
throw new BusinessValidateException("图书内拆分出来的文章不支持单独上、下架、删除操作");
}
}*/
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
......@@ -204,9 +147,9 @@ public class ArticleLibraryController {
example.createCriteria().andIn("id", ids);
List<ArticleLibrary> list = service.selectByExample(example);
for (ArticleLibrary entity : list) {
if(entity.getBookId() != null){
/* if(entity.getBookId() != null){
throw new BusinessValidateException("图书内拆分出来的文章不支持单独上、下架、删除操作");
}
}*/
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BusinessValidateException("不能删除已上架的资源");
}
......@@ -220,17 +163,6 @@ public class ArticleLibraryController {
ArticleLibrary entity = service.selectByPrimaryKey(oid);
ArticleLibraryOneVO vo = new ArticleLibraryOneVO();
BeanUtils.copyProperties(entity, vo);
if(StringUtils.isNotBlank(entity.getAuthorId())){
vo.setAuthorNameAndId(entity.getAuthor() + "," + entity.getAuthorId());
}else{
vo.setAuthorNameAndId(entity.getAuthor());
}
if(entity.getRealPrice() != null){
vo.setRealPrice(entity.getRealPrice().toString());
}
if(entity.getPrice() != null){
vo.setPrice(entity.getPrice().toString());
}
//组装自定义分类
Example example = adrService.createExample();
example.createCriteria().andEqualTo("alId", oid);
......@@ -244,44 +176,6 @@ public class ArticleLibraryController {
public CallBack<PageInfo<ArticleLibraryListVO>> page(QueryArticleLibraryForm form, PageParam pageParam){
return CallBack.success(service.page(form, pageParam));
}
@ApiOperation("相关资源列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.PAGE)
public CallBack<PageInfo<ResourceRelationVo>> reousrceRelationPage(QueryResourceRelationForm entity,
PageParam pageParam) {
if (entity == null || entity.getId() == null) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "资源id不能为空!");
}
List<ResourceRelationVo> list = resourceService.queryByIdAndResourceType(entity, pageParam);
if (list == null || list.size() == 0) {
return CallBack.success(new PageInfo<ResourceRelationVo>(list));
}
return CallBack.success(new PageInfo<ResourceRelationVo>(resourceRelationService.queryRelationList(list)));
}
@ApiOperation(value = "批量删除关联资源", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.RES_BATCH_DELETE)
public CallBack<Boolean> deleteByResourceIds(@RequestBody List<Integer> ids) {
if (ids.size() == 0) {
throw new BaseException(-7,"没有选中任何数据,请重新选择");
}
Example example = resourceService.createExample();
example.createCriteria().andIn("id", ids);
List<ArticleResource> list = resourceService.selectByExample(example);
for (ArticleResource entity : list) {
resourceService.deleteByPrimaryKey(entity);
}
return CallBack.success();
}
@ApiOperation(value = "修改排序号", notes = "修改排序号")
@PostMapping(value = ResourceRequestPath.UPDATE + ResourceRequestPath.SORT)
public CallBack<Boolean> updateSort(@RequestBody UpdateEbookRelationForm form) {
if (form.getId() == null) {
throw new ParameterValidateException("分类不能为空");
}
ArticleResource resource = resourceService.selectByPrimaryKey(form.getId());
resource.setSort(form.getSort());
resourceService.updateByPrimaryKeySelective(resource);
return CallBack.success();
}
}
......@@ -91,8 +91,6 @@ public class EbookController {
private ImageLibraryService ilService;
@Autowired
private ImageLibraryDiyTypeRelationService ildtrService;
@Autowired
private RecordService recordService;
@ApiOperation("保存电子书")
@PostMapping(ResourceRequestPath.SAVE)
......@@ -162,65 +160,6 @@ public class EbookController {
return CallBack.success(ebookservice.page(form, pageParam));
}
/*@ApiOperation("相关资源列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.PAGE)
public CallBack<PageInfo<ResourceRelationVo>> reousrceRelationPage(QueryResourceRelationForm entity,
PageParam pageParam) {
if (entity == null || entity.getId() == null) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "资源id不能为空!");
}
List<ResourceRelationVo> list = resourceService.queryByIdAndResourceType(entity, pageParam);
if (list == null || list.size() == 0) {
return CallBack.success(new PageInfo<ResourceRelationVo>(list));
}
return CallBack.success(new PageInfo<ResourceRelationVo>(resourceRelationService.queryRelationList(list)));
}
@ApiOperation(value = "保存相关资源" , notes ="保存相关资源")
@PostMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.SAVE)
public CallBack<Boolean> saveRelation(@RequestBody SaveResourceRelationForm entity){
if(entity.getId() == null || entity.getResourceIds() == null || entity.getResourceType() == null || entity.getResourceIds().length == 0){
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "必须指定id、被关联的resourceId、资源类型");
}
List<EbookResource> recordList = new ArrayList<EbookResource>();
Arrays.asList(entity.getResourceIds()).forEach(resourceId -> {
EbookResource e = new EbookResource();
e.setEbookId(entity.getId());
e.setResourceId(resourceId);
e.setCreateTime(new Date());
e.setResourceType(entity.getResourceType());
recordList.add(e);
});
return CallBack.success(resourceService.insertList(recordList));
}
@ApiOperation(value = "批量删除关联资源", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.RES_BATCH_DELETE)
public CallBack<Boolean> deleteByResourceIds(@RequestBody List<Integer> ids) {
if (ids.size() == 0) {
throw new BaseException(-7,"没有选中任何数据,请重新选择");
}
Example example = resourceService.createExample();
example.createCriteria().andIn("id", ids);
List<EbookResource> list = resourceService.selectByExample(example);
for (EbookResource entity : list) {
resourceService.deleteByPrimaryKey(entity);
}
return CallBack.success();
}
@ApiOperation(value = "修改排序号", notes = "修改排序号")
@PostMapping(value = ResourceRequestPath.UPDATE + ResourceRequestPath.SORT)
public CallBack<Boolean> updateSort(@RequestBody UpdateEbookRelationForm form) {
if (form.getId() == null) {
throw new ParameterValidateException("分类不能为空");
}
EbookResource resource = resourceService.selectByPrimaryKey(form.getId());
resource.setSort(form.getSort());
resourceService.updateByPrimaryKeySelective(resource);
return CallBack.success();
}*/
/**
* 批量修改
*
......
package com.zrqx.resource.bg.controller.pdffilelibrary;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
......@@ -15,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.form.resource.bg.pdffilelibrary.BatchUpdatePdfLibraryForm;
import com.zrqx.core.form.resource.bg.pdffilelibrary.QueryPdfLibraryForm;
......
......@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.resource.ResourceRequestPath;
......
......@@ -21,30 +21,18 @@ public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
* @return
*/
@Select("<script>"
+ "select distinct a.id,a.name,a.author,a.source,a.bookName,a.price,a.realPrice,DATE_FORMAT(a.uploadTime,'%Y-%m-%d') uploadTime,a.status,a.nationsType,a.resourceType "
+ "select distinct a.id,a.name,a.author,a.source,DATE_FORMAT(a.uploadTime,'%Y-%m-%d') uploadTime,a.status "
+ "from res_Article_Library a left join res_Article_Library_Diy_Type ad "
+ "on a.id = ad.alid "
+ "where 1=1 "
+ "<if test='form.resourceType != null' >"
+ "and a.resourceType = #{form.resourceType} "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.diyTypeCode)'>"
+ "and ad.code like concat(#{form.diyTypeCode},'%') "
+ "</if>"
/*+ "<if test='form.diyTypeId != null and form.diyTypeId.size > 0'>"
+ "and ad.dtId in "
+ " <foreach collection=\"form.diyTypeId\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\")\">"
+ "#{id}"
+ "</foreach>"
+ "</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 test = '" + NOTBLANK + "(form.name)'>"
+ "and (a.author like concat('%',#{form.name},'%') or a.source like concat('%',#{form.name},'%') or a.name like concat('%',#{form.name},'%') ) "
+ "</if>"
+ "<if test='form.status != null'>"
+ "and a.status = #{form.status}"
......
......@@ -55,35 +55,17 @@ public class ArticleLibrarySerivceImpl extends BaseServiceImpl<ArticleLibrary,St
public boolean saveOrUpdate(SaveUpdateArticleLibraryForm form) {
ArticleLibrary entity = new ArticleLibrary();
BeanUtils.copyProperties(form, entity);
if(StringUtils.isNotBlank(form.getAuthorNameAndId())){
String[] authorNameAndId = form.getAuthorNameAndId().split(",");
form.setAuthor(authorNameAndId[0]);
if(authorNameAndId.length > 1){
form.setAuthorId(authorNameAndId[1]);
}
}
if(PriceOptionEnum.STATUS_0.getCode() == form.getPriceOption()){
entity.setRealPrice(new BigDecimal(0));
}
if(entity.getId() == null){
//添加
entity.setStatus(LibraryStatusEnum.STATUS_0.getCode());
entity.setStatus(LibraryStatusEnum.STATUS_1.getCode());
entity.setUploadTime(new Date());
entity.setBrowseNum(50);//浏览数量
entity.setReadTextPower(1);
entity.setSalesNum(0);
entity.setGoodsType(GoodsTypeEnum.ARTICLE.getCode());
entity.setResourceType(AllResourceTypeEnum.ARTICLE.getCode());
mapper.insert(entity);
}else{
//修改
entity.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(entity);
if(form.getPrice() == null){
ArticleLibrary a = mapper.selectByPrimaryKey(entity.getId());
a.setPrice(form.getPrice());
mapper.updateByPrimaryKey(a);
}
//删除当前对象与自定义分类的关系
ArticleLibraryDiyType old = new ArticleLibraryDiyType();
old.setAlId(entity.getId());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论