提交 9b01e4a8 authored 作者: lizhuo's avatar lizhuo

--no commit message

上级 f4739776
package com.zrqx.resource.bg.controller.ebook; package com.zrqx.resource.bg.controller.ebook;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -10,9 +7,14 @@ import java.util.Arrays; ...@@ -10,9 +7,14 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -24,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -24,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.zrqx.core.constant.resource.ResourceRequestPath; import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.enums.AllResourceTypeEnum; import com.zrqx.core.enums.AllResourceTypeEnum;
...@@ -83,6 +83,10 @@ import com.zrqx.resource.bg.service.projectlibrary.ProjectModelResouresService; ...@@ -83,6 +83,10 @@ import com.zrqx.resource.bg.service.projectlibrary.ProjectModelResouresService;
import com.zrqx.resource.bg.service.recommend.RecommendResourceService; import com.zrqx.resource.bg.service.recommend.RecommendResourceService;
import com.zrqx.resource.commons.Redis; import com.zrqx.resource.commons.Redis;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import tk.mybatis.mapper.entity.Example;
/** /**
* 电子书管理-controller * 电子书管理-controller
* *
...@@ -102,8 +106,8 @@ public class EbookController { ...@@ -102,8 +106,8 @@ public class EbookController {
private EbookDiyTypeService dtservice; private EbookDiyTypeService dtservice;
@Autowired @Autowired
private EbookLabelContentDiyTypeService lcdtservice; private EbookLabelContentDiyTypeService lcdtservice;
//@Autowired // @Autowired
//private EbookResourceService resourceService; // private EbookResourceService resourceService;
@Autowired @Autowired
private ResourceRelationService resourceRelationService; private ResourceRelationService resourceRelationService;
@Autowired @Autowired
...@@ -130,7 +134,7 @@ public class EbookController { ...@@ -130,7 +134,7 @@ public class EbookController {
/** 促销内容 */ /** 促销内容 */
@Autowired @Autowired
private PromotionContentService promotionContentService; private PromotionContentService promotionContentService;
/** 专题关联资源*/ /** 专题关联资源 */
@Autowired @Autowired
private ProjectModelResouresService projectModelResouresService; private ProjectModelResouresService projectModelResouresService;
...@@ -140,14 +144,14 @@ public class EbookController { ...@@ -140,14 +144,14 @@ public class EbookController {
if (!ebookservice.saveOrUpdate(form)) { if (!ebookservice.saveOrUpdate(form)) {
throw new BusinessValidateException("操作失败"); throw new BusinessValidateException("操作失败");
} }
if(StringUtils.isNotBlank(form.getId()) && form.getSalesWay().equals(SalesWayEnum.STATUS_4.getCode())){ if (StringUtils.isNotBlank(form.getId()) && form.getSalesWay().equals(SalesWayEnum.STATUS_4.getCode())) {
// 修改文章状态,下架 // 修改文章状态,下架
this.updateArticleStatus(Arrays.asList(form.getId()), LibraryStatusEnum.STATUS_2.getCode()); this.updateArticleStatus(Arrays.asList(form.getId()), LibraryStatusEnum.STATUS_2.getCode());
}else{ } else {
// 修改文章状态,上架 // 修改文章状态,上架
this.updateArticleStatus(Arrays.asList(form.getId()), LibraryStatusEnum.STATUS_1.getCode()); this.updateArticleStatus(Arrays.asList(form.getId()), LibraryStatusEnum.STATUS_1.getCode());
} }
if(form.getId() != null){ if (form.getId() != null) {
// 促销活动内容修改 // 促销活动内容修改
PromotionContent con = new PromotionContent(); PromotionContent con = new PromotionContent();
con.setResourceId(form.getId()); con.setResourceId(form.getId());
...@@ -162,8 +166,9 @@ public class EbookController { ...@@ -162,8 +166,9 @@ public class EbookController {
res.setResName(form.getName()); res.setResName(form.getName());
recommendResourceService.updateResourceContent(res); recommendResourceService.updateResourceContent(res);
// 专题关联资源 // 专题关联资源
Example ex= projectModelResouresService.createExample(); Example ex = projectModelResouresService.createExample();
ex.and().andEqualTo("resouresId", form.getId()).andEqualTo("resouresClass", AllResourceTypeEnum.WEIKE.getCode()); ex.and().andEqualTo("resouresId", form.getId()).andEqualTo("resouresClass",
AllResourceTypeEnum.WEIKE.getCode());
ProjectModelResoures projectModelResoures = new ProjectModelResoures(); ProjectModelResoures projectModelResoures = new ProjectModelResoures();
projectModelResoures.setImg(form.getImg()); projectModelResoures.setImg(form.getImg());
projectModelResoures.setResouresName(form.getName()); projectModelResoures.setResouresName(form.getName());
...@@ -183,17 +188,17 @@ public class EbookController { ...@@ -183,17 +188,17 @@ public class EbookController {
BeanUtils.copyProperties(book, vo); BeanUtils.copyProperties(book, vo);
Ebook ebook = ebookservice.selectByPrimaryKey(oid); Ebook ebook = ebookservice.selectByPrimaryKey(oid);
BeanUtils.copyProperties(ebook, vo); BeanUtils.copyProperties(ebook, vo);
if(vo.getRealPrice() != null && vo.getRealPrice().doubleValue() == new BigDecimal(0).doubleValue()){ if (vo.getRealPrice() != null && vo.getRealPrice().doubleValue() == new BigDecimal(0).doubleValue()) {
vo.setRealPrice(null); vo.setRealPrice(null);
} }
if(StringUtils.isNotBlank(book.getAuthorId())){ if (StringUtils.isNotBlank(book.getAuthorId())) {
vo.setAuthorNameAndId(book.getAuthor() + "," + book.getAuthorId()); vo.setAuthorNameAndId(book.getAuthor() + "," + book.getAuthorId());
}else{ } else {
vo.setAuthorNameAndId(book.getAuthor()); vo.setAuthorNameAndId(book.getAuthor());
} }
if(StringUtils.isNotBlank(book.getTranslatorId())){ if (StringUtils.isNotBlank(book.getTranslatorId())) {
vo.setTranslatorNameAndId(book.getTranslator() + "," + book.getTranslatorId()); vo.setTranslatorNameAndId(book.getTranslator() + "," + book.getTranslatorId());
}else{ } else {
vo.setTranslatorNameAndId(book.getTranslator()); vo.setTranslatorNameAndId(book.getTranslator());
} }
// 组装自定义分类 // 组装自定义分类
...@@ -207,7 +212,8 @@ public class EbookController { ...@@ -207,7 +212,8 @@ public class EbookController {
List<EbookLabelContentDiyType> lcdList = lcdtservice.selectByExample(example); List<EbookLabelContentDiyType> lcdList = lcdtservice.selectByExample(example);
vo.setLabel(lcdList); vo.setLabel(lcdList);
// 选中的LabelContentDiyTypeId // 选中的LabelContentDiyTypeId
List<Integer> labelContentDiyTypeIds = lcdList.stream().map(EbookLabelContentDiyType :: getLabelContentDiyTypeId).collect(Collectors.toList()); List<Integer> labelContentDiyTypeIds = lcdList.stream().map(EbookLabelContentDiyType::getLabelContentDiyTypeId)
.collect(Collectors.toList());
vo.setLabelContentDiyTypeIds(labelContentDiyTypeIds); vo.setLabelContentDiyTypeIds(labelContentDiyTypeIds);
if (StringUtils.isNotBlank(ebook.getPdfFile())) { if (StringUtils.isNotBlank(ebook.getPdfFile())) {
vo.setPdf_zh(pdfLibraryService.getOriginalFileName(ebook.getPdfFile())); vo.setPdf_zh(pdfLibraryService.getOriginalFileName(ebook.getPdfFile()));
...@@ -226,7 +232,7 @@ public class EbookController { ...@@ -226,7 +232,7 @@ public class EbookController {
eb.setRealPrice(form.getRealPrice()); eb.setRealPrice(form.getRealPrice());
Example example = ebookservice.createExample(); Example example = ebookservice.createExample();
example.createCriteria().andIn("id", form.getIds()); example.createCriteria().andIn("id", form.getIds());
if (!ebookservice.UpdateByExampleSelective(eb,example)) { if (!ebookservice.UpdateByExampleSelective(eb, example)) {
throw new BusinessValidateException("操作失败"); throw new BusinessValidateException("操作失败");
} }
return CallBack.success(); return CallBack.success();
...@@ -254,19 +260,19 @@ public class EbookController { ...@@ -254,19 +260,19 @@ public class EbookController {
b.setSalesWay(form.getSalesWay()); b.setSalesWay(form.getSalesWay());
Example example = bookservice.createExample(); Example example = bookservice.createExample();
example.createCriteria().andIn("id", form.getIds()); example.createCriteria().andIn("id", form.getIds());
bookservice.UpdateByExampleSelective(b,example); bookservice.UpdateByExampleSelective(b, example);
if(form.getSalesWay().equals(SalesWayEnum.STATUS_3.getCode())){ if (form.getSalesWay().equals(SalesWayEnum.STATUS_3.getCode())) {
Ebook ebook = new Ebook(); Ebook ebook = new Ebook();
ebook.setRealPrice(form.getRealPrice()); ebook.setRealPrice(form.getRealPrice());
ebook.setPriceOption(PriceOptionEnum.STATUS_1.getCode()); ebook.setPriceOption(PriceOptionEnum.STATUS_1.getCode());
example = ebookservice.createExample(); example = ebookservice.createExample();
example.createCriteria().andIn("id", form.getIds()); example.createCriteria().andIn("id", form.getIds());
ebookservice.UpdateByExampleSelective(ebook,example); ebookservice.UpdateByExampleSelective(ebook, example);
} }
if(form.getSalesWay().equals(SalesWayEnum.STATUS_4.getCode())){ if (form.getSalesWay().equals(SalesWayEnum.STATUS_4.getCode())) {
// 修改文章状态,下架 // 修改文章状态,下架
this.updateArticleStatus(form.getIds(), LibraryStatusEnum.STATUS_2.getCode()); this.updateArticleStatus(form.getIds(), LibraryStatusEnum.STATUS_2.getCode());
}else{ } else {
// 修改文章状态,上架 // 修改文章状态,上架
this.updateArticleStatus(form.getIds(), LibraryStatusEnum.STATUS_1.getCode()); this.updateArticleStatus(form.getIds(), LibraryStatusEnum.STATUS_1.getCode());
} }
...@@ -288,7 +294,8 @@ public class EbookController { ...@@ -288,7 +294,8 @@ public class EbookController {
throw new BusinessValidateException("您选择的状态数据不能执行此操作,请重新选择"); throw new BusinessValidateException("您选择的状态数据不能执行此操作,请重新选择");
} }
} else if (form.getBookStatus() == EbookStatusEnum._4.getCode()) {// 审核通过并上架操作 } else if (form.getBookStatus() == EbookStatusEnum._4.getCode()) {// 审核通过并上架操作
if (!list(form.getIds(), EbookStatusEnum._4, false, EbookStatusEnum._1, EbookStatusEnum._2, EbookStatusEnum._3)) {// 如果状态不是 if (!list(form.getIds(), EbookStatusEnum._4, false, EbookStatusEnum._1, EbookStatusEnum._2,
EbookStatusEnum._3)) {// 如果状态不是
// 1待审核和2审核中3审核不通过 // 1待审核和2审核中3审核不通过
// 不能变更为4审核通过并上架 // 不能变更为4审核通过并上架
throw new BusinessValidateException("您选择的状态数据不能执行此操作,请重新选择"); throw new BusinessValidateException("您选择的状态数据不能执行此操作,请重新选择");
...@@ -317,11 +324,12 @@ public class EbookController { ...@@ -317,11 +324,12 @@ public class EbookController {
} else { } else {
throw new ParameterValidateException("请求参数有误,请检查!"); throw new ParameterValidateException("请求参数有误,请检查!");
} }
if(form.getBookStatus() == EbookStatusEnum._5.getCode() && ArrayUtils.isNotEmpty(form.getIds())){ if (form.getBookStatus() == EbookStatusEnum._5.getCode() && ArrayUtils.isNotEmpty(form.getIds())) {
//这里需要级联更新其他接口关联资源 // 这里需要级联更新其他接口关联资源
//----推荐位内容 // ----推荐位内容
Example example = recommendResourceService.createExample(); Example example = recommendResourceService.createExample();
example.createCriteria().andIn("resId", form.getIds()).andEqualTo("resType", AllResourceTypeEnum.TUSHU.getCode()); example.createCriteria().andIn("resId", form.getIds()).andEqualTo("resType",
AllResourceTypeEnum.TUSHU.getCode());
RecommendResource re = new RecommendResource(); RecommendResource re = new RecommendResource();
re.setStatus(Integer.parseInt(BooleanStatusEnum.NO.getCode())); re.setStatus(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
recommendResourceService.UpdateByExampleSelective(re, example); recommendResourceService.UpdateByExampleSelective(re, example);
...@@ -361,16 +369,16 @@ public class EbookController { ...@@ -361,16 +369,16 @@ public class EbookController {
Example example = alservice.createExample(); Example example = alservice.createExample();
example.createCriteria().andIn("bookId", ids); example.createCriteria().andIn("bookId", ids);
List<ArticleLibrary> articleList = alservice.selectByExample(example); List<ArticleLibrary> articleList = alservice.selectByExample(example);
if(ArrayUtils.isNotEmpty(articleList)){ if (ArrayUtils.isNotEmpty(articleList)) {
List<String> articleIds = articleList.stream().map(ArticleLibrary :: getId).collect(Collectors.toList()); List<String> articleIds = articleList.stream().map(ArticleLibrary::getId).collect(Collectors.toList());
alservice.batchDelete(articleIds); alservice.batchDelete(articleIds);
} }
// 删除图片 // 删除图片
example = ilService.createExample(); example = ilService.createExample();
example.createCriteria().andIn("bookId", ids); example.createCriteria().andIn("bookId", ids);
List<ImageLibrary> imageList = ilService.selectByExample(example); List<ImageLibrary> imageList = ilService.selectByExample(example);
if(ArrayUtils.isNotEmpty(imageList)){ if (ArrayUtils.isNotEmpty(imageList)) {
List<Integer> imageIds = imageList.stream().map(ImageLibrary :: getId).collect(Collectors.toList()); List<Integer> imageIds = imageList.stream().map(ImageLibrary::getId).collect(Collectors.toList());
ilService.batchDelete(imageIds); ilService.batchDelete(imageIds);
} }
// 删除目录 // 删除目录
...@@ -404,7 +412,7 @@ public class EbookController { ...@@ -404,7 +412,7 @@ public class EbookController {
if (entity == null || entity.getId() == null) { if (entity == null || entity.getId() == null) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "资源id不能为空!"); throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "资源id不能为空!");
} }
if(entity.getResourceType() != null && entity.getResourceType() == 0){ if (entity.getResourceType() != null && entity.getResourceType() == 0) {
entity.setResourceType(null); entity.setResourceType(null);
} }
List<ResourceRelationVo> list = resourceRelationService.queryByIdAndResourceType(entity, pageParam); List<ResourceRelationVo> list = resourceRelationService.queryByIdAndResourceType(entity, pageParam);
...@@ -414,18 +422,22 @@ public class EbookController { ...@@ -414,18 +422,22 @@ public class EbookController {
return CallBack.success(new PageInfo<ResourceRelationVo>(resourceRelationService.queryRelationList(list))); return CallBack.success(new PageInfo<ResourceRelationVo>(resourceRelationService.queryRelationList(list)));
} }
/*@ApiOperation(value = "选择弹窗中的列表", notes = "查询选择弹窗中的列表") /*
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.POPPAGE) * @ApiOperation(value = "选择弹窗中的列表", notes = "查询选择弹窗中的列表")
public CallBack<PageInfo<EbookListVO>> page(QueryResourceForPoPForm form, PageParam pageParam) { *
return CallBack.success(ebookservice.pageByTitleAndDiyType(form, pageParam)); * @GetMapping(value = ResourceRequestPath.RELATION_RESOURCE +
}*/ * ResourceRequestPath.POPPAGE) public CallBack<PageInfo<EbookListVO>>
* page(QueryResourceForPoPForm form, PageParam pageParam) { return
* CallBack.success(ebookservice.pageByTitleAndDiyType(form, pageParam)); }
*/
@ApiOperation(value = "保存相关资源", notes = "保存相关资源") @ApiOperation(value = "保存相关资源", notes = "保存相关资源")
@PostMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.SAVE) @PostMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.SAVE)
public CallBack<Boolean> saveRelation(@RequestBody SaveResourceRelationForm entity) { public CallBack<Boolean> saveRelation(@RequestBody SaveResourceRelationForm entity) {
if (entity.getId() == null || entity.getResourceIds() == null || entity.getResourceType() == null if (entity.getId() == null || entity.getResourceIds() == null || entity.getResourceType() == null
|| entity.getResourceIds().length == 0) { || entity.getResourceIds().length == 0) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "必须指定id、被关联的resourceId、资源类型"); throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(),
"必须指定id、被关联的resourceId、资源类型");
} }
List<ResourceRelation> recordList = new ArrayList<ResourceRelation>(); List<ResourceRelation> recordList = new ArrayList<ResourceRelation>();
Arrays.asList(entity.getResourceIds()).forEach(resourceId -> { Arrays.asList(entity.getResourceIds()).forEach(resourceId -> {
...@@ -453,9 +465,9 @@ public class EbookController { ...@@ -453,9 +465,9 @@ public class EbookController {
return CallBack.success(); return CallBack.success();
} }
@ApiOperation(value = "修改关联资源排序号" , notes = "修改关联资源排序号") @ApiOperation(value = "修改关联资源排序号", notes = "修改关联资源排序号")
@PostMapping(value = ResourceRequestPath.RELATION_RESOURCE +ResourceRequestPath.UPDATE) @PostMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.UPDATE)
public CallBack<?> updateResourceSort(Integer oid, Integer sort){ public CallBack<?> updateResourceSort(Integer oid, Integer sort) {
ResourceRelation res = new ResourceRelation(); ResourceRelation res = new ResourceRelation();
res.setId(oid); res.setId(oid);
res.setSort(sort); res.setSort(sort);
...@@ -464,7 +476,8 @@ public class EbookController { ...@@ -464,7 +476,8 @@ public class EbookController {
@ApiOperation("导入图书文章的分类表") @ApiOperation("导入图书文章的分类表")
@PostMapping(value = ResourceRequestPath.IMPORT) @PostMapping(value = ResourceRequestPath.IMPORT)
public CallBack<?> importBook(@RequestParam("file") MultipartFile file,@RequestParam("bookId") String bookId) throws Exception { public CallBack<?> importBook(@RequestParam("file") MultipartFile file, @RequestParam("bookId") String bookId)
throws Exception {
ExcelImportDiyTypeAndLabelVO vo = bookservice.importExcel(file, bookId); ExcelImportDiyTypeAndLabelVO vo = bookservice.importExcel(file, bookId);
return CallBack.success(vo); return CallBack.success(vo);
} }
...@@ -472,14 +485,10 @@ public class EbookController { ...@@ -472,14 +485,10 @@ public class EbookController {
/** /**
* 批量修改 * 批量修改
* *
* @param ids * @param ids 要修改数据id主键集合
* 要修改数据id主键集合 * @param bookStatus 要修改的值
* @param bookStatus * @param falg true ==,false !=
* 要修改的值 * @param status 要判断的值 可变参数
* @param falg
* true ==,false !=
* @param status
* 要判断的值 可变参数
* @return * @return
*/ */
public Boolean list(List<String> ids, EbookStatusEnum bookStatus, boolean falg, EbookStatusEnum... status) { public Boolean list(List<String> ids, EbookStatusEnum bookStatus, boolean falg, EbookStatusEnum... status) {
...@@ -507,7 +516,7 @@ public class EbookController { ...@@ -507,7 +516,7 @@ public class EbookController {
Ebook eb = new Ebook(); Ebook eb = new Ebook();
eb.setBookStatus(bookStatus.getCode()); eb.setBookStatus(bookStatus.getCode());
eb.setUpdateTime(new Date()); eb.setUpdateTime(new Date());
ebookservice.UpdateByExampleSelective(eb,example); ebookservice.UpdateByExampleSelective(eb, example);
return true; return true;
} }
...@@ -523,7 +532,7 @@ public class EbookController { ...@@ -523,7 +532,7 @@ public class EbookController {
@ApiOperation(value = "批量上传解析epub", notes = "批量上传解析epub") @ApiOperation(value = "批量上传解析epub", notes = "批量上传解析epub")
@PostMapping(value = ResourceRequestPath.UPLOADEPUB) @PostMapping(value = ResourceRequestPath.UPLOADEPUB)
public CallBack<Boolean> uploadBook(@RequestBody List<String> tokenList) { public CallBack<Boolean> uploadBook(@RequestBody List<String> tokenList) {
if(ArrayUtils.isNotEmpty(tokenList)){ if (ArrayUtils.isNotEmpty(tokenList)) {
tokenList.stream().forEach(token -> this.importEpub(token)); tokenList.stream().forEach(token -> this.importEpub(token));
} }
return CallBack.success(); return CallBack.success();
...@@ -532,11 +541,12 @@ public class EbookController { ...@@ -532,11 +541,12 @@ public class EbookController {
/** /**
* 解析epub * 解析epub
*
* @param token * @param token
* @author ycw * @author ycw
* @date: 2019年7月25日 下午6:01:51 * @date: 2019年7月25日 下午6:01:51
*/ */
private void importEpub(String token){ private void importEpub(String token) {
EpubVo ev = redis.getInfoObjectRedis(token, EpubVo.class); EpubVo ev = redis.getInfoObjectRedis(token, EpubVo.class);
if (ev == null) { if (ev == null) {
throw new BaseException("缓存中找不到该token"); throw new BaseException("缓存中找不到该token");
...@@ -579,13 +589,13 @@ public class EbookController { ...@@ -579,13 +589,13 @@ public class EbookController {
article.setBrowseNum(50); article.setBrowseNum(50);
article.setSalesNum(0); article.setSalesNum(0);
alservice.insert(article); alservice.insert(article);
/*ArticleLibraryDiyType aldt = new ArticleLibraryDiyType(); /*
aldt.setAlId(article.getId()); * ArticleLibraryDiyType aldt = new ArticleLibraryDiyType();
aldt.setCode(ev.getCode()); * aldt.setAlId(article.getId()); aldt.setCode(ev.getCode());
aldt.setDtId(ev.getDtId()); * aldt.setDtId(ev.getDtId()); aldtservice.insertSelective(aldt);
aldtservice.insertSelective(aldt);*/ */
}); });
//图片表 // 图片表
ev.getImageSet().forEach(image -> { ev.getImageSet().forEach(image -> {
image.setBookId(ev.getEbook().getId()); image.setBookId(ev.getEbook().getId());
image.setBookName(ev.getBook().getName()); image.setBookName(ev.getBook().getName());
...@@ -595,15 +605,13 @@ public class EbookController { ...@@ -595,15 +605,13 @@ public class EbookController {
ilService.insertList(new ArrayList(ev.getImageSet())); ilService.insertList(new ArrayList(ev.getImageSet()));
// 图片分类关联表 // 图片分类关联表
/*List<ImageLibraryDiyType> ildtList = new ArrayList<ImageLibraryDiyType>(); /*
for (ImageLibrary il : ev.getImageSet()) { * List<ImageLibraryDiyType> ildtList = new ArrayList<ImageLibraryDiyType>();
ImageLibraryDiyType ildt = new ImageLibraryDiyType(); * for (ImageLibrary il : ev.getImageSet()) { ImageLibraryDiyType ildt = new
ildt.setDtId(ev.getDtId()); * ImageLibraryDiyType(); ildt.setDtId(ev.getDtId());
ildt.setCode(ev.getCode()); * ildt.setCode(ev.getCode()); ildt.setIlId(il.getId()); ildtList.add(ildt); }
ildt.setIlId(il.getId()); * ildtrService.insertList(ildtList);
ildtList.add(ildt); */
}
ildtrService.insertList(ildtList);*/
try { try {
redis.delete(token); redis.delete(token);
...@@ -614,13 +622,14 @@ public class EbookController { ...@@ -614,13 +622,14 @@ public class EbookController {
/** /**
* 目录 * 目录
*
* @param bookid * @param bookid
* @return * @return
* @author ycw * @author ycw
* @date: 2019年4月24日 下午2:28:15 * @date: 2019年4月24日 下午2:28:15
*/ */
public List<ChapterLibrary> getDirectory(String bookid) { public List<ChapterLibrary> getDirectory(String bookid) {
if(StringUtils.isBlank(bookid)){ if (StringUtils.isBlank(bookid)) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "参数不能为空!"); throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "参数不能为空!");
} }
Example example = clservice.createExample(); Example example = clservice.createExample();
...@@ -630,15 +639,15 @@ public class EbookController { ...@@ -630,15 +639,15 @@ public class EbookController {
ChapterLibrary d = new ChapterLibrary(); ChapterLibrary d = new ChapterLibrary();
for (ChapterLibrary ch : list) { for (ChapterLibrary ch : list) {
String name = ch.getChapterName(); String name = ch.getChapterName();
if(name.contains("目录")){ if (name.contains("目录")) {
ChapterLibrary c = new ChapterLibrary(); ChapterLibrary c = new ChapterLibrary();
c.setOrderNum(ch.getOrderNum()+1); c.setOrderNum(ch.getOrderNum() + 1);
d = c; d = c;
break; break;
}else if(name.contains("一") || name.contains("1")){ } else if (name.contains("一") || name.contains("1")) {
d = ch; d = ch;
break; break;
}else{ } else {
d.setOrderNum(0); d.setOrderNum(0);
} }
} }
...@@ -651,16 +660,83 @@ public class EbookController { ...@@ -651,16 +660,83 @@ public class EbookController {
/** /**
* 修改文章状态,id集合,需要修改的状态 * 修改文章状态,id集合,需要修改的状态
*
* @param ids * @param ids
* @param status * @param status
* @author ycw * @author ycw
* @date: 2019年8月1日 下午3:09:50 * @date: 2019年8月1日 下午3:09:50
*/ */
private void updateArticleStatus(List<String> ids, Integer status){ private void updateArticleStatus(List<String> ids, Integer status) {
Example example = alservice.createExample(); Example example = alservice.createExample();
example.createCriteria().andIn("bookId", ids); example.createCriteria().andIn("bookId", ids);
ArticleLibrary article = new ArticleLibrary(); ArticleLibrary article = new ArticleLibrary();
article.setStatus(LibraryStatusEnum.STATUS_1.getCode()); article.setStatus(LibraryStatusEnum.STATUS_1.getCode());
alservice.UpdateByExampleSelective(article,example); alservice.UpdateByExampleSelective(article, example);
}
@ApiOperation(value = "测试案例问答录入", notes = "测试案例问答录入")
@GetMapping(value = "/anliwenda")
public void anliwenda(String bookId) {
String pattern1 = "问题\\d.*";
String pattern2 = "案例\\d.*";
ArticleLibrary article = new ArticleLibrary();
article.setBookId(bookId);
List<ArticleLibrary> articleList = alservice.select(article);
for (ArticleLibrary item : articleList) {
String text = item.getText();
if (text.contains("案例") || text.contains("问题")) {
Document doc = Jsoup.parse(text);
Elements elements = doc.select(".emphasis_bold");
for (Element e : elements) {
boolean flag = false;
if (e.text().contains("案例") || e.text().contains("问题")) {
StringBuffer sb = new StringBuffer();
Element el = e.parent().nextElementSibling();
ArticleLibrary newArticle = new ArticleLibrary();
while (el != null && el.hasClass("content_reference")) {
flag = true;
BeanUtils.copyProperties(item, newArticle);
String tex = e.text();
String[] tex1 =tex.split(" ");
if(tex1.length>1) {
tex=tex1[1];
}
String[] tex2=tex.split(":");
if(tex2.length>1) {
tex=tex2[1];
}
newArticle.setName(tex);
sb.append(el.toString());
el = el.nextElementSibling();
}
if (flag) {
newArticle.setText(sb.toString());
newArticle.setUpdateTime(new Date());
newArticle.setUploadTime(new Date());
newArticle.setMarkid("");
newArticle.setId(null);
if (Pattern.matches(pattern1, e.text())) {
newArticle.setResourceType(35);
alservice.insert(newArticle);
}
if (Pattern.matches(pattern2, e.text())) {
newArticle.setResourceType(23);
alservice.insert(newArticle);
}
}
}
}
}
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论