提交 785a8937 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 0ebeebd6
......@@ -2,77 +2,35 @@ package com.zrqx.resource.bg.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.form.resource.bg.imagelibrary.QueryImageRelationLibraryForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
import com.zrqx.core.vo.resource.ResourceRelationVo;
import com.zrqx.core.vo.resource.imagelibrary.ImageLibraryListVO;
@Mapper
public interface ResourceRelationMapper extends BaseMapper<ResourceRelation> {
@Select("<script>"
+ "select id ,resourceId,resourceType,uploadTime,sort "
+ "from res_resource_relation "
+ "where objectId = #{id} "
+ "<if test='resourceType != null'> "
+ " and resourceType = #{resourceType} "
+ "</if>"
+ " order by sort "
+ "</script>")
List<ResourceRelationVo> queryByIdAndResourceType(QueryResourceRelationForm entity);
@Select("<script>"
+ "select a.id ,b.name,resourceId,a.goodsType,author,a.resourceType,DATE_FORMAT(a.uploadTime,'%Y-%m-%d %H:%i:%s') uploadTime,sort "
+ "from res_resource_relation a inner join res_article_library b on b.id = a.resourceId "
+ " where objectId = #{id} "
+ "<if test='goodsType != null'> "
+ " and goodsType = #{goodsType} "
+ "</if>"
+ "</script>")
List<ResourceRelationVo> queryByIdAndGoodsType(QueryResourceRelationForm entity);
@Select("<script>"
+ "select id ,resourceId,resourceType,DATE_FORMAT(uploadTime,'%Y-%m-%d %H:%i:%s') uploadTime,sort "
+ "from res_resource_relation "
+ "where objectId = #{id} "
+ "<if test='resourceType != null'> "
+ " and resourceType = #{resourceType} "
+ "</if>"
+ "</script>")
List<ResourceRelationVo> FgqueryByIdAndResourceType(QueryResourceRelationForm entity);
/**
* 根据类型和资源id集合删除关联内容
* @param ids
* @param type
* @author ycw
* @date: 2019年8月6日 上午10:34:15
*/
@Delete("<script>"
+ "delete from res_resource_relation "
+ "where 1 = 1 "
+ "<if test='type != null' >"
+ "and resourceType = #{type} "
@Select("<script>"
+ "select distinct a.id,a.name,a.source,a.sort,a.image,DATE_FORMAT(a.uploadTime,'%Y-%m-%d') uploadTime,a.status "
+ "from res_resource_relation a left join res_Diy_Type_Relation ad "
+ " on a.id = ad.resId "
+ "where 1=1 "
+ "<if test = '" + NOTBLANK + "(form.name)'>"
+ " and a.name like concat('%',#{form.name},'%') "
+ "</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 ( objectId 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);
+ "<if test='form.status != null'>"
+ "and a.status = #{form.status}"
+ "</if>"
+ "<if test='form.dtId != null'>"
+ "and ad.dtId = #{form.dtId}"
+ "</if>"
+ " order by a.sort,a.uploadTime desc"
+ "</script>")
List<ImageLibraryListVO> query(@Param("form")QueryImageRelationLibraryForm form);
/**
* 获取关联资源排序
* @return
......@@ -80,10 +38,4 @@ public interface ResourceRelationMapper extends BaseMapper<ResourceRelation> {
@Select("SELECT MAX(sort) FROM res_resource_relation ")
Integer getMaxSort();
/**
* 获取关联资源排序
* @return
*/
@Select("SELECT MAX(sort) FROM res_resource_relation where objectid = #{id} ")
Integer getMaxSortH(@Param("id") String id);
}
package com.zrqx.resource.bg.mapper.diytype;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.diytype.DiyTypeRelation;
/**
* 文章库和自定义分类
*/
public interface DiyTypeRelationMapper extends BaseMapper<DiyTypeRelation> {
}
\ No newline at end of file
......@@ -2,52 +2,20 @@ package com.zrqx.resource.bg.service;
import java.util.List;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.form.resource.bg.imagelibrary.QueryImageLibraryForm;
import com.zrqx.core.form.resource.bg.imagelibrary.QueryImageRelationLibraryForm;
import com.zrqx.core.form.resource.bg.imagelibrary.SaveImageLibraryForm;
import com.zrqx.core.form.resource.bg.imagelibrary.SaveUpdateImageLibraryForm;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
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.ResourceRelationVo;
import com.zrqx.core.vo.resource.imagelibrary.ImageLibraryListVO;
public interface ResourceRelationService extends BaseService<ResourceRelation, String> {
List<ResourceRelationVo> queryRelationList(List<ResourceRelationVo> list);
List<ResourceRelationVo> queryfgRelationList(List<ResourceRelationVo> list);
/**
* 获取相关资源列表
* @param entity
* @param pageParam
* @return
*/
List<ResourceRelationVo> queryByIdAndResourceType(QueryResourceRelationForm entity, PageParam pageParam);
/**
* 获取相关资源列表
* @param entity
* @param pageParam
* @return
*/
List<ResourceRelationVo> queryByIdAndGoodsType(QueryResourceRelationForm entity, PageParam pageParam);
/**
* 前台获取相关资源
* @param entity
* @return
* @author rjc
* @date: 2019年9月20日 下午5:46:24
*/
public List<ResourceRelationVo> FgqueryByIdAndResourceType(QueryResourceRelationForm entity);
/**
* 获取排序
* @param resourceType
* @return
*/
Integer getMaxSort();
/**
* 获取排序
* @param resourceType
* @return
*/
Integer getMaxSort(String id);
boolean saveOrUpdate(SaveUpdateImageLibraryForm form);
boolean save(SaveImageLibraryForm form);
boolean batchDelete(List<String> ids);
PageInfo<ImageLibraryListVO> page(QueryImageRelationLibraryForm form, PageParam pageParam);
public Integer getMaxSort();
}
package com.zrqx.resource.bg.service;
import java.util.ArrayList;
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.github.pagehelper.PageHelper;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.imagelibrary.QueryImageLibraryForm;
import com.zrqx.core.form.resource.bg.imagelibrary.QueryImageRelationLibraryForm;
import com.zrqx.core.form.resource.bg.imagelibrary.SaveImageLibraryForm;
import com.zrqx.core.form.resource.bg.imagelibrary.SaveUpdateImageLibraryForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.audiolibrary.AudioLibrary;
import com.zrqx.core.model.resource.ebook.Book;
import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
import com.zrqx.core.model.resource.diytype.DiyTypeRelation;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
import com.zrqx.core.model.resource.videolibrary.VideoLibrary;
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.ResourceRelationVo;
import com.zrqx.core.vo.resource.imagelibrary.ImageLibraryListVO;
import com.zrqx.resource.bg.mapper.ResourceRelationMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryMapper;
import com.zrqx.resource.bg.mapper.audiolibrary.AudioLibraryMapper;
import com.zrqx.resource.bg.mapper.ebook.BookMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
import com.zrqx.resource.bg.mapper.videolibrary.VideoLibraryMapper;
import com.zrqx.resource.bg.mapper.diytype.DiyTypeRelationMapper;
import tk.mybatis.mapper.entity.Example;
@Service
public class ResourceRelationServiceImpl extends BaseServiceImpl<ResourceRelation,String> implements ResourceRelationService {
@Autowired
private ResourceRelationMapper mapper;
@Autowired
private ArticleLibraryMapper articleLibraryMapper;
@Autowired
private BookMapper bookMapper;
@Autowired
private PdfLibraryMapper pdfLibraryMapper;
@Autowired
private AudioLibraryMapper audioLibraryMapper;
@Autowired
private VideoLibraryMapper videoLibraryMapper;
private DiyTypeRelationMapper dtMapper;
@Override
public BaseMapper<ResourceRelation> getMapper() {
return mapper;
}
public List<ResourceRelationVo> queryRelationList(List<ResourceRelationVo> list) {
list.forEach(e -> {
e.setUploadTime(e.getUploadTime().substring(0, e.getUploadTime().length()-2));
if (e.getResourceType() != null) {
if (e.getResourceType().equals(AllResourceTypeEnum.BOOK.getCode())) {
Book il = bookMapper.selectByPrimaryKey(e.getResourceId());
if (il != null) {
e.setName(il.getName());
e.setAuthor(il.getAuthor());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.ARTICLE.getCode())) {
ArticleLibrary cl = articleLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (cl != null) {
e.setName(cl.getName());
e.setAuthor(cl.getAuthor());
e.setCover(cl.getImg());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.PDF.getCode())) {
PdfLibrary cl = pdfLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (cl != null) {
e.setName(cl.getName());
e.setAuthor(cl.getAuthor());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.VIDEO.getCode())) {
VideoLibrary vl = videoLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (vl != null) {
e.setName(vl.getName());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.AUDIO.getCode())) {
AudioLibrary al = audioLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (al != null) {
e.setName(al.getName());
}
}
}
});
return list;
}
public List<ResourceRelationVo> queryfgRelationList(List<ResourceRelationVo> list) {
List<ResourceRelationVo> mylist =new ArrayList<ResourceRelationVo>();
list.forEach(e -> {
e.setUploadTime(e.getUploadTime().substring(0, e.getUploadTime().length()-2));
if (e.getResourceType() != null) {
if (e.getResourceType().equals(AllResourceTypeEnum.BOOK.getCode())) {
Book il = bookMapper.selectByPrimaryKey(e.getResourceId());
if (il != null && il.getStatus()==1) {
e.setName(il.getName());
e.setAuthor(il.getAuthor());
mylist.add(e);
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.ARTICLE.getCode())) {
ArticleLibrary cl = articleLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (cl != null && cl.getStatus()==1) {
e.setName(cl.getName());
e.setAuthor(cl.getAuthor());
e.setCover(cl.getImg());
mylist.add(e);
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.PDF.getCode())) {
PdfLibrary cl = pdfLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (cl != null && cl.getStatus()==1) {
e.setName(cl.getName());
e.setAuthor(cl.getAuthor());
mylist.add(e);
}
}
}
});
return mylist;
}
/**
* 获取相关资源列表
* 单个图片插入
* @param form
* @return
* @date: 2018年12月13日 上午11:09:37
*/
@Override
public List<ResourceRelationVo> queryByIdAndResourceType(QueryResourceRelationForm entity, PageParam pageParam) {
if(null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("sort desc");
public boolean saveOrUpdate(SaveUpdateImageLibraryForm form) {
ResourceRelation entity = new ResourceRelation();
BeanUtils.copyProperties(form, entity);
if(entity.getId() == null){
//添加
entity.setUploadTime(new Date());
mapper.insert(entity);
}else{
//修改
mapper.updateByPrimaryKeySelective(entity);
//删除当前对象与自定义分类的关系
DiyTypeRelation old = new DiyTypeRelation();
old.setResId(entity.getId());
dtMapper.delete(old);
}
//添加当前对象与自定义分类的关系
if(form.getDiyType() != null && form.getDiyType().size() > 0){
List<DiyTypeRelation> list = form.getDiyType();
list.forEach(li -> li.setResId(entity.getId()));
dtMapper.insertUuidList(list);
}
PageHelper.startPage(pageParam);
return mapper.queryByIdAndResourceType(entity);
return true;
}
/**
* 获取相关资源文章列表
* 批量图片插入
* @param form
* @return
* @date: 2018年12月13日 上午11:09:37
*/
@Override
public List<ResourceRelationVo> queryByIdAndGoodsType(QueryResourceRelationForm entity, PageParam pageParam) {
if(null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("sort desc,uploadTime desc");
public boolean save(SaveImageLibraryForm form){
if(form.getNames().size() != form.getImages().size()){
throw new ParameterValidateException("图片数量错误");
}
//循环创建图片对象
for (int i = 0; i < form.getNames().size(); i++) {
ResourceRelation obj = new ResourceRelation();
BeanUtils.copyProperties(form, obj);
obj.setName(form.getNames().get(i));
obj.setImage(form.getImages().get(i));
obj.setSize(form.getSize().get(i));
obj.setFormats(form.getFormats().get(i));
obj.setUploadTime(new Date());
obj.setSort(this.getMaxSort());
mapper.insert(obj);
//添加当前对象与自定义分类的关系
if(form.getDiyType() != null && form.getDiyType().size() > 0){
List<DiyTypeRelation> list = form.getDiyType();
list.forEach(li -> li.setResId(obj.getId()));
dtMapper.insertUuidList(list);
}
}
PageHelper.startPage(pageParam);
List<ResourceRelationVo> list = mapper.queryByIdAndGoodsType(entity);
return list;
return true;
}
/**
* 获取相关资源列表
*/
@Override
public List<ResourceRelationVo> FgqueryByIdAndResourceType(QueryResourceRelationForm entity) {
return mapper.queryByIdAndResourceType(entity);
public boolean batchDelete(List<String> ids) {
Example example = createExample();
example.createCriteria().andIn("id", ids);
mapper.deleteByExample(example);
return true;
}
@Override
public Integer getMaxSort() {
Integer sort = mapper.getMaxSort();
if(sort == null){
sort = 1;
}else{
sort += 1;
}
return sort;
public PageInfo<ImageLibraryListVO> page(QueryImageRelationLibraryForm form, PageParam pageParam) {
startPage(pageParam);
//暂不用自定义分类id 做in查询
List<ImageLibraryListVO> list = mapper.query(form);
return new PageInfo<ImageLibraryListVO>(list);
}
/**
* 查询最大排序
*/
@Override
public Integer getMaxSort(String id) {
Integer sort = mapper.getMaxSortH(id);
public Integer getMaxSort() {
Integer sort = mapper.getMaxSort();
if(sort == null){
sort = 1;
}else{
......
package com.zrqx.resource.bg.service.diytype;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.diytype.DiyTypeRelation;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.resource.bg.mapper.diytype.DiyTypeRelationMapper;
/**
* 文章库和自定义分类
*/
@Service
public class DiyTypeRelationSerivceImpl extends BaseServiceImpl<DiyTypeRelation,String> implements DiyTypeRelationService {
@Autowired
private DiyTypeRelationMapper mapper;
@Override
public BaseMapper<DiyTypeRelation> getMapper() {
return mapper;
}
}
package com.zrqx.resource.bg.service.diytype;
import com.zrqx.core.model.resource.diytype.DiyTypeRelation;
import com.zrqx.core.service.BaseService;
/**
* 文章库和自定义分类
*/
public interface DiyTypeRelationService extends BaseService<DiyTypeRelation,String>{
}
......@@ -108,8 +108,6 @@ public class FgEbookController {
recordService.saveOrUpdateRecord(entity.getId(), AllResourceTypeEnum.BOOK.getCode().toString());
// 更新浏览量
bookservice.updateBrowseNum(entity.getId());
List<ResourceRelationVo> list = resourceRelationService.FgqueryByIdAndResourceType(entity);
vo.setListArticle(resourceRelationService.queryfgRelationList(list));
return CallBack.success(vo);
}
public List<ChapterLibrary> tree(List<ChapterLibrary> list,List<ChapterLibrary> voList){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论