提交 3990f972 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 eff26667
......@@ -258,31 +258,6 @@ public class ArticleLibraryController {
return CallBack.success(new PageInfo<ResourceRelationVo>(resourceRelationService.queryRelationList(list)));
}
@ApiOperation(value = "选择弹窗中的列表", notes = "查询选择弹窗中的列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.POPPAGE)
public CallBack<PageInfo<ArticleLibraryListVO>> page(QueryResourceForPoPForm form, PageParam pageParam) {
return CallBack.success(service.pageByTitleAndDiyType(form, pageParam));
}
@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<ArticleResource> recordList = new ArrayList<ArticleResource>();
Arrays.asList(entity.getResourceIds()).forEach(resourceId -> {
ArticleResource e = new ArticleResource();
e.setArticleId(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) {
......
......@@ -13,7 +13,6 @@ import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.form.resource.bg.ebook.QueryEbookMainBodyForm;
import com.zrqx.core.form.resource.bg.ebook.SaveUpdateEbookMainBodyForm;
import com.zrqx.core.form.resource.bg.ebook.UpdateEbookMainBodyForm;
import com.zrqx.core.model.resource.ebook.Book;
import com.zrqx.core.model.resource.ebook.EbookMainBody;
import com.zrqx.core.util.bean.BeanUtils;
import com.zrqx.core.util.page.PageInfo;
......
......@@ -24,21 +24,22 @@ import com.zrqx.core.enums.SaleResourceTypeEnum;
import com.zrqx.core.exception.BaseException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.ClassifyRelationForm;
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.ebook.UpdateEbookRelationForm;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.model.resource.imagelibrary.ImageLibraryDiyType;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
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.ResourceRelationListVo;
import com.zrqx.core.vo.resource.ResourceRelationVo;
import com.zrqx.resource.bg.service.ResourceRelationService;
import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryDiyTypeService;
import com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryService;
import com.zrqx.resource.bg.service.imagelibrary.ImageLibraryDiyTypeService;
import com.zrqx.resource.bg.service.imagelibrary.ImageLibraryService;
import com.zrqx.resource.bg.service.ebook.BookService;
import com.zrqx.resource.bg.service.pdffilelibrary.PdfLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -51,20 +52,16 @@ import tk.mybatis.mapper.entity.Example;
@Api(description = "资源的公共接口")
public class ResourceLibraryController {
private static final Logger log = Logger.getLogger(ResourceLibraryController.class);
@Autowired
private ImageLibraryService imageLibraryService;
@Autowired
private ArticleLibraryService articleLibraryService;
@Autowired
private ArticleLibraryDiyTypeService articleLibraryDiyTypeService;
@Autowired
private ImageLibraryDiyTypeService imageDiyTypeService;
private PdfLibraryService pdfLibraryService;
@Autowired
private ResourceRelationService resourceRelationService;
@Autowired
private BookService bookservice;
//关联资源begin
......@@ -79,7 +76,7 @@ public class ResourceLibraryController {
ResourceRelation e = new ResourceRelation();
e.setObjectId(entity.getId());
e.setResourceId(resourceId);
e.setCreateTime(new Date());
e.setUploadTime(new Date());
e.setResourceType(entity.getResourceType());
recordList.add(e);
});
......@@ -103,24 +100,37 @@ public class ResourceLibraryController {
if (form.getId().isEmpty()) {
throw new ParameterValidateException("id不能为空");
}
List<Integer> ids = form.getId();
List<String> ids = form.getId();
Example example = new Example(ResourceRelation.class);
example.createCriteria().andIn("id", ids);
return CallBack.success(resourceRelationService.deleteByExample(example));
}
@ApiOperation(value = "关联资源修改排序号", notes = "修改排序号")
@PostMapping(value = ResourceRequestPath.UPDATE + ResourceRequestPath.SORT)
public CallBack<Boolean> updateSort(@RequestBody UpdateEbookRelationForm form) {
if (form.getId().isEmpty()) {
throw new ParameterValidateException("id不能为空");
}
List<Integer> ids = form.getId();
List<String> ids = form.getId();
Example example = new Example(ResourceRelation.class);
example.createCriteria().andIn("id", ids);
ResourceRelation resourceRelation = new ResourceRelation();
resourceRelation.setSort(form.getSort());
return CallBack.success(resourceRelationService.UpdateByExampleSelective(resourceRelation, example));
}
@ApiOperation(value = "选择弹窗中的列表", notes = "查询选择弹窗中的列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.POPPAGE)
public CallBack<PageInfo<ResourceRelationListVo>> page(QueryResourceForPoPForm form, PageParam pageParam) {
if (form.getResourceType().equals(1)) {
return CallBack.success(bookservice.pageByTitleAndDiyType(form, pageParam));
}else if(form.getResourceType().equals(2)){
return CallBack.success(articleLibraryService.pageByTitleAndDiyType(form, pageParam));
}else if (form.getResourceType().equals(15)) {
return CallBack.success(pdfLibraryService.pageByTitleAndDiyType(form, pageParam));
}
return CallBack.success();
}
@ApiOperation(value = "获取资源最大排序号", notes = "获取资源最大排序号")
@GetMapping(value = ResourceRequestPath.GET + ResourceRequestPath.SORT)
......@@ -128,8 +138,6 @@ public class ResourceLibraryController {
return CallBack.success(resourceRelationService.getMaxSort(resourceType));
}
@ApiOperation(value = "资源类型列表" , notes ="资源类型")
@GetMapping(value = ResourceRequestPath.TYPE + ResourceRequestPath.LIST)
public CallBack<Map<String,String>> queryResourceTypeList(){
......@@ -179,26 +187,6 @@ public class ResourceLibraryController {
throw new BaseException(ResponseCodeEnum.FAIL);
}
}
// 图片
if(form.getObjectType().equals(AllResourceTypeEnum.IMAGE.getCode())){
List<ImageLibraryDiyType> list = new ArrayList<ImageLibraryDiyType>();
form.getIds().forEach(objectId -> {
//刪除原有的分类
ImageLibraryDiyType ob = new ImageLibraryDiyType();
ob.setIlId(objectId);
imageDiyTypeService.delete(ob);
for (int i = 0; i < form.getDiyTypeId().size(); i++) {
ImageLibraryDiyType obj = new ImageLibraryDiyType();
obj.setIlId(objectId);
obj.setDtId(Integer.parseInt(form.getDiyTypeId().get(i)));
obj.setCode(form.getDiyTypeCode().get(i));
list.add(obj);
}
});
if (!imageDiyTypeService.insertList(list)) {
throw new BaseException(ResponseCodeEnum.FAIL);
}
}
return CallBack.success();
}
......
......@@ -9,6 +9,7 @@ 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.ResourceRelationListVo;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
/**
* 文章库
......@@ -58,30 +59,17 @@ public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
+ "</script>")
List<ArticleLibraryListVO> query(@Param("form")QueryArticleLibraryForm form);
@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.img,a.nationsType,a.resourceType "
+ "from res_Article_Library a left join res_Article_Library_Diy_Type ad "
+ "on a.id = ad.alid "
+ "select a.id,a.name,a.resourceType,a.author,DATE_FORMAT(a.uploadTime,'%Y-%m-%d') uploadTime,a.status,"
+ "from res_Article_Library a "
+ "where 1=1 and a.status = 1 "
+ "<if test='form.nationsType != null' >"
+ "and a.nationsType = #{form.nationsType} "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.diyTypeCode)'>"
+ "and ad.code like concat(#{form.diyTypeCode},'%') "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.title)'>"
+ "and a.name like concat('%',#{form.title},'%') "
+ "<if test = '" + NOTBLANK + "(form.name)'>"
+ "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);
List<ResourceRelationListVo> queryByTileAndDiyType(@Param("form")QueryResourceForPoPForm entity);
}
package com.zrqx.resource.bg.mapper.ebook;
import java.util.List;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.ebook.Book;
import com.zrqx.core.vo.resource.ResourceRelationListVo;
public interface BookMapper extends BaseMapper<Book> {
@Select("<script>"
+ "SELECT bb.id,bb.name,bb.executiveEditor as author,bb.status,"
+ " DATE_FORMAT(bb.uploadTime,'%Y-%m-%d %H:%i:%s') uploadTime,bb.resourceType"
+ " FROM res_book bb where 1=1 and bb.status=1"
+ " <if test='form.name != null and form.name != \"\"'>"
+ " and bb.name like concat('%',#{form.name},'%') "
+ " </if>"
+ " <if test='form.resourceType != null and form.resourceType != \"\"'>"
+ " and bb.resourceType like concat('%',#{form.resourceType},'%') "
+ " </if>"
+ "</script>")
List<ResourceRelationListVo> queryByTileAndDiyType(QueryResourceForPoPForm form);
}
......@@ -28,67 +28,19 @@ public interface EbookMapper extends BaseMapper<Ebook>{
*/
@Select("<script>"
+ "SELECT "
+ " DISTINCT bb.id,bb.name,bb.author,bb.isbn,"
+ " be.realprice,DATE_FORMAT(be.uploadTime,'%Y-%m-%d')uploadTime,DATE_FORMAT(be.updateTime,'%Y-%m-%d')updateTime,be.bookStatus "
+ " DISTINCT bb.id,bb.name,bb.executiveEditor,bb.JournalCode,bb.year,bb.periods,bb.status,"
+ " bb.download,DATE_FORMAT(bb.uploadTime,'%Y-%m-%d')uploadTime,DATE_FORMAT(be.releaseTime,'%Y-%m-%d')releaseTime"
+ " FROM res_book bb "
+ " LEFT JOIN res_ebook be ON bb.id = be.id "
+ " LEFT JOIN res_ebook_diy_type bdt ON be.id = bdt.ebookid"
+ " WHERE 1 = 1 "
+ "<if test='option==1'>"
+ " AND bb.author is null "
+ "</if>"
+ "<if test='option==2'>"
+ " AND be.bookCover is null "
+ "</if>"
+ "<if test='option==3'>"
+ " AND be.summary is null "
+ "</if>"
+ "<if test='option==4'>"
+ " AND be.realPrice is null "
+ "</if>"
+ "<if test='bookStatus!=null'>"
+ " AND be.bookStatus = #{bookStatus} "
+ "</if>"
+ "<if test='bookStatus==null'>"
+ " AND be.bookStatus != 6 "
+ "</if>"
+ "<if test='type!=null'>"
+ " AND bb.type = #{type} "
+ "</if>"
+ "<if test='status!=null'>"
+ " AND bb.status = #{status} "
+ "</if>"
+ "<if test='"+ NOTBLANK +"(diyTypeCode)' >"
+ "and bdt.code like concat(#{diyTypeCode},'%') "
+ "</if>"
/* + "<if test='diyTypeId != null and diyTypeId.size > 0'>"
+ "and bdt.diytypeid in "
+ " <foreach collection=\"diyTypeId\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\")\">"
+ "#{id}"
+ "</foreach>"
+ "</if>" */
+ "<if test='nationsType != null ' >"
+ "and bb.nationsType = #{nationsType} "
+ "<if test='mainBody != null ' >"
+ "and bb.mainBody = #{mainBody} "
+ "</if>"
+ "<if test='"+ NOTBLANK +"(nai)'>"
+ " AND (bb.name like concat('%',#{nai},'%') OR bb.author like concat('%',#{nai},'%') OR bb.isbn like concat('%',#{nai},'%')) "
+ "</if>"
+ "<if test='"+ NOTBLANK +"(name)'>"
+ " AND bb.name like concat('%',#{name},'%')"
+ "</if>"
+ "<if test='"+ NOTBLANK +"(author)'>"
+ " AND bb.author like concat('%',#{author},'%')"
+ "</if>"
+ "<if test='"+ NOTBLANK +"(isbn)'>"
+ " AND bb.isbn like concat('%',#{isbn},'%')"
+ "</if>"
+ "<if test='"+ NOTBLANK +"(beginTime)'>"
+ " AND be.uploadTime &gt;= concat(#{beginTime}, ' 00:00:00')"
+ "</if>"
+ "<if test='beginTime!=null and endTime!=null'>"
+ " AND be.uploadTime &lt;= concat(#{endTime}, ' 23:59:59')"
+ " AND (bb.name like concat('%',#{nai},'%') OR bb.executiveEditor like concat('%',#{nai},'%') OR bb.JournalCode like concat('%',#{nai},'%')) "
+ "</if>"
+ " order by be.uploadTime desc "
+ " order by bb.uploadTime desc "
+ "</script>")
List<EbookListVO> page(QueryEbookInfoForm form);
@Select("<script>"
......
......@@ -5,9 +5,11 @@ 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.pdffilelibrary.QueryPdfLibraryForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
import com.zrqx.core.vo.resource.ResourceRelationListVo;
import com.zrqx.core.vo.resource.pdffilelibrary.PdfLibraryListVO;
/**
* PDF
......@@ -51,4 +53,15 @@ public interface PdfLibraryMapper extends BaseMapper<PdfLibrary> {
+ " order by a.uploadTime desc "
+ "</script>")
List<PdfLibraryListVO> query(@Param("form")QueryPdfLibraryForm form);
@Select("<script>"
+ "select a.id,a.name,a.author,a.resourceType,DATE_FORMAT(a.uploadTime,'%Y-%m-%d %H:%i:%s') uploadTime,a.status "
+ "from res_Pdf_Library a where 1=1 "
+ "<if test='form.name != null and form.name != \"\"'>"
+ "and a.name like concat('%',#{form.name},'%') "
+ "</if>"
+ " <if test='form.resourceType != null and form.resourceType != \"\"'>"
+ " and a.resourceType != #{form.resourceType}"
+ " </if>"
+ "</script>")
List<ResourceRelationListVo> queryByTileAndDiyType(QueryResourceForPoPForm form);
}
......@@ -12,6 +12,7 @@ import com.zrqx.core.form.resource.bg.QueryResourceRelationForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.imagelibrary.ImageLibrary;
import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageParam;
......@@ -19,6 +20,7 @@ import com.zrqx.core.vo.resource.ResourceRelationVo;
import com.zrqx.resource.bg.mapper.ResourceRelationMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryMapper;
import com.zrqx.resource.bg.mapper.imagelibrary.ImageLibraryMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
@Service
public class ResourceRelationServiceImpl extends BaseServiceImpl<ResourceRelation,Integer> implements ResourceRelationService {
......@@ -28,6 +30,8 @@ public class ResourceRelationServiceImpl extends BaseServiceImpl<ResourceRelatio
private ArticleLibraryMapper articleLibraryMapper;
@Autowired
private ImageLibraryMapper imageLibraryMapper;
@Autowired
private PdfLibraryMapper pdfLibraryMapper;
@Override
public BaseMapper<ResourceRelation> getMapper() {
......@@ -37,18 +41,22 @@ public class ResourceRelationServiceImpl extends BaseServiceImpl<ResourceRelatio
public List<ResourceRelationVo> queryRelationList(List<ResourceRelationVo> list) {
list.forEach(e -> {
if (e.getResourceType() != null) {
if (e.getResourceType().equals(AllResourceTypeEnum.IMAGE.getCode())) {
if (e.getResourceType().equals(AllResourceTypeEnum.BOOK.getCode())) {
ImageLibrary il = imageLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (il != null) {
e.setName(il.getName());
e.setResType_zh(AllResourceTypeEnum.IMAGE.getName());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.ARTICLE.getCode())) {
ArticleLibrary cl = articleLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (cl != null) {
e.setName(cl.getName());
e.setResType_zh(AllResourceTypeEnum.ARTICLE.getName());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.PDF.getCode())) {
PdfLibrary cl = pdfLibraryMapper.selectByPrimaryKey(e.getResourceId());
if (cl != null) {
e.setName(cl.getName());
}
}
}
......
......@@ -24,6 +24,7 @@ import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
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.ResourceRelationListVo;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
import com.zrqx.resource.bg.mapper.ResourceRelationMapper;
import com.zrqx.resource.bg.mapper.articlelibrary.ArticleLibraryDiyTypeMapper;
......@@ -124,15 +125,10 @@ public class ArticleLibrarySerivceImpl extends BaseServiceImpl<ArticleLibrary,St
return new PageInfo<ArticleLibraryListVO>(list);
}
@Override
public PageInfo<ArticleLibraryListVO> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
public PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
startPage(pageParam);
List<ArticleLibraryListVO> list = mapper.queryByTileAndDiyType(form);
if(!list.isEmpty()){
for(ArticleLibraryListVO ebookListVO : list){
ebookListVO.setStatus_zh(LibraryStatusEnum.getName(Integer.parseInt(ebookListVO.getStatus())));
}
}
return new PageInfo<ArticleLibraryListVO>(list);
List<ResourceRelationListVo> list = mapper.queryByTileAndDiyType(form);
return new PageInfo<ResourceRelationListVo>(list);
}
}
......@@ -9,6 +9,7 @@ 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.ResourceRelationListVo;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
/**
* 文章库
......@@ -17,5 +18,13 @@ 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);
/**
* 关联资源弹窗
* @param form
* @param pageParam
* @return
* @author rjc
* @date: 2019年9月11日 上午10:17:59
*/
PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam);
}
package com.zrqx.resource.bg.service.ebook;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.model.resource.ebook.Book;
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.ResourceRelationListVo;
/**
* 商品-service
......@@ -9,4 +13,6 @@ import com.zrqx.core.service.BaseService;
* @date 2018年7月13日上午10:05:18
*/
public interface BookService extends BaseService<Book, String> {
PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam);
}
package com.zrqx.resource.bg.service.ebook;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.ebook.Book;
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.ResourceRelationListVo;
import com.zrqx.resource.bg.mapper.ebook.BookMapper;
/**
......@@ -28,4 +34,13 @@ public class BookServiceImpl extends BaseServiceImpl<Book, String> implements
return bookMapper;
}
@Override
public PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
pageParam.setOrderBy("uploadTime desc ");
startPage(pageParam);
List<ResourceRelationListVo> list = bookMapper.queryByTileAndDiyType(form);
return new PageInfo<ResourceRelationListVo>(list);
}
}
package com.zrqx.resource.bg.service.ebook;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -29,11 +27,6 @@ public class EbookDiyTypeSerivceImpl extends BaseServiceImpl<EbookDiyType,Intege
Example example = createExample();
example.createCriteria().andIn("ebookId", form.getIds());
mapper.deleteByExample(example);
for (String id : form.getIds()) {
List<EbookDiyType> dtList = form.getDiyType();
dtList.forEach(li -> li.setEbookId(id));
mapper.insertList(dtList);
}
}
......
......@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.enums.GoodsTypeEnum;
import com.zrqx.core.enums.resource.EbookStatusEnum;
import com.zrqx.core.enums.resource.PriceOptionEnum;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
......@@ -22,6 +21,7 @@ import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.ebook.Book;
import com.zrqx.core.model.resource.ebook.Ebook;
import com.zrqx.core.model.resource.ebook.EbookDiyType;
import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
......@@ -29,6 +29,7 @@ import com.zrqx.core.vo.resource.ebook.EbookListVO;
import com.zrqx.resource.bg.mapper.ebook.BookMapper;
import com.zrqx.resource.bg.mapper.ebook.EbookDiyTypeMapper;
import com.zrqx.resource.bg.mapper.ebook.EbookMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
/**
* 电子书-serviceimpl
......@@ -44,65 +45,53 @@ public class EbookServiceImpl extends BaseServiceImpl<Ebook, String> implements
@Autowired
private EbookMapper ebookMapper;
@Autowired
private EbookDiyTypeMapper ebookDiyTypeMapper;
private PdfLibraryMapper pdfLibraryMapper;
@Override
public BaseMapper<Ebook> getMapper() {
return ebookMapper;
}
@Override
public boolean saveOrUpdate(SaveUpdateEbookForm form) {
Book book = new Book();
Ebook ebook = new Ebook();
if(StringUtils.isNotBlank(form.getAuthorNameAndId())){
String[] authorNameAndId = form.getAuthorNameAndId().split(",");
form.setAuthor(authorNameAndId[0]);
if(authorNameAndId.length > 1){
form.setAuthorId(authorNameAndId[1]);
}
}
if(StringUtils.isNotBlank(form.getTranslatorNameAndId())){
String[] translatorNameAndId = form.getTranslatorNameAndId().split(",");
form.setAuthor(translatorNameAndId[0]);
if(translatorNameAndId.length > 1){
form.setAuthorId(translatorNameAndId[1]);
}
}
BeanUtils.copyProperties(form, book);
BeanUtils.copyProperties(form, ebook);
if(PriceOptionEnum.STATUS_0.getCode().equals(ebook.getPriceOption())){
ebook.setRealPrice(new BigDecimal(0));
}
if (book.getId() == null) {
book.setUploadTime(new Date());
book.setResourceType(AllResourceTypeEnum.BOOK.getCode());
book.setSalesNum(0);
if(form.getPdfResourceType()!=null ){
if(form.getPdfResourceType().equals(1)){
PdfLibrary pdf=new PdfLibrary();
pdf.setPdf(form.getPdf());
pdf.setName(form.getPdfName());
pdf.setUploadTime(new Date());
pdf.setStatus(0);
pdfLibraryMapper.insert(pdf);
book.setPdf(pdf.getId());
}
if(form.getPdfResourceType().equals(2)){
book.setPdf(form.getPdf());
}
}
bookMapper.insertSelective(book);
ebook.setId(book.getId());
ebook.setUploadTime(new Date());
ebook.setBrowseNum(50); //浏览量
ebook.setGoodsType(GoodsTypeEnum.EBOOK.getCode());
ebookMapper.insertSelective(ebook);
} else {
book.setUpdateTime(new Date());
if(form.getPdfResourceType()!=null ){
if(form.getPdfResourceType().equals(1)){
PdfLibrary pdf=new PdfLibrary();
pdf.setPdf(form.getPdf());
pdf.setName(form.getPdfName());
pdf.setUploadTime(new Date());
pdf.setStatus(0);
pdfLibraryMapper.insert(pdf);
book.setPdf(pdf.getId());
}
if(form.getPdfResourceType().equals(2)){
book.setPdf(form.getPdf());
}
}
bookMapper.updateByPrimaryKeySelective(book);
ebook.setUpdateTime(new Date());
ebookMapper.updateByPrimaryKeySelective(ebook);
if(form.getPrice() == null){
Ebook a = ebookMapper.selectByPrimaryKey(ebook.getId());
a.setPrice(form.getPrice());
ebookMapper.updateByPrimaryKey(a);
}
// 删除原有关系表中的关系
EbookDiyType ebdt = new EbookDiyType();
ebdt.setEbookId(ebook.getId());
ebookDiyTypeMapper.delete(ebdt);
}
// 添加关系
if (form.getDiyType() != null && form.getDiyType().size() > 0) {
List<EbookDiyType> dtlist = form.getDiyType();
dtlist.forEach(li -> li.setEbookId(ebook.getId()));
ebookDiyTypeMapper.insertList(dtlist);
}
return true;
}
......@@ -135,7 +124,6 @@ public class EbookServiceImpl extends BaseServiceImpl<Ebook, String> implements
List<EbookListVO> list = ebookMapper.queryByTileAndDiyType(form);
if(!list.isEmpty()){
for(EbookListVO ebookListVO : list){
ebookListVO.setStatus_zh(EbookStatusEnum.getName(Integer.parseInt(ebookListVO.getBookStatus())));
}
}
return new PageInfo<EbookListVO>(list);
......
......@@ -7,12 +7,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.ResponseCodeEnum;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
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.pdffilelibrary.QueryPdfLibraryForm;
import com.zrqx.core.form.resource.bg.pdffilelibrary.SavePdfLibraryForm;
import com.zrqx.core.form.resource.bg.pdffilelibrary.SaveUpdatePdfLibraryForm;
......@@ -22,10 +21,13 @@ import com.zrqx.core.model.resource.pdffilelibrary.PdfLibraryDiyType;
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.ResourceRelationListVo;
import com.zrqx.core.vo.resource.pdffilelibrary.PdfLibraryListVO;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryDiyTypeMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
import tk.mybatis.mapper.entity.Example;
/**
* PDF
*/
......@@ -65,16 +67,6 @@ public class PdfLibrarySerivceImpl extends BaseServiceImpl<PdfLibrary,Integer> i
a.setPrice(form.getPrice());
mapper.updateByPrimaryKey(a);
}
//删除当前对象与自定义分类的关系
PdfLibraryDiyType old = new PdfLibraryDiyType();
old.setPlId(entity.getId());
pdrMapper.delete(old);
}
//添加当前对象与自定义分类的关系
if(form.getDiyType() != null && form.getDiyType().size() > 0){
List<PdfLibraryDiyType> list = form.getDiyType();
list.forEach(li -> li.setPlId(entity.getId()));
pdrMapper.insertList(list);
}
return true;
}
......@@ -106,7 +98,6 @@ public class PdfLibrarySerivceImpl extends BaseServiceImpl<PdfLibrary,Integer> i
PdfLibraryDiyType pdfLibraryDiyType = new PdfLibraryDiyType();
pdfLibraryDiyType.setCode(form.getDiyType().getCode());
pdfLibraryDiyType.setDtId(form.getDiyType().getDtId());
pdfLibraryDiyType.setPlId(obj.getId());
pdrMapper.insert(pdfLibraryDiyType);
}
}
......@@ -174,5 +165,21 @@ public class PdfLibrarySerivceImpl extends BaseServiceImpl<PdfLibrary,Integer> i
}
return null;
}
/**
* 关联资源弹窗
* @see com.zrqx.resource.bg.service.pdffilelibrary.PdfLibraryService#pageByTitleAndDiyType(com.zrqx.core.form.resource.bg.QueryResourceForPoPForm, com.zrqx.core.util.page.PageParam)
* @param form
* @param pageParam
* @return
* @author rjc
* @date: 2019年9月11日 上午10:12:48
*/
@Override
public PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
pageParam.setOrderBy("uploadTime desc");
startPage(pageParam);
List<ResourceRelationListVo> list = mapper.queryByTileAndDiyType(form);
return new PageInfo<ResourceRelationListVo>(list);
}
}
......@@ -2,6 +2,7 @@ package com.zrqx.resource.bg.service.pdffilelibrary;
import java.util.List;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.form.resource.bg.pdffilelibrary.QueryPdfLibraryForm;
import com.zrqx.core.form.resource.bg.pdffilelibrary.SavePdfLibraryForm;
import com.zrqx.core.form.resource.bg.pdffilelibrary.SaveUpdatePdfLibraryForm;
......@@ -9,6 +10,7 @@ import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
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.ResourceRelationListVo;
import com.zrqx.core.vo.resource.pdffilelibrary.PdfLibraryListVO;
/**
* PDF
......@@ -56,4 +58,13 @@ public interface PdfLibraryService extends BaseService<PdfLibrary,Integer>{
* @date: 2019年1月29日 上午10:05:21
*/
String getOriginalFileName(String code);
/**
* 关联资源弹窗
* @param form
* @param pageParam
* @return
* @author rjc
* @date: 2019年9月11日 上午10:12:07
*/
PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论