提交 ddb43059 authored 作者: 任建彩's avatar 任建彩

feat:图书关联全部资源、图书关联系列

1.resource
上级 c8ef8544
......@@ -58,7 +58,23 @@ public class ZipUtil {
System.out.println("压缩完成");
return zipFileName;
}
public static String wholeZip(String rootPath, List<FileInfo> list,String name) throws Exception {
// File zipFile = new File(zipFileName);
System.out.println("压缩中...");
String zipFileName = rootPath + name + ".zip";
// 创建zip输出流
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFileName)));
for (FileInfo file : list) {
String filePath = rootPath + file.getPath() + "/" + file.getFileName() + file.getSuffixName();
File sourceFile = new File(filePath);
compress(out, sourceFile, sourceFile.getName());
}
out.close();
System.out.println("压缩完成");
return zipFileName;
}
public static void compress(ZipOutputStream out, File sourceFile, String base) throws Exception {
// 如果路径为目录(文件夹)
if (sourceFile.isDirectory()) {
......
......@@ -300,6 +300,15 @@ public class FileController {
List<FileInfo> list = service.list(queryWrapper);
return ZipUtil.zip(rootPath, BeanUtils.copyList(list, com.zrqx.core.vo.FileInfo.class));
}
@ApiOperation(value = "全部资源下载zip")
@RequestMapping(value = "/wholeDownload/zip", method = RequestMethod.POST)
public String downLoad(@RequestBody List<String> fileNames,String name) throws Exception {
LambdaQueryWrapper<FileInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(FileInfo::getFileName, fileNames);
List<FileInfo> list = service.list(queryWrapper);
// return ZipUtil.zip(rootPath, BeanUtils.copyList(list, com.zrqx.core.vo.FileInfo.class));
return ZipUtil.wholeZip(rootPath, BeanUtils.copyList(list, com.zrqx.core.vo.FileInfo.class),name);
}
@ApiOperation(value = "导出二维码zip")
@RequestMapping(value = "/download/zip", method = RequestMethod.GET)
public String downLoad(HttpServletResponse response,String fileName) throws Exception {
......
......@@ -345,7 +345,11 @@ public class EbookController {
public CallBack<PageInfo<EbookListVO>> getBookList(QueryEbookInfoForm form, PageParam pageParam) {
return CallBack.success(ebookservice.page(form, pageParam));
}
@ApiOperation("电子书搜索补全")
@GetMapping("/bookList")
public CallBack<List<EbookListVO>> getBookNameList(QueryEbookInfoForm form) {
return CallBack.success(ebookservice.getBookNameList(form));
}
@ApiOperation(value = "筛选列表", notes = "筛选条件列表")
@GetMapping(value = "/option/list")
public CallBack<Map<String, String>> queryOptionList() {
......
......@@ -39,6 +39,7 @@ public interface EbookMapper extends BaseMapper<Ebook> {
+ " LEFT JOIN res_ebook be ON bb.id = be.id "
+ " LEFT JOIN res_ebook_diy_type bdt ON be.id = bdt.ebookid"
+ " LEFT JOIN ( SELECT resourceId,author,authorId FROM res_relation_author GROUP BY resourceId HAVING MIN(id)) ba ON bb.id = ba.resourceId "
+ " LEFT JOIN res_project_model_resource rr ON bb.id = rr.resourceId "
+ " WHERE 1 = 1 "
+ "<if test='form.option == 1'>"
+ " AND (ba.author IS NULL OR ba.author = '') "
......@@ -72,6 +73,7 @@ public interface EbookMapper extends BaseMapper<Ebook> {
+ " AND be.createdTime &lt;= concat(#{form.endTime}, ' 23:59:59')"
+ "</if>"
+ " rlike(bb.departmentCode,form.departmentCode) "
+ " eq(rr.projectId,form.projectId) "
+ "</script>")
List<EbookListVO> page(@Param("form") QueryEbookInfoForm form);
......@@ -338,4 +340,10 @@ public interface EbookMapper extends BaseMapper<Ebook> {
+ " rlike(ld.labelContentDiyTypeCode,form.labelContentDiyTypeCode) "
+"</script>")
List<ResourceListInfoVO> searchResource(@Param("form") ResourceQueryForm form);
@Select("<script>"
+ "SELECT bb.id,bb.name FROM res_book bb WHERE 1=1 "
+ " like(bb.name,form.name)"
+ " rlike(bb.departmentCode,form.departmentCode) "
+"</script>")
List<EbookListVO> getBookNameList(@Param("form") QueryEbookInfoForm form);
}
......@@ -31,6 +31,8 @@ public class QueryEbookInfoForm {
private List<Integer> diyTypeId;
@ApiModelProperty("自定义分类code")
private String diyTypeCode;
@ApiModelProperty("系列")
private String projectId;
@ApiModelProperty("0全部1电子书2实体书")
private Integer bookType;
......
......@@ -17,6 +17,8 @@ public class ResourceRelationVO {
private String objectId;
@ApiModelProperty("资源名")
private String name;
@ApiModelProperty("文件fileName")
private String fileName;
@ApiModelProperty("封面")
private String cover;
@ApiModelProperty("讲师")
......@@ -45,6 +47,7 @@ public class ResourceRelationVO {
private Integer sort;
@ApiModelProperty("播放数,默认值:0")
private Integer browseNum;
//查看全部资源需要
@ApiModelProperty(value = "资源包下关联的资源")
private List<ResourceRelationVO> resourceList;
......
......@@ -282,4 +282,11 @@ public interface EbookService extends IService<Ebook> {
* @return Boolean
*/
Boolean updateReaderNum(String oid);
/**
* 根据图书名搜索补全
* @param: ${tags}
* @author rjc
* @date 2022/4/20 15:48
*/
List<EbookListVO> getBookNameList(QueryEbookInfoForm form);
}
......@@ -62,6 +62,7 @@ import com.zrqx.resource.model.vo.ebook.ExcelBookExportVo;
import com.zrqx.resource.model.vo.ebook.ExcelEbookImportVo;
import com.zrqx.resource.service.*;
import com.zrqx.resource.solr.SolrManage;
import com.zrqx.resource.utils.Reyo;
import com.zrqx.util.datatype.ArrayUtils;
import com.zrqx.util.datatype.DateUtils;
import com.zrqx.util.datatype.StringUtil;
......@@ -1156,6 +1157,36 @@ public class EbookServiceImpl extends ServiceImpl<EbookMapper, Ebook> implements
return update(wrapper);
}
@Override
public List<EbookListVO> getBookNameList(QueryEbookInfoForm form) {
ObjectMapper mapper1 = new ObjectMapper();
String jsonString = systemAdminClient.infoJson(Integer.parseInt(tokenManager.getUserId()));
try {
SystemAdmin systemAdmin = mapper1.readValue(jsonString, SystemAdmin.class);
if (systemAdmin != null) {
if (systemAdmin.getRoles().contains(",")) {
List<String> list = Arrays.asList(systemAdmin.getRoles().split(","));
boolean b = list.stream().anyMatch(s -> s.equals("1"));
if (!b) {
form.setDepartmentCode(systemAdmin.getDepartmentCode());
}
}else{
if (!systemAdmin.getRoles().equals("1")) {
form.setDepartmentCode(systemAdmin.getDepartmentCode());
}
}
}
} catch (JsonProcessingException e) {
e.printStackTrace();
}
List<EbookListVO> list=ebookMapper.getBookNameList(form);
/*for (EbookListVO vo:list) {
String name = Reyo.IgnoreCaseReplace(vo.getName(),form.getName());
vo.setName(name);
}*/
return list;
}
/**
* 机构会员,查询是否有查看该资源的权限
*
......
......@@ -156,6 +156,7 @@ public class ResourceRelationServiceImpl extends ServiceImpl<ResourceRelationMap
e.setResourceType_zh(AllResourceTypeEnum.VIDEO.getName());
e.setStatus(vl.getStatus());
e.setStatus_zh(LibraryStatusEnum.getName(vl.getStatus()));
e.setFileName(vl.getVideo());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.AUDIO.getCode())) {
......@@ -170,6 +171,7 @@ public class ResourceRelationServiceImpl extends ServiceImpl<ResourceRelationMap
e.setSize(al.getSize());
e.setStatus_zh(LibraryStatusEnum.getName(al.getStatus()));
e.setBrowseNum(al.getBrowseNum());
e.setFileName(al.getAudio());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.IMAGE.getCode())) {
......@@ -243,6 +245,7 @@ public class ResourceRelationServiceImpl extends ServiceImpl<ResourceRelationMap
PdfLibrary pdfLibrary = pdfLibraryMapper.selectById(e.getResourceId());
if (pdfLibrary != null) {
e.setName(pdfLibrary.getName());
e.setFileName(pdfLibrary.getPdf());
}
}
}
......
package com.zrqx.resource.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Reyo {
/**
* @param args
*/
public static void main(String[] args) {
String source = "aa reyo Reyo bb rEYO";
String patternstring = "reyo";
System.out.println(IgnoreCaseReplace(source, patternstring));
}
/**
* java实现不区分大小写高亮替换
* @param source
* @param patternstring
* @return
*/
public static String IgnoreCaseReplace(String source, String patternstring) {
Pattern p = Pattern.compile(patternstring, Pattern.CASE_INSENSITIVE);
Matcher mc = p.matcher(source);
StringBuffer sb = new StringBuffer();
while (mc.find()) {
mc.appendReplacement(sb, "<font color='red' >" + mc.group() + "</font>");
}
mc.appendTail(sb);
return sb.toString();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论