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

--no commit message

上级 504ece24
...@@ -16,7 +16,7 @@ public enum AllResourceTypeEnum { ...@@ -16,7 +16,7 @@ public enum AllResourceTypeEnum {
BOOK(1, "图书"), BOOK(1, "图书"),
AUTHOR(2, "学者"), AUTHOR(2, "学者"),
ARTICLE(3, "章节"), ARTICLE(3, "文章"),
IMAGE(4, "图片"), IMAGE(4, "图片"),
VIDEO(5, "视频"), VIDEO(5, "视频"),
AUDIO(6, "音频"), AUDIO(6, "音频"),
......
...@@ -14,7 +14,7 @@ public enum LibraryStatusEnum { ...@@ -14,7 +14,7 @@ public enum LibraryStatusEnum {
STATUS_0(0, "待审核"), STATUS_0(0, "待审核"),
/** 已上架*/ /** 已上架*/
STATUS_1(1, "已上架"), STATUS_1(1, "已上架"),
/** 未上架 */ /** 已下架 */
STATUS_2(2, "已下架"); STATUS_2(2, "已下架");
private final Integer code; private final Integer code;
......
...@@ -8,14 +8,8 @@ import lombok.Data; ...@@ -8,14 +8,8 @@ import lombok.Data;
@Data @Data
@ApiModel(value="QueryArticleLibraryForm",description="文章库") @ApiModel(value="QueryArticleLibraryForm",description="文章库")
public class QueryArticleLibraryForm { public class QueryArticleLibraryForm {
@ApiModelProperty(value = "文章标题") @ApiModelProperty(value = "标题、作者、来源")
private String name; private String name;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("所属图书")
private String source;
@ApiModelProperty("状态:0待审核,1已上架,2已下架")
private String status;
@ApiModelProperty(value="上传时间-开始") @ApiModelProperty(value="上传时间-开始")
private String beginTime; private String beginTime;
@ApiModelProperty(value="上传时间-结束") @ApiModelProperty(value="上传时间-结束")
...@@ -24,6 +18,4 @@ public class QueryArticleLibraryForm { ...@@ -24,6 +18,4 @@ public class QueryArticleLibraryForm {
private List<Integer> diyTypeId; private List<Integer> diyTypeId;
@ApiModelProperty("自定义分类code") @ApiModelProperty("自定义分类code")
private String diyTypeCode; private String diyTypeCode;
@ApiModelProperty("资源类型 0全部 1图书、2医家、3文章、4图片、5视频、6音频、7附件资源 ")
private Integer resourceType;
} }
package com.zrqx.core.form.resource.bg.articlelibrary; package com.zrqx.core.form.resource.bg.articlelibrary;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -16,43 +14,18 @@ public class SaveUpdateArticleLibraryForm { ...@@ -16,43 +14,18 @@ public class SaveUpdateArticleLibraryForm {
private String id; private String id;
@ApiModelProperty(value = "文章标题", required = true) @ApiModelProperty(value = "文章标题", required = true)
private String name; private String name;
@ApiModelProperty("作者id")
private String authorId;
@ApiModelProperty("作者") @ApiModelProperty("作者")
private String author; private String author;
@ApiModelProperty("来源") @ApiModelProperty("来源")
private String source; private String source;
@ApiModelProperty("关键词") @ApiModelProperty("关键词")
private String keywords; private String keywords;
@ApiModelProperty("定价")
private BigDecimal price;
@ApiModelProperty("简介") @ApiModelProperty("简介")
private String synopsis; private String synopsis;
@ApiModelProperty("正文") @ApiModelProperty("正文")
private String text; private String text;
@ApiModelProperty("pdf")
private String pdf;
@ApiModelProperty("封面") @ApiModelProperty("封面")
private String img; private String img;
@ApiModelProperty("音频文件")
private String audio;
@ApiModelProperty("视频文件")
private String video;
@ApiModelProperty("售价")
private BigDecimal realPrice;
@ApiModelProperty("全文阅读权限 0 游客可见 1会员可见")
private Integer readTextPower;
@ApiModelProperty(value = "分类id") @ApiModelProperty(value = "分类id")
private List<ArticleLibraryDiyType> diyType; private List<ArticleLibraryDiyType> diyType;
@ApiModelProperty(value = "标签id")
private List<ArticleLibraryLabelContentDiyType> label;
@ApiModelProperty(value = "预览文章")
private String previewText;
@ApiModelProperty("售价选项 0 免费,1收费")
private Integer priceOption;
@ApiModelProperty("pdf名称")
private String pdfName;
@ApiModelProperty(value = "作者名称和id(用,隔开)")
private String authorNameAndId;
} }
package com.zrqx.core.model.resource.articlelibrary; package com.zrqx.core.model.resource.articlelibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
...@@ -14,9 +14,9 @@ import lombok.Data; ...@@ -14,9 +14,9 @@ import lombok.Data;
@Table(name = "res_Article_Library_Diy_Type") @Table(name = "res_Article_Library_Diy_Type")
public class ArticleLibraryDiyType { public class ArticleLibraryDiyType {
@Id @Id
@GeneratedValue(generator="JDBC") @GeneratedValue(strategy =GenerationType.IDENTITY, generator = "SELECT REPLACE (UUID(), '-', '')")
@ApiModelProperty("文章与自定义分类关系表id") @ApiModelProperty("文章与自定义分类关系表id")
private Integer id; private String id;
@ApiModelProperty("文章库id") @ApiModelProperty("文章库id")
private String alId; private String alId;
@ApiModelProperty("自定义分类id") @ApiModelProperty("自定义分类id")
......
package com.zrqx.core.model.resource.articlelibrary;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value="ArticleLibraryLabelContentDiyType",description="文章与标签关系表")
@Table(name = "res_Article_Library_Label_Content_Diy_Type")
public class ArticleLibraryLabelContentDiyType {
@Id
@GeneratedValue(generator="JDBC")
@ApiModelProperty("文章与标签内容关系表id")
private Integer id;
@ApiModelProperty("文章id")
private String alId;
@ApiModelProperty(value = "标签id")
private Integer labelId;
@ApiModelProperty(value = "标签内容id")
private Integer labelContentDiyTypeId;
@ApiModelProperty(value = "标签内容code")
private String labelContentDiyTypeCode;
}
...@@ -17,22 +17,10 @@ public class ArticleLibraryListVO { ...@@ -17,22 +17,10 @@ public class ArticleLibraryListVO {
private String author; private String author;
@ApiModelProperty("来源") @ApiModelProperty("来源")
private String source; private String source;
@ApiModelProperty("所属图书")
private String bookName;
@ApiModelProperty("定价")
private String price;
@ApiModelProperty("售价")
private String realPrice;
@ApiModelProperty("上传时间") @ApiModelProperty("上传时间")
private Date uploadTime; private Date uploadTime;
@ApiModelProperty("状态:0待审核,1已上架,2已下架") @ApiModelProperty("状态:0待审核,1已上架,2已下架")
private String status; private Integer status;
@ApiModelProperty("状态:0待审核,1已上架,2已下架") @ApiModelProperty("状态:0待审核,1已上架,2已下架")
private String status_zh; 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.core.vo.resource.articlelibrary; package com.zrqx.core.vo.resource.articlelibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
import lombok.Data;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType; 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;
import lombok.Data;
@Data @Data
@ApiModel(value="ArticleLibraryOneVO",description="单个查询文章返回的实体") @ApiModel(value="ArticleLibraryOneVO",description="单个查询文章返回的实体")
public class ArticleLibraryOneVO { public class ArticleLibraryOneVO {
...@@ -16,47 +14,18 @@ public class ArticleLibraryOneVO { ...@@ -16,47 +14,18 @@ public class ArticleLibraryOneVO {
private String id; private String id;
@ApiModelProperty(value = "文章标题") @ApiModelProperty(value = "文章标题")
private String name; private String name;
@ApiModelProperty("作者id")
private String authorId;
@ApiModelProperty("作者") @ApiModelProperty("作者")
private String author; private String author;
@ApiModelProperty("来源") @ApiModelProperty("来源")
private String source; private String source;
@ApiModelProperty("关键词") @ApiModelProperty("关键词")
private String keywords; private String keywords;
@ApiModelProperty("定价")
private String price;
@ApiModelProperty("简介") @ApiModelProperty("简介")
private String synopsis; private String synopsis;
@ApiModelProperty("正文") @ApiModelProperty("正文")
private String text; private String text;
@ApiModelProperty("pdf")
private String pdf;
@ApiModelProperty("封面") @ApiModelProperty("封面")
private String img; private String img;
@ApiModelProperty("音频文件")
private String audio;
@ApiModelProperty("售价")
private String realPrice;
@ApiModelProperty("全文阅读权限 0 游客可见 1会员可见")
private Integer readTextPower;
@ApiModelProperty("文章类型 1理论 2药物 3方剂 4临床 5医案 6文化 7机构 8其他 9未分类 10蒙文")
private Integer resourceType;
@ApiModelProperty("民族 1蒙古族 2侗族 3藏族 4朝鲜族 5土家族 6回族 7满族 8汉族")
private Integer nationsType;
@ApiModelProperty(value = "预览文章")
private String previewText;
@ApiModelProperty(value = "分类id") @ApiModelProperty(value = "分类id")
private List<ArticleLibraryDiyType> diyType; private List<ArticleLibraryDiyType> diyType;
@ApiModelProperty(value = "标签id")
private List<ArticleLibraryLabelContentDiyType> label;
@ApiModelProperty(value = "标签内容id")
private List<Integer> labelContentDiyTypeIds;
@ApiModelProperty("pdf名称")
private String pdfName;
@ApiModelProperty("售价选项 0 免费,1收费")
private Integer priceOption;
@ApiModelProperty(value = "作者名称和id(用,隔开)")
private String authorNameAndId;
} }
...@@ -4,7 +4,6 @@ import java.util.ArrayList; ...@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -24,12 +23,9 @@ import com.zrqx.core.form.resource.bg.annexlibrary.BatchUpdateAnnexLibraryForm; ...@@ -24,12 +23,9 @@ import com.zrqx.core.form.resource.bg.annexlibrary.BatchUpdateAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.annexlibrary.QueryAnnexLibraryForm; import com.zrqx.core.form.resource.bg.annexlibrary.QueryAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.annexlibrary.SaveAnnexLibraryForm; import com.zrqx.core.form.resource.bg.annexlibrary.SaveAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.annexlibrary.SaveUpdateAnnexLibraryForm; import com.zrqx.core.form.resource.bg.annexlibrary.SaveUpdateAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.recommend.UpdateRecommendResourceForm;
import com.zrqx.core.form.resource.bg.videolibrary.BatchUpdateVideoLibraryForm; import com.zrqx.core.form.resource.bg.videolibrary.BatchUpdateVideoLibraryForm;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary; import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibraryDiyType; import com.zrqx.core.model.resource.annexlibrary.AnnexLibraryDiyType;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibraryLabelContentDiyType;
import com.zrqx.core.model.resource.marketing.PromotionContent;
import com.zrqx.core.util.page.PageInfo; import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam; import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack; import com.zrqx.core.util.response.CallBack;
......
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.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RestController;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.exception.BaseException;
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.recommend.UpdateRecommendResourceForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
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.articlelibrary.ArticleLibraryListVO;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryOneVO;
import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryDiyTypeService;
import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryService;
import com.zrqx.resource.bg.service.recommend.RecommendResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import tk.mybatis.mapper.entity.Example;
/**
* 文章库Controller
*/
@RestController
@RequestMapping("/bg/article-library")
@Api(description = "资源管理-文章库")
public class ArticleLibraryController {
@Autowired
private ArticleLibraryService service;
@Autowired
private ArticleLibraryDiyTypeService adrService;
/** 推荐位内容*/
@Autowired
private RecommendResourceService recommendResourceService;
@ApiOperation(value = "新增", notes = "新增一个")
@PostMapping(value = "/save")
public CallBack<Boolean> save(@RequestBody SaveUpdateArticleLibraryForm form) {
if (!service.saveOrUpdate(form)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "更新", notes = "根据ID更新")
@PostMapping(value = "/update")
public CallBack<Boolean> update(@RequestBody SaveUpdateArticleLibraryForm form) {
if (!service.saveOrUpdate(form)) {
throw new BaseException("操作失败");
}
ArticleLibrary entity = service.selectByPrimaryKey(form.getId());
//推荐位内容修改
UpdateRecommendResourceForm res = new UpdateRecommendResourceForm();
res.setResId(form.getId());
res.setResType(entity.getResourceType());
res.setResImg(form.getImg());
res.setResName(form.getName());
recommendResourceService.updateResourceContent(res);
return CallBack.success();
}
/*@ApiOperation(value = "更新文章封面", notes = "根据ID更新")
@PostMapping(value = "/img/update")
public CallBack<Boolean> updateImg(@RequestBody UpdateArticleImgForm form) {
ArticleLibrary entity = new ArticleLibrary();
BeanUtils.copyProperties(form, entity);
entity.setUpdateTime(new Date());
if (!service.updateByPrimaryKeySelective(entity)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}*/
/*@ApiOperation(value = "批量审核", notes = "批量审核")
@PostMapping(value = "/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 BaseException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改阅读权限", notes = "批量修改阅读权限")
@PostMapping(value = "/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 BaseException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改价格", notes = "批量修改价格")
@PostMapping(value = "/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 BaseException("操作失败");
}
return CallBack.success();
}*/
@ApiOperation(value = "批量修改分类", notes = "批量修改分类")
@PostMapping(value = "/batch/update/diytype")
public CallBack<Boolean> updateDivType(@RequestBody BatchUpdateArticleLibraryForm form) {
List<ArticleLibraryDiyType> list = new ArrayList<ArticleLibraryDiyType>();
form.getIds().forEach(alId -> {
//刪除原有的分类
ArticleLibraryDiyType ob = new ArticleLibraryDiyType();
ob.setAlId(alId);
adrService.delete(ob);
//添加
List<ArticleLibraryDiyType> ls = form.getDiyType();
ls.forEach(l -> l.setAlId(alId));
list.addAll(ls);
});
if (!adrService.insertUuidList(list)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量 上架/下架", notes = "批量 上架/下架")
@PostMapping(value = "/batch/update/updown")
public CallBack<Boolean> updateShowState(@RequestBody BatchUpdateArticleLibraryForm form) {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
List<ArticleLibrary> list = service.selectByExample(example);
for (ArticleLibrary entity : list) {
entity.setStatus(form.getStatus());
entity.setUpdateTime(new Date());
if (!service.updateByPrimaryKey(entity)) {
throw new BaseException("操作失败");
}
}
return CallBack.success();
}
@ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = "/delete/{oid}")
public CallBack<Boolean> delete(@PathVariable String oid) {
ArticleLibrary entity = service.selectByPrimaryKey(oid);
if (entity.getStatus() == LibraryStatusEnum.STATUS_1.getCode()) {
throw new BaseException("不能删除已上架的资源");
}
if (!service.batchDelete(Arrays.asList(oid))) {
throw new BaseException("操作失败");
}
return CallBack.success(true);
}
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping(value = "/batch/delete")
public CallBack<Boolean> deleteByIds(@RequestBody List<String> ids) {
if (ids.size() == 0) {
throw new BaseException("没有选中任何数据,请重新选择");
}
return CallBack.success(service.batchDelete(ids));
}
@ApiOperation(value = "查询", notes = "根据ID查询")
@GetMapping(value = "/get/oid")
public CallBack<ArticleLibraryOneVO> getById(@PathVariable String oid) {
ArticleLibrary entity = service.selectByPrimaryKey(oid);
ArticleLibraryOneVO vo = new ArticleLibraryOneVO();
BeanUtils.copyProperties(entity, vo);
//组装自定义分类
Example example = adrService.createExample();
example.createCriteria().andEqualTo("alId", oid);
List<ArticleLibraryDiyType> list = adrService.selectByExample(example);
vo.setDiyType(list);
return CallBack.success(vo);
}
@ApiOperation(value = "分页查询" , notes ="分页查询")
@GetMapping(value = "/page")
public CallBack<PageInfo<ArticleLibraryListVO>> page(QueryArticleLibraryForm form, PageParam pageParam){
return CallBack.success(service.page(form, pageParam));
}
}
package com.zrqx.resource.bg.mapper.articlelibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
/**
* 文章库和自定义分类
*/
public interface ArticleLibraryDiyTypeMapper extends BaseMapper<ArticleLibraryDiyType> {
}
package com.zrqx.resource.bg.mapper.articlelibrary;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.form.resource.bg.articlelibrary.QueryArticleLibraryForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
/**
* 文章库
*/
public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
/**
* 后台 10种文章列表页查询
* @param form
* @return
*/
@Select("<script>"
+ "select a.id,a.name,a.author,a.source,a.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.diyTypeCode != null' >"
+ " and ad.code like concat('%', #{form.diyTypeCode},'%'))"
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.name)'>"
+ " and ( a.name like concat('%',#{form.name},'%')) or a.source like concat('%',#{form.name},'%') or a.author like concat('%',#{form.name},'%')) "
+ "</if>"
+ " <if test = '" + NOTBLANK + "(form.beginTime)'> "
+ " and a.uploadTime &gt;= concat(#{form.beginTime}, ' 00:00:00' ) "
+ " </if> "
+ " <if test = '" + NOTBLANK + "(form.endTime)'> "
+ " and a.uploadTime &lt;= concat(#{form.endTime}, ' 23:59:59') "
+ " </if> "
+ "</script>")
List<ArticleLibraryListVO> query(@Param("form")QueryArticleLibraryForm form);
@Select("<script>"
+ " select a.id,a.name,a.author,a.source,a.bookName,a.price,a.realPrice,a.uploadTime,a.status,a.img,a.resourceType "
+ " from res_Article_Library a left join res_Article_Library_Diy_Type ad "
+ " on a.id = ad.alid "
+ " where 1=1 and a.status = 1 "
+ "<if test = 'form.diyTypeCode != null' >"
+ " and ad.code like concat('%', #{form.diyTypeCode},'%'))"
+ "</if>"
+ "<if test = 'form.name != null' >"
+ " and a.name like concat('%',#{form.name},'%'))"
+ "</if>"
+ "<if test = 'form.resourceType != null' >"
+ " and a.resourceType = #{form.resourceType}"
+ "</if>"
+ "<if test='form.ids != null and form.ids.size > 0'>"
+ "and a.id not in "
+ " <foreach collection=\"form.ids\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\")\">"
+ "#{id}"
+ "</foreach>"
+ "</if>"
+ "</script>")
List<ArticleLibraryListVO> queryByTileAndDiyType(@Param("form")QueryResourceForPoPForm entity);
}
package com.zrqx.resource.bg.mapper.articlelibrary;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleResource;
import com.zrqx.core.vo.resource.ResourceRelationVo;
public interface ArticleResourceMapper extends BaseMapper<ArticleResource> {
@Select("<script>"
+ "select id ,resourceId,resourceType,createTime,sort from res_article_resource "
+ "where articleId = #{id} "
+ " eq(resourceType,form.resourceType) "
+ " order by sort desc , createTime desc "
+ "</script>")
List<ResourceRelationVo> queryByIdAndResourceType(@Param("form")QueryResourceRelationForm entity);
/**
* 获取关联资源最大排序
* @return
*/
@Select("select Max(sort) from res_article_resource")
Integer getMaxSort();
}
package com.zrqx.resource.bg.service.articlelibrary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryDiyTypeMapper;
/**
* 文章库和自定义分类
*/
@Service
public class ArticleLibraryDiyTypeSerivceImpl extends BaseServiceImpl<ArticleLibraryDiyType,Integer> implements ArticleLibraryDiyTypeService {
@Autowired
private ArticleLibraryDiyTypeMapper mapper;
@Override
public BaseMapper<ArticleLibraryDiyType> getMapper() {
return mapper;
}
}
package com.zrqx.resource.bg.service.articlelibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.service.BaseService;
/**
* 文章库和自定义分类
*/
public interface ArticleLibraryDiyTypeService extends BaseService<ArticleLibraryDiyType,Integer>{
}
package com.zrqx.resource.bg.service.articlelibrary;
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.stereotype.Service;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.enums.GoodsTypeEnum;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.form.resource.bg.articlelibrary.QueryArticleLibraryForm;
import com.zrqx.core.form.resource.bg.articlelibrary.SaveUpdateArticleLibraryForm;
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.membercollection.MemberCollection;
import com.zrqx.core.model.resource.record.Record;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
import com.zrqx.core.model.resource.shoppingcart.ShoppingCart;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
import com.zrqx.resource.bg.client.order.OrderClient;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryDiyTypeMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryMapper;
import com.zrqx.resource.bg.mapper.authorLibrary.ResourceRelationMapper;
import com.zrqx.resource.bg.mapper.membercollection.MemberCollectionMapper;
import com.zrqx.resource.bg.mapper.recommend.RecommendResourceMapper;
import com.zrqx.resource.bg.mapper.record.RecordMapper;
import com.zrqx.resource.bg.mapper.shoppingcart.ShoppingCartMapper;
import tk.mybatis.mapper.entity.Example;
/**
* 文章库
*/
@Service
public class ArticleLibrarySerivceImpl extends BaseServiceImpl<ArticleLibrary,String> implements ArticleLibraryService {
@Autowired
private ArticleLibraryMapper mapper;
@Autowired
private ArticleLibraryDiyTypeMapper adrMapper;
@Autowired
private OrderClient orderClient;
@Autowired
private MemberCollectionMapper memberCollectionMapper;
@Autowired
private RecordMapper recordMapper;
@Autowired
private ShoppingCartMapper shoppingCartMapper;
@Autowired
private RecommendResourceMapper recommendResourceMapper;
@Autowired
private ResourceRelationMapper resourceRelationMapper;
@Override
public BaseMapper<ArticleLibrary> getMapper() {
return mapper;
}
@Override
public boolean saveOrUpdate(SaveUpdateArticleLibraryForm form) {
ArticleLibrary entity = new ArticleLibrary();
BeanUtils.copyProperties(form, entity);
if(entity.getId() == null){
//添加
entity.setStatus(LibraryStatusEnum.STATUS_1.getCode());
entity.setUploadTime(new Date());
entity.setBrowseNum(0);//浏览数量
entity.setResourceType(AllResourceTypeEnum.ARTICLE.getCode());
mapper.insert(entity);
}else{
//修改
entity.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(entity);
//删除当前对象与自定义分类的关系
ArticleLibraryDiyType old = new ArticleLibraryDiyType();
old.setAlId(entity.getId());
adrMapper.delete(old);
}
//添加当前对象与自定义分类的关系
if(form.getDiyType() != null && form.getDiyType().size() > 0){
List<ArticleLibraryDiyType> list = form.getDiyType();
list.forEach(li -> li.setAlId(entity.getId()));
adrMapper.insertUuidList(list);
}
return true;
}
@Override
public boolean batchDelete(List<String> ids) {
Example example = createExample();
example.createCriteria().andIn("id", ids);
mapper.deleteByExample(example);
//还需删除与自定义分类关系
example = new Example(ArticleLibraryDiyType.class);
example.createCriteria().andIn("alId", ids);
adrMapper.deleteByExample(example);
//这里需要级联删除其他接口关联资源
//----推荐位内容
recommendResourceMapper.delectByResourceIds(ids, AllResourceTypeEnum.ARTICLE.getCode());
//----关联资源
example = new Example(ResourceRelation.class);
example.createCriteria().andIn("objectId", ids).orIn("resourceId", ids);
resourceRelationMapper.deleteByExample(example);
return true;
}
@Override
public PageInfo<ArticleLibraryListVO> page(QueryArticleLibraryForm form, PageParam pageParam) {
startPage(pageParam);
pageParam.setOrderBy(" a.uploadTime desc ");
List<ArticleLibraryListVO> list = mapper.query(form);
return new PageInfo<ArticleLibraryListVO>(list);
}
@Override
public PageInfo<ArticleLibraryListVO> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
if(pageParam != null && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("uploadTime desc,id desc");
}
startPage(pageParam);
List<ArticleLibraryListVO> list = mapper.queryByTileAndDiyType(form);
if(!list.isEmpty()){
for(ArticleLibraryListVO ebookListVO : list){
ebookListVO.setStatus_zh(LibraryStatusEnum.getName(ebookListVO.getStatus()));
}
}
return new PageInfo<ArticleLibraryListVO>(list);
}
}
package com.zrqx.resource.bg.service.articlelibrary;
import java.util.List;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.form.resource.bg.articlelibrary.QueryArticleLibraryForm;
import com.zrqx.core.form.resource.bg.articlelibrary.SaveUpdateArticleLibraryForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.service.BaseService;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
/**
* 文章库
*/
public interface ArticleLibraryService extends BaseService<ArticleLibrary,String>{
boolean saveOrUpdate(SaveUpdateArticleLibraryForm form);
boolean batchDelete(List<String> ids);
PageInfo<ArticleLibraryListVO> page(QueryArticleLibraryForm form, PageParam pageParam);
PageInfo<ArticleLibraryListVO> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam);
}
package com.zrqx.resource.bg.service.articlelibrary;
import java.util.List;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleResource;
import com.zrqx.core.service.BaseService;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.resource.ResourceRelationVo;
public interface ArticleResourceService extends BaseService<ArticleResource, Integer> {
/**
* 获取相关资源列表
* @param entity
* @param pageParam
* @return
* @author yzg
* @date: 2018年7月24日 上午9:09:34
*/
List<ResourceRelationVo> queryByIdAndResourceType(QueryResourceRelationForm entity, PageParam pageParam);
/**
* 获取关联资源最大排序
* @return
*/
Integer getMaxSort();
}
package com.zrqx.resource.bg.service.articlelibrary;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleResource;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.resource.ResourceRelationVo;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleResourceMapper;
@Service
public class ArticleResourceServiceImpl extends BaseServiceImpl<ArticleResource, Integer> implements ArticleResourceService{
@Autowired
private ArticleResourceMapper articleResourceMapper;
@Override
public BaseMapper<ArticleResource> getMapper() {
return articleResourceMapper;
}
/**
* 获取相关资源列表
* @see com.zrqx.resource.bg.service.articlelibrary.ArticleResourceService#queryByIdAndResourceType(com.zrqx.core.form.resource.bg.QueryResourceRelationForm, com.zrqx.core.util.page.PageParam)
* @param entity
* @param pageParam
* @return
* @author yzg
* @date: 2018年7月24日 上午9:10:11
*/
@Override
public List<ResourceRelationVo> queryByIdAndResourceType(QueryResourceRelationForm entity, PageParam pageParam) {
PageHelper.startPage(pageParam);
return articleResourceMapper.queryByIdAndResourceType(entity);
}
/**
* 获取关联资源最大排序
*/
@Override
public Integer getMaxSort() {
Integer sort = articleResourceMapper.getMaxSort();
if(sort == null){
sort = 1;
}else{
sort += 1;
}
return sort;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论