|
|
@@ -4,15 +4,21 @@ import com.doc.biz.domain.DocTemplate;
|
|
|
import com.doc.biz.service.IDocTemplateService;
|
|
|
import com.doc.biz.service.IMongoService;
|
|
|
import com.doc.biz.vo.DocumentVO;
|
|
|
+import com.doc.biz.vo.UserVO;
|
|
|
import com.doc.common.annotation.Log;
|
|
|
+import com.doc.common.constant.Constants;
|
|
|
import com.doc.common.core.controller.BaseController;
|
|
|
import com.doc.common.core.domain.AjaxResult;
|
|
|
+import com.doc.common.core.domain.entity.SysUser;
|
|
|
import com.doc.common.core.page.TableDataInfo;
|
|
|
import com.doc.common.enums.BusinessType;
|
|
|
+import com.doc.common.enums.EventLevel;
|
|
|
import com.doc.common.utils.file.FileUtils;
|
|
|
import com.doc.common.utils.poi.ExcelUtil;
|
|
|
+import com.doc.system.service.ISysUserService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -21,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.InputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -38,6 +45,8 @@ public class DocTemplateController extends BaseController {
|
|
|
private IDocTemplateService docTemplateService;
|
|
|
@Resource
|
|
|
private IMongoService mongoService;
|
|
|
+ @Resource
|
|
|
+ private ISysUserService userService;
|
|
|
|
|
|
/**
|
|
|
* 查询文档模板列表
|
|
|
@@ -134,4 +143,77 @@ public class DocTemplateController extends BaseController {
|
|
|
return toAjax(docTemplateService.deleteDocTemplateByTmplIds(tmplIds));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("使用该文档的人员")
|
|
|
+ @GetMapping("/users")
|
|
|
+ public AjaxResult users() {
|
|
|
+ List<UserVO> result = new ArrayList<>();
|
|
|
+ userService.selectUserList(new SysUser()).forEach(u -> {
|
|
|
+ if (u.getUserId() > 1) {
|
|
|
+ UserVO vo = new UserVO();
|
|
|
+ vo.setUserId(u.getUserId());
|
|
|
+ vo.setUserName(u.getNickName());
|
|
|
+ if (u.getDept() != null) {
|
|
|
+ vo.setDeptName(u.getDept().getDeptName());
|
|
|
+ }
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件上传
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return 上传结果
|
|
|
+ */
|
|
|
+ @ApiOperation("模板文件上传-单文件")
|
|
|
+ @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
|
|
|
+ @PostMapping("/upload")
|
|
|
+ public AjaxResult uploadFile(@ApiParam(value = "文件", required = true) @RequestPart(value = "file") MultipartFile file) {
|
|
|
+ try {
|
|
|
+ DocumentVO vo = mongoService.uploadFile(file);
|
|
|
+ return upload(vo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("文件上传失败:", e);
|
|
|
+ return error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 多文件上传
|
|
|
+ *
|
|
|
+ * @param files 文件列表
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @ApiOperation("文件上传-多文件")
|
|
|
+ @PostMapping("/uploadFiles")
|
|
|
+ @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
|
|
|
+ public AjaxResult uploadFile(@ApiParam(value = "文件", required = true) @RequestPart(value = "files") List<MultipartFile> files) {
|
|
|
+ try {
|
|
|
+ mongoService.uploadFiles(files).forEach(vo -> {
|
|
|
+ upload(vo);
|
|
|
+ });
|
|
|
+ return success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private AjaxResult upload(DocumentVO vo) {
|
|
|
+ DocTemplate docTemplate = new DocTemplate();
|
|
|
+ docTemplate.setTmplName(vo.getFileName());
|
|
|
+ if (Constants.WORD_EXTENSION.contains(vo.getSuffix())) {
|
|
|
+ docTemplate.setTmplType("word");
|
|
|
+ }
|
|
|
+ if (Constants.WORD_EXTENSION.contains(vo.getSuffix())) {
|
|
|
+ docTemplate.setTmplType("excel");
|
|
|
+ }
|
|
|
+ if (Constants.WORD_EXTENSION.contains(vo.getSuffix())) {
|
|
|
+ docTemplate.setTmplType("ppt");
|
|
|
+ }
|
|
|
+ docTemplate.setFileId(vo.getFileId());
|
|
|
+ return toAjax(docTemplateService.insertDocTemplate(docTemplate));
|
|
|
+ }
|
|
|
}
|