1、新增文档分类管理
2、新增资源管理开发
This commit is contained in:
parent
2a75898712
commit
a272e06018
@ -1,17 +1,25 @@
|
||||
package com.rzdata.web.controller.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.rzdata.common.config.JaConfig;
|
||||
import com.rzdata.common.constant.Constants;
|
||||
@ -160,4 +168,68 @@ public class CommonController
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/initUpload")
|
||||
public ResponseEntity<Map<String, String>> initUpload(@RequestParam("fileName") String fileName) {
|
||||
// 上传文件路径
|
||||
String filePath = JaConfig.getUploadPath();
|
||||
String uploadId = UUID.randomUUID().toString();
|
||||
// 创建临时目录用于存放分片文件
|
||||
new File(filePath + "/" + uploadId).mkdirs();
|
||||
Map<String, String> response = new HashMap<>();
|
||||
response.put("uploadId", uploadId);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@PostMapping("/uploadChunk")
|
||||
public ResponseEntity<Map<String, String>> uploadChunk(
|
||||
@RequestParam("chunkFile") MultipartFile chunkFile,
|
||||
@RequestParam("uploadId") String uploadId,
|
||||
@RequestParam("chunkId") int chunkId) {
|
||||
String filePath = JaConfig.getUploadPath();
|
||||
String chunkFilePath = filePath + "/" + uploadId + "/" + chunkId;
|
||||
try {
|
||||
chunkFile.transferTo(new File(chunkFilePath));
|
||||
Map<String, String> response = new HashMap<>();
|
||||
response.put("status", "200");
|
||||
return ResponseEntity.ok(response);
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/mergeFile")
|
||||
public ResponseEntity<Map<String, String>> mergeFile(@RequestParam("uploadId") String uploadId,
|
||||
@RequestParam("fileName") String fileName) {
|
||||
String filePath = JaConfig.getUploadPath();
|
||||
//String finalFilePath = FileUploadUtils.generateMergedFilePath(filePath, fileName);
|
||||
String fileNamePath = FileUploadUtils.getFilePath(filePath, fileName);
|
||||
String finalFilePath = filePath + fileNamePath.replace("profile/upload/", "") ;
|
||||
File dir = new File(filePath + "/" + uploadId);
|
||||
File[] chunkFiles = dir.listFiles();
|
||||
|
||||
// 按文件名(即chunkId)排序
|
||||
Arrays.sort(chunkFiles, Comparator.comparingInt(f -> Integer.parseInt(f.getName())));
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(finalFilePath)) {
|
||||
for (File chunk : chunkFiles) {
|
||||
Files.copy(chunk.toPath(), fos);
|
||||
}
|
||||
|
||||
Map<String, String> response = new HashMap<>();
|
||||
String url = serverConfig.getUrl() + fileNamePath;
|
||||
response.put("url", url);
|
||||
response.put("fileUrl", finalFilePath);
|
||||
response.put("fileNamePath", fileNamePath);
|
||||
return ResponseEntity.ok(response);
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
} finally {
|
||||
// 清理临时文件
|
||||
Arrays.stream(chunkFiles).forEach(File::delete);
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,116 @@
|
||||
package com.rzdata.web.controller.document;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.rzdata.common.core.domain.DocumentCategory;
|
||||
import com.rzdata.web.service.IDocumentCategoryService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.rzdata.common.annotation.Log;
|
||||
import com.rzdata.common.core.controller.BaseController;
|
||||
import com.rzdata.common.core.domain.AjaxResult;
|
||||
import com.rzdata.common.enums.BusinessType;
|
||||
import com.rzdata.common.utils.poi.ExcelUtil;
|
||||
import com.rzdata.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 文档资源分类管理Controller
|
||||
*
|
||||
* @author spongepan
|
||||
* @date 2024-08-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/category")
|
||||
public class DocumentCategoryController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IDocumentCategoryService documentCategoryService;
|
||||
|
||||
/**
|
||||
* 查询文档资源分类管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(DocumentCategory documentCategory)
|
||||
{
|
||||
startPage();
|
||||
List<DocumentCategory> list = documentCategoryService.selectDocumentCategoryList(documentCategory);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文档资源分类管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:export')")
|
||||
@Log(title = "文档资源分类管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DocumentCategory documentCategory)
|
||||
{
|
||||
List<DocumentCategory> list = documentCategoryService.selectDocumentCategoryList(documentCategory);
|
||||
ExcelUtil<DocumentCategory> util = new ExcelUtil<DocumentCategory>(DocumentCategory.class);
|
||||
util.exportExcel(response, list, "文档资源分类管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档资源分类管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(documentCategoryService.selectDocumentCategoryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文档资源分类管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:add')")
|
||||
@Log(title = "文档资源分类管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody DocumentCategory documentCategory)
|
||||
{
|
||||
return toAjax(documentCategoryService.insertDocumentCategory(documentCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文档资源分类管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:edit')")
|
||||
@Log(title = "文档资源分类管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody DocumentCategory documentCategory)
|
||||
{
|
||||
return toAjax(documentCategoryService.updateDocumentCategory(documentCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档资源分类管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:remove')")
|
||||
@Log(title = "文档资源分类管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(documentCategoryService.deleteDocumentCategoryByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文档分类树列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:category:tree:list')")
|
||||
@GetMapping("/documentTree")
|
||||
public AjaxResult deptTree(DocumentCategory documentCategory)
|
||||
{
|
||||
return success(documentCategoryService.selectDocumentTreeList(documentCategory));
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.rzdata.web.domain;
|
||||
|
||||
import com.rzdata.common.annotation.Excel;
|
||||
import com.rzdata.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
@ -11,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
* @author ja
|
||||
* @date 2024-07-08
|
||||
*/
|
||||
@Data
|
||||
public class Document extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -49,106 +51,11 @@ public class Document extends BaseEntity {
|
||||
@Excel(name = "文档地址")
|
||||
private String docUrl;
|
||||
|
||||
public void setDocId(String docId)
|
||||
{
|
||||
this.docId = docId;
|
||||
}
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
public String getDocId()
|
||||
{
|
||||
return docId;
|
||||
}
|
||||
public void setDocCode(String docCode)
|
||||
{
|
||||
this.docCode = docCode;
|
||||
}
|
||||
|
||||
public String getDocCode()
|
||||
{
|
||||
return docCode;
|
||||
}
|
||||
public void setDocName(String docName)
|
||||
{
|
||||
this.docName = docName;
|
||||
}
|
||||
|
||||
public String getDocName()
|
||||
{
|
||||
return docName;
|
||||
}
|
||||
public void setDocType(String docType)
|
||||
{
|
||||
this.docType = docType;
|
||||
}
|
||||
|
||||
public String getDocType()
|
||||
{
|
||||
return docType;
|
||||
}
|
||||
public void setDocPrincipals(String docPrincipals)
|
||||
{
|
||||
this.docPrincipals = docPrincipals;
|
||||
}
|
||||
|
||||
public String getDocPrincipals()
|
||||
{
|
||||
return docPrincipals;
|
||||
}
|
||||
public void setDocRespDept(String docRespDept)
|
||||
{
|
||||
this.docRespDept = docRespDept;
|
||||
}
|
||||
|
||||
public String getDocRespDept()
|
||||
{
|
||||
return docRespDept;
|
||||
}
|
||||
public void setDocSource(String docSource)
|
||||
{
|
||||
this.docSource = docSource;
|
||||
}
|
||||
|
||||
public String getDocSource()
|
||||
{
|
||||
return docSource;
|
||||
}
|
||||
|
||||
public void setDocStatus(String docStatus)
|
||||
{
|
||||
this.docStatus = docStatus;
|
||||
}
|
||||
|
||||
public String getDocStatus()
|
||||
{
|
||||
return docStatus;
|
||||
}
|
||||
|
||||
public void setDocUrl(String docUrl)
|
||||
{
|
||||
this.docUrl = docUrl;
|
||||
}
|
||||
|
||||
public String getDocUrl()
|
||||
{
|
||||
return docUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("docId", getDocId())
|
||||
.append("docCode", getDocCode())
|
||||
.append("docName", getDocName())
|
||||
.append("docType", getDocType())
|
||||
.append("docPrincipals", getDocPrincipals())
|
||||
.append("docRespDept", getDocRespDept())
|
||||
.append("docSource", getDocSource())
|
||||
.append("docStatus", getDocStatus())
|
||||
.append("docUrl", getDocUrl())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
/** 文档分类id */
|
||||
@Excel(name = "文档分类id")
|
||||
private String docCategoryId;
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.rzdata.web.mapper;
|
||||
|
||||
import com.rzdata.common.core.domain.DocumentCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档资源分类管理Mapper接口
|
||||
*
|
||||
* @author spongepan
|
||||
* @date 2024-08-27
|
||||
*/
|
||||
public interface DocumentCategoryMapper
|
||||
{
|
||||
/**
|
||||
* 查询文档资源分类管理
|
||||
*
|
||||
* @param id 文档资源分类管理主键
|
||||
* @return 文档资源分类管理
|
||||
*/
|
||||
public DocumentCategory selectDocumentCategoryById(String id);
|
||||
|
||||
/**
|
||||
* 查询文档资源分类管理列表
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 文档资源分类管理集合
|
||||
*/
|
||||
public List<DocumentCategory> selectDocumentCategoryList(DocumentCategory documentCategory);
|
||||
|
||||
/**
|
||||
* 新增文档资源分类管理
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDocumentCategory(DocumentCategory documentCategory);
|
||||
|
||||
/**
|
||||
* 修改文档资源分类管理
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDocumentCategory(DocumentCategory documentCategory);
|
||||
|
||||
/**
|
||||
* 删除文档资源分类管理
|
||||
*
|
||||
* @param id 文档资源分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDocumentCategoryById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除文档资源分类管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDocumentCategoryByIds(String[] ids);
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.rzdata.web.service;
|
||||
|
||||
import com.rzdata.common.core.domain.TreeSelect;
|
||||
import com.rzdata.common.core.domain.DocumentCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档资源分类管理Service接口
|
||||
*
|
||||
* @author spongepan
|
||||
* @date 2024-08-27
|
||||
*/
|
||||
public interface IDocumentCategoryService
|
||||
{
|
||||
/**
|
||||
* 查询文档资源分类管理
|
||||
*
|
||||
* @param id 文档资源分类管理主键
|
||||
* @return 文档资源分类管理
|
||||
*/
|
||||
public DocumentCategory selectDocumentCategoryById(String id);
|
||||
|
||||
/**
|
||||
* 查询文档资源分类管理列表
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 文档资源分类管理集合
|
||||
*/
|
||||
public List<DocumentCategory> selectDocumentCategoryList(DocumentCategory documentCategory);
|
||||
|
||||
/**
|
||||
* 新增文档资源分类管理
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDocumentCategory(DocumentCategory documentCategory);
|
||||
|
||||
/**
|
||||
* 修改文档资源分类管理
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDocumentCategory(DocumentCategory documentCategory);
|
||||
|
||||
/**
|
||||
* 批量删除文档资源分类管理
|
||||
*
|
||||
* @param ids 需要删除的文档资源分类管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDocumentCategoryByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除文档资源分类管理信息
|
||||
*
|
||||
* @param id 文档资源分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDocumentCategoryById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 获取文档资源树
|
||||
* @param documentCategory
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelect> selectDocumentTreeList(DocumentCategory documentCategory);
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package com.rzdata.web.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import com.rzdata.common.core.domain.TreeSelect;
|
||||
import com.rzdata.common.utils.DateUtils;
|
||||
import com.rzdata.common.utils.SecurityUtils;
|
||||
import com.rzdata.common.utils.StringUtils;
|
||||
import com.rzdata.common.core.domain.DocumentCategory;
|
||||
import com.rzdata.web.mapper.DocumentCategoryMapper;
|
||||
import com.rzdata.web.service.IDocumentCategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档资源分类管理Service业务层处理
|
||||
*
|
||||
* @author spongepan
|
||||
* @date 2024-08-27
|
||||
*/
|
||||
@Service
|
||||
public class DocumentCategoryServiceImpl implements IDocumentCategoryService
|
||||
{
|
||||
@Autowired
|
||||
private DocumentCategoryMapper documentCategoryMapper;
|
||||
|
||||
@Autowired
|
||||
private Snowflake snowflake;
|
||||
|
||||
/**
|
||||
* 查询文档资源分类管理
|
||||
*
|
||||
* @param id 文档资源分类管理主键
|
||||
* @return 文档资源分类管理
|
||||
*/
|
||||
@Override
|
||||
public DocumentCategory selectDocumentCategoryById(String id)
|
||||
{
|
||||
return documentCategoryMapper.selectDocumentCategoryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文档资源分类管理列表
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 文档资源分类管理
|
||||
*/
|
||||
@Override
|
||||
public List<DocumentCategory> selectDocumentCategoryList(DocumentCategory documentCategory)
|
||||
{
|
||||
return documentCategoryMapper.selectDocumentCategoryList(documentCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文档资源分类管理
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDocumentCategory(DocumentCategory documentCategory)
|
||||
{
|
||||
documentCategory.setId(String.valueOf(snowflake.nextId()));
|
||||
documentCategory.setCreateTime(DateUtils.getNowDate());
|
||||
documentCategory.setCreateBy(SecurityUtils.getLoginUser().getUsername());
|
||||
documentCategory.setCreateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
|
||||
return documentCategoryMapper.insertDocumentCategory(documentCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文档资源分类管理
|
||||
*
|
||||
* @param documentCategory 文档资源分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDocumentCategory(DocumentCategory documentCategory)
|
||||
{
|
||||
documentCategory.setUpdateTime(DateUtils.getNowDate());
|
||||
return documentCategoryMapper.updateDocumentCategory(documentCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文档资源分类管理
|
||||
*
|
||||
* @param ids 需要删除的文档资源分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDocumentCategoryByIds(String[] ids)
|
||||
{
|
||||
return documentCategoryMapper.deleteDocumentCategoryByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档资源分类管理信息
|
||||
*
|
||||
* @param id 文档资源分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDocumentCategoryById(String id)
|
||||
{
|
||||
return documentCategoryMapper.deleteDocumentCategoryById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelect> selectDocumentTreeList(DocumentCategory documentCategory) {
|
||||
List<DocumentCategory> documentCategoryList = documentCategoryMapper.selectDocumentCategoryList(documentCategory);
|
||||
return buildDeptTreeSelect(documentCategoryList);
|
||||
}
|
||||
|
||||
public List<TreeSelect> buildDeptTreeSelect(List<DocumentCategory> documentCategory)
|
||||
{
|
||||
List<DocumentCategory> docCategoryTree = buildDeptTree(documentCategory);
|
||||
return docCategoryTree.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<DocumentCategory> buildDeptTree(List<DocumentCategory> documentCategoryList)
|
||||
{
|
||||
List<DocumentCategory> returnList = new ArrayList<DocumentCategory>();
|
||||
List<String> tempList = documentCategoryList.stream().map(DocumentCategory::getId).collect(Collectors.toList());
|
||||
for (DocumentCategory documentCategory : documentCategoryList)
|
||||
{
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(documentCategory.getParentId()))
|
||||
{
|
||||
recursionFn(documentCategoryList, documentCategory);
|
||||
returnList.add(documentCategory);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
returnList = documentCategoryList;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
private void recursionFn(List<DocumentCategory> list, DocumentCategory t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<DocumentCategory> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (DocumentCategory tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<DocumentCategory> getChildList(List<DocumentCategory> list, DocumentCategory t)
|
||||
{
|
||||
List<DocumentCategory> tlist = new ArrayList<DocumentCategory>();
|
||||
Iterator<DocumentCategory> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
DocumentCategory n = (DocumentCategory) it.next();
|
||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().equals(t.getId()))
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<DocumentCategory> list, DocumentCategory t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.rzdata.web.mapper.DocumentCategoryMapper">
|
||||
|
||||
<resultMap type="DocumentCategory" id="DocumentCategoryResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="categoryName" column="category_name" />
|
||||
<result property="categoryDescription" column="category_description" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createById" column="create_by_id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateById" column="update_by_id" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="types" column="types" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDocumentCategoryVo">
|
||||
select id, category_name, category_description, parent_id, create_by, create_by_id, create_time,
|
||||
update_by, update_by_id, update_time, types from t_document_category
|
||||
</sql>
|
||||
|
||||
<select id="selectDocumentCategoryList" parameterType="DocumentCategory" resultMap="DocumentCategoryResult">
|
||||
<include refid="selectDocumentCategoryVo"/>
|
||||
<where>
|
||||
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="categoryDescription != null and categoryDescription != ''"> and category_description = #{categoryDescription}</if>
|
||||
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if>
|
||||
<if test="createById != null and createById != ''"> and create_by_id = #{createById}</if>
|
||||
<if test="updateById != null and updateById != ''"> and update_by_id = #{updateById}</if>
|
||||
<if test="types != null and types != ''"> and types = #{types}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDocumentCategoryById" parameterType="String" resultMap="DocumentCategoryResult">
|
||||
<include refid="selectDocumentCategoryVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDocumentCategory" parameterType="DocumentCategory">
|
||||
insert into t_document_category
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name,</if>
|
||||
<if test="categoryDescription != null">category_description,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createById != null and createById != ''">create_by_id,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateById != null">update_by_id,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="types != null">types,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
<if test="categoryDescription != null">#{categoryDescription},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createById != null and createById != ''">#{createById},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateById != null">#{updateById},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="types != null">#{types},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDocumentCategory" parameterType="DocumentCategory">
|
||||
update t_document_category
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="categoryDescription != null">category_description = #{categoryDescription},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
||||
<if test="createById != null and createById != ''">create_by_id = #{createById},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateById != null">update_by_id = #{updateById},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="types != null">types = #{types},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDocumentCategoryById" parameterType="String">
|
||||
delete from t_document_category where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDocumentCategoryByIds" parameterType="String">
|
||||
delete from t_document_category where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -18,10 +18,14 @@
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="docCategoryId" column="doc_category_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDocumentVo">
|
||||
select doc_id, doc_code, doc_name, doc_type, doc_principals, doc_resp_dept, doc_source, doc_status, doc_url, create_by, create_time, update_by, update_time from t_document
|
||||
select doc_id, doc_code, doc_name, doc_type, doc_principals, doc_resp_dept,
|
||||
doc_source, doc_status, doc_url, create_by, create_time,
|
||||
update_by, update_time, remark, doc_category_id from t_document
|
||||
</sql>
|
||||
|
||||
<select id="selectDocumentList" parameterType="Document" resultMap="DocumentResult">
|
||||
@ -34,6 +38,7 @@
|
||||
<if test="docRespDept != null and docRespDept != ''"> and doc_resp_dept = #{docRespDept}</if>
|
||||
<if test="docSource != null and docSource != ''"> and doc_source = #{docSource}</if>
|
||||
<if test="docStatus != null and docStatus != ''"> and doc_status = #{docStatus}</if>
|
||||
<if test="docCategoryId != null and docCategoryId != ''"> and doc_category_id = #{docCategoryId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -58,6 +63,8 @@
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="docCategoryId != null">doc_category_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="docId != null">#{docId},</if>
|
||||
@ -73,6 +80,8 @@
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="docCategoryId != null">#{doc_category_id},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -91,6 +100,8 @@
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="docCategoryId != null">docCategoryId = #{doc_category_id},</if>
|
||||
</trim>
|
||||
where doc_id = #{docId}
|
||||
</update>
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.rzdata.common.config;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 雪花算法订单号生成
|
||||
* @author lanhai
|
||||
*/
|
||||
@Configuration
|
||||
public class SnowflakeConfig {
|
||||
|
||||
@Value("${application.datacenterId}")
|
||||
private Long datacenterId;
|
||||
|
||||
@Value("${application.workerId}")
|
||||
private Long workerId;
|
||||
|
||||
@Bean
|
||||
public Snowflake snowflake() {
|
||||
return new Snowflake(workerId, datacenterId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.rzdata.common.core.domain;
|
||||
|
||||
import com.rzdata.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档资源分类管理对象 t_document_category
|
||||
*
|
||||
* @author spongepan
|
||||
* @date 2024-08-27
|
||||
*/
|
||||
@Data
|
||||
public class DocumentCategory extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private String id;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
/** 分类描述 */
|
||||
@Excel(name = "分类描述")
|
||||
private String categoryDescription;
|
||||
|
||||
/** 父分类ID,如果是一级分类,则为空 */
|
||||
@Excel(name = "父分类ID,如果是一级分类,则为空")
|
||||
private String parentId;
|
||||
|
||||
/** 创建人id */
|
||||
@Excel(name = "创建人id")
|
||||
private String createById;
|
||||
|
||||
/** 更新人id */
|
||||
@Excel(name = "更新人id")
|
||||
private String updateById;
|
||||
|
||||
/** 类型(system:系统,user:用户创建) */
|
||||
@Excel(name = "类型")
|
||||
private String types;
|
||||
|
||||
/** 文档分类id */
|
||||
@Excel(name = "文档分类id")
|
||||
private String docCategoryId;
|
||||
|
||||
/** 子分类 */
|
||||
private List<DocumentCategory> children = new ArrayList<DocumentCategory>();
|
||||
|
||||
}
|
@ -6,12 +6,14 @@ import java.util.stream.Collectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.rzdata.common.core.domain.entity.SysDept;
|
||||
import com.rzdata.common.core.domain.entity.SysMenu;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Treeselect树结构实体类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class TreeSelect implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -22,6 +24,9 @@ public class TreeSelect implements Serializable
|
||||
/** 节点名称 */
|
||||
private String label;
|
||||
|
||||
/** 类型 */
|
||||
private String types;
|
||||
|
||||
/** 子节点 */
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> children;
|
||||
@ -45,33 +50,14 @@ public class TreeSelect implements Serializable
|
||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
|
||||
public TreeSelect(DocumentCategory docCategory)
|
||||
{
|
||||
return id;
|
||||
this.id = Long.valueOf(docCategory.getId());
|
||||
this.label = docCategory.getCategoryName();
|
||||
this.types = docCategory.getTypes();
|
||||
this.children = docCategory.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<TreeSelect> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeSelect> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.rzdata.common.listener.PutObjectProgressListener;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.util.Assert;
|
||||
@ -280,4 +282,50 @@ public class FileUploadUtils
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成合并后的文件路径
|
||||
*
|
||||
* @param baseDir 文件存储根目录
|
||||
* @param fileName 上传的文件名
|
||||
* @return 合并后文件的完整路径
|
||||
*/
|
||||
public static String generateMergedFilePath(String baseDir, String fileName) {
|
||||
// 获取当前日期路径
|
||||
String datePath = DateUtil.today().replace("-", "/");
|
||||
|
||||
// 获取文件的基本名称和扩展名
|
||||
String baseName = StrUtil.subBefore(fileName, ".", true);
|
||||
String extension = StrUtil.subAfter(fileName, ".", true);
|
||||
|
||||
// 生成唯一文件名,使用时间戳
|
||||
String uniqueFileName = baseName + "_" + System.currentTimeMillis() + "." + extension;
|
||||
|
||||
// 合并文件路径: baseDir/yyyy/MM/dd/uploadId/uniqueFileName
|
||||
String mergedFilePath = Paths.get(baseDir, datePath, uniqueFileName).toString();
|
||||
|
||||
return mergedFilePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件名称
|
||||
*
|
||||
* @param baseDir 文件存储根目录
|
||||
* @param fileNames 上传的文件名
|
||||
* @return 合并后文件的完整路径
|
||||
*/
|
||||
public static String getFilePath(String baseDir, String fileNames) {
|
||||
String extension = StrUtil.subAfter(fileNames, ".", true);
|
||||
|
||||
String fileName = StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
||||
FilenameUtils.getBaseName(fileNames), Seq.getId(Seq.uploadSeqType), extension);;
|
||||
|
||||
try {
|
||||
return getPathFileName(baseDir, fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user