Browse Source

资料文档

tags/24080901
PoffyZhang 1 year ago
parent
commit
683594b8a4
13 changed files with 310 additions and 7 deletions
  1. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java
  2. +44
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/DocumentationController.java
  3. +121
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/DocumentationManage.java
  4. +16
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.java
  5. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.xml
  6. +22
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationGroupSaveDTO.java
  7. +29
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationSaveDTO.java
  8. +5
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/Documentation.java
  9. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/DocumentationGroup.java
  10. +33
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationGroupVO.java
  11. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationVO.java
  12. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/IDocumentationGroupService.java
  13. +20
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/DocumentationGroupServiceImpl.java

+ 2
- 1
pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java View File

@@ -27,7 +27,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
"com.ningdatech.pmapi.expert.controller", "com.ningdatech.pmapi.expert.controller",
"com.ningdatech.pmapi.sms.controller", "com.ningdatech.pmapi.sms.controller",
"com.ningdatech.pmapi.workbench.controller", "com.ningdatech.pmapi.workbench.controller",
"com.ningdatech.pmapi.ding.controller"
"com.ningdatech.pmapi.ding.controller",
"com.ningdatech.pmapi.filemanage.controller"
}) })
public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {




+ 44
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/DocumentationController.java View File

@@ -2,11 +2,17 @@ package com.ningdatech.pmapi.filemanage.controller;


import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.filemanage.manage.DocumentationManage; import com.ningdatech.pmapi.filemanage.manage.DocumentationManage;
import com.ningdatech.pmapi.filemanage.model.dto.DocumentationGroupSaveDTO;
import com.ningdatech.pmapi.filemanage.model.dto.DocumentationSaveDTO;
import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam; import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam;
import com.ningdatech.pmapi.filemanage.model.vo.DocumentationGroupVO;
import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO; import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;


/** /**
* @Classname DocumentationController * @Classname DocumentationController
@@ -18,12 +24,50 @@ import org.springframework.web.bind.annotation.*;
@AllArgsConstructor @AllArgsConstructor
@Api(tags = "档案管理-资料文档控制器") @Api(tags = "档案管理-资料文档控制器")
@RequestMapping("/api/v1/file-manage/documentation") @RequestMapping("/api/v1/file-manage/documentation")
@Validated
public class DocumentationController { public class DocumentationController {


private final DocumentationManage documentationManage; private final DocumentationManage documentationManage;


@GetMapping("/group/list")
@ApiOperation(value = "分组列表", notes = "分组列表")
public List<DocumentationGroupVO> groupList(){
return documentationManage.groupList();
}

@PostMapping("/group/add")
@ApiOperation(value = "分组添加", notes = "分组添加")
public String addGroup(@Validated @RequestBody DocumentationGroupSaveDTO dto){
return documentationManage.addGroup(dto);
}

@PostMapping("/group/delete/{id}")
@ApiOperation(value = "分组删除", notes = "分组删除")
public String deleteGroup(@PathVariable Long id){
return documentationManage.deleteGroup(id);
}

@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "文档列表", notes = "文档列表")
public PageVo<DocumentationVO> list(@ModelAttribute DocumentationListParam param){ public PageVo<DocumentationVO> list(@ModelAttribute DocumentationListParam param){
return documentationManage.list(param); return documentationManage.list(param);
} }

@GetMapping("/detail/{id}")
@ApiOperation(value = "文档详情", notes = "文档详情")
public DocumentationVO detail(@PathVariable Long id){
return documentationManage.detail(id);
}

@PostMapping("/add")
@ApiOperation(value = "文档添加", notes = "文档添加")
public String addDoc(@Validated @RequestBody DocumentationSaveDTO dto){
return documentationManage.addDoc(dto);
}

@PostMapping("/delete/{id}")
@ApiOperation(value = "文档删除", notes = "文档删除")
public String deleteDoc(@PathVariable Long id){
return documentationManage.deleteDoc(id);
}
} }

+ 121
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/DocumentationManage.java View File

@@ -3,15 +3,28 @@ package com.ningdatech.pmapi.filemanage.manage;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.model.PageVo;
import com.ningdatech.file.entity.File;
import com.ningdatech.file.service.FileService;
import com.ningdatech.pmapi.filemanage.model.dto.DocumentationGroupSaveDTO;
import com.ningdatech.pmapi.filemanage.model.dto.DocumentationSaveDTO;
import com.ningdatech.pmapi.filemanage.model.entity.Documentation; import com.ningdatech.pmapi.filemanage.model.entity.Documentation;
import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup;
import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam; import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam;
import com.ningdatech.pmapi.filemanage.model.vo.DocumentationGroupVO;
import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO; import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO;
import com.ningdatech.pmapi.filemanage.service.IDocumentationGroupService;
import com.ningdatech.pmapi.filemanage.service.IDocumentationService; import com.ningdatech.pmapi.filemanage.service.IDocumentationService;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -29,6 +42,20 @@ public class DocumentationManage {


private final IDocumentationService documentationService; private final IDocumentationService documentationService;


private final IDocumentationGroupService documentationGroupService;

private final FileService fileService;

/**
*
* @return
*/
public List<DocumentationGroupVO> groupList() {
List<DocumentationGroup> list = documentationGroupService.list();

return list.stream().map(g -> BeanUtil.copyProperties(g,DocumentationGroupVO.class)).collect(Collectors.toList());
}

/** /**
* 文档列表 * 文档列表
* @param param * @param param
@@ -49,4 +76,98 @@ public class DocumentationManage {


return PageVo.of(vos,page.getTotal()); return PageVo.of(vos,page.getTotal());
} }

/**
* 增加分组
* @param dto
* @return
*/
public String addGroup(DocumentationGroupSaveDTO dto) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
if(documentationGroupService.count(Wrappers.lambdaQuery(DocumentationGroup.class)
.eq(DocumentationGroup::getName,dto.getName())) > 0){
throw new BizException("此分组名 已经存在");
}

DocumentationGroup documentationGroup = BeanUtil.copyProperties(dto, DocumentationGroup.class);
documentationGroup.setCreateBy(user.getRealName());
documentationGroup.setCreateOn(LocalDateTime.now());
if(documentationGroupService.save(documentationGroup)){
return "添加成功";
}
return "添加失败";
}

/**
* 删除分组 同时删除文档
* @param id
* @return
*/
@Transactional
public String deleteGroup(Long id) {
DocumentationGroup group = documentationGroupService.getById(id);
VUtils.isTrue(Objects.isNull(group)).throwMessage("该分组不存在!");

//
documentationService.remove(Wrappers.lambdaQuery(Documentation.class)
.eq(Documentation::getGroupId, id));
documentationGroupService.removeById(id);

return "删除成功";
}

/**
* 上传文档
* @param dto
* @return
*/
public String addDoc(DocumentationSaveDTO dto) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();

Long fileId = dto.getFileId();
File file = fileService.getById(fileId);

VUtils.isTrue(Objects.isNull(file)).throwMessage("该文件不存在!");

DocumentationGroup group = documentationGroupService.getById(dto.getGroupId());

VUtils.isTrue(Objects.isNull(group)).throwMessage("分组不存在!");

Documentation documentation = new Documentation();
documentation.setCreateBy(user.getRealName());
documentation.setCreateOn(LocalDateTime.now());
documentation.setSize(Objects.nonNull(file.getSize()) ? file.getSize()/1000L : 0L);
documentation.setFileId(fileId);
documentation.setGroupId(dto.getGroupId());
documentation.setFileName(file.getOriginalFileName());
if(documentationService.save(documentation)){
documentation.setSort(documentation.getId().intValue());
documentationService.updateById(documentation);
}

return "添加成功";
}

/**
* 删除文档
* @param id
* @return
*/
public String deleteDoc(Long id) {
Documentation doc = documentationService.getById(id);
VUtils.isTrue(Objects.isNull(doc)).throwMessage("该文档不存在!");

if(documentationService.removeById(id)){
return "删除成功";
}
return "删除失败";
}

public DocumentationVO detail(Long id) {
Documentation doc = documentationService.getById(id);
if(Objects.isNull(doc)){
return null;
}
return BeanUtil.copyProperties(doc,DocumentationVO.class);
}
} }

+ 16
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.java View File

@@ -0,0 +1,16 @@
package com.ningdatech.pmapi.filemanage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup;

/**
* <p>
* Mapper 接口
* </p>
*
* @author CMM
* @since 2023-02-27
*/
public interface DocumentationGroupMapper extends BaseMapper<DocumentationGroup> {

}

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.xml View File

@@ -0,0 +1,5 @@
<?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.ningdatech.pmapi.filemanage.mapper.DocumentationGroupMapper">

</mapper>

+ 22
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationGroupSaveDTO.java View File

@@ -0,0 +1,22 @@
package com.ningdatech.pmapi.filemanage.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* @Classname Documentation
* @Description
* @Date 2023/6/6 14:41
* @Author PoffyZhang
*/
@Data
@ApiModel(value = "DocumentationGroupSaveDTO", description = "DocumentationGroupSaveDTO")
public class DocumentationGroupSaveDTO {

@ApiModelProperty("分组名")
private String name;

@ApiModelProperty("排序")
private Integer sort;
}

+ 29
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationSaveDTO.java View File

@@ -0,0 +1,29 @@
package com.ningdatech.pmapi.filemanage.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
* @Classname Documentation
* @Description
* @Date 2023/6/6 14:41
* @Author PoffyZhang
*/
@Data
@ApiModel(value = "DocumentationSaveDTO", description = "DocumentationSaveDTO")
public class DocumentationSaveDTO {

@ApiModelProperty("文档分类ID")
@NotNull(message = "请传分组ID")
private Long groupId;

@ApiModelProperty("文档ID")
@NotNull(message = "请传文档ID")
private Long fileId;

@ApiModelProperty("排序")
private Integer sort;
}

+ 5
- 2
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/Documentation.java View File

@@ -28,10 +28,10 @@ public class Documentation {
private String fileName; private String fileName;


@ApiModelProperty("上传人") @ApiModelProperty("上传人")
private String creatBy;
private String createBy;


@ApiModelProperty("上传时间") @ApiModelProperty("上传时间")
private LocalDateTime creatOn;
private LocalDateTime createOn;


@ApiModelProperty("文档大小 kb") @ApiModelProperty("文档大小 kb")
private Long size; private Long size;
@@ -39,6 +39,9 @@ public class Documentation {
@ApiModelProperty("文档分类ID") @ApiModelProperty("文档分类ID")
private Long groupId; private Long groupId;


@ApiModelProperty("文档ID")
private Long fileId;

@ApiModelProperty("排序") @ApiModelProperty("排序")
private Integer sort; private Integer sort;
} }

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/DocumentationGroup.java View File

@@ -25,10 +25,10 @@ public class DocumentationGroup {
private Long id; private Long id;


@ApiModelProperty("上传人") @ApiModelProperty("上传人")
private String creatBy;
private String createBy;


@ApiModelProperty("上传时间") @ApiModelProperty("上传时间")
private LocalDateTime creatOn;
private LocalDateTime createOn;


@ApiModelProperty("分组名") @ApiModelProperty("分组名")
private String name; private String name;


+ 33
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationGroupVO.java View File

@@ -0,0 +1,33 @@
package com.ningdatech.pmapi.filemanage.model.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
* @Classname Documentation
* @Description
* @Date 2023/6/6 14:41
* @Author PoffyZhang
*/
@Data
@ApiModel(value = "nd_documentation_group", description = "资料文档分组")
public class DocumentationGroupVO {

@ApiModelProperty("主键")
private Long id;

@ApiModelProperty("上传人")
private String createBy;

@ApiModelProperty("上传时间")
private LocalDateTime createOn;

@ApiModelProperty("分组名")
private String name;

@ApiModelProperty("排序")
private Integer sort;
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationVO.java View File

@@ -23,10 +23,10 @@ public class DocumentationVO {
private String fileName; private String fileName;


@ApiModelProperty("上传人") @ApiModelProperty("上传人")
private String creatBy;
private String createBy;


@ApiModelProperty("上传时间") @ApiModelProperty("上传时间")
private LocalDateTime creatOn;
private LocalDateTime createOn;


@ApiModelProperty("文档大小 kb") @ApiModelProperty("文档大小 kb")
private Long size; private Long size;


+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/IDocumentationGroupService.java View File

@@ -0,0 +1,9 @@
package com.ningdatech.pmapi.filemanage.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup;

public interface IDocumentationGroupService extends IService<DocumentationGroup> {


}

+ 20
- 0
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/DocumentationGroupServiceImpl.java View File

@@ -0,0 +1,20 @@
package com.ningdatech.pmapi.filemanage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.filemanage.mapper.DocumentationGroupMapper;
import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup;
import com.ningdatech.pmapi.filemanage.service.IDocumentationGroupService;
import org.springframework.stereotype.Service;

/**
* <p>
* 服务实现类
* </p>
*
* @author Poffy
* @since 2023-02-13
*/
@Service
public class DocumentationGroupServiceImpl extends ServiceImpl<DocumentationGroupMapper, DocumentationGroup> implements IDocumentationGroupService {

}

Loading…
Cancel
Save