dcs 1 year ago
parent
commit
d56665da4f

+ 46 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/controller/DocumentCategoryController.java

@@ -0,0 +1,46 @@
+package com.bosshand.virgo.file.controller;
+
+import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.file.document.DocumentService;
+import com.bosshand.virgo.file.document.model.DocumentCategory;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping({"category"})
+@Api(tags = {"合同标签"})
+public class DocumentCategoryController {
+
+    @Autowired
+    private DocumentService documentService;
+
+    @ApiOperation("保存标签")
+    @RequestMapping(value = "/category", method = RequestMethod.POST)
+    public Response saveCategory(@RequestBody DocumentCategory documentCategory) {
+        documentService.saveCategory(documentCategory);
+        return Response.ok();
+    }
+
+    @ApiOperation("获取标签")
+    @RequestMapping(value = "/category/{organizationId}/{projectId}", method = RequestMethod.GET)
+    public Response getDirectory(@PathVariable long organizationId, @PathVariable long projectId) {
+        return Response.ok(documentService.getDirectory(organizationId, projectId));
+    }
+
+    @ApiOperation("更新标签")
+    @RequestMapping(value = "/category", method = RequestMethod.PUT)
+    public Response updateCategory(@RequestBody DocumentCategory documentCategory) {
+        documentService.updateCategory(documentCategory);
+        return Response.ok();
+    }
+
+    @ApiOperation("删除标签")
+    @RequestMapping(value = "/category/{id}", method = RequestMethod.DELETE)
+    public Response deleteCategory(@PathVariable long id) {
+        documentService.deleteCategory(id);
+        return Response.ok();
+    }
+
+}

+ 37 - 287
virgo.file/src/main/java/com/bosshand/virgo/file/controller/DocumentController.java

@@ -6,278 +6,44 @@ import com.bosshand.virgo.exception.BadRequestException;
 import com.bosshand.virgo.exception.Constant;
 import com.bosshand.virgo.file.document.DocumentService;
 import com.bosshand.virgo.file.document.exception.DocumentProcessException;
-import com.bosshand.virgo.file.document.model.*;
-import com.bosshand.virgo.file.model.FileNode;
+import com.bosshand.virgo.file.document.model.BehaviorTrack;
+import com.bosshand.virgo.file.document.model.CollaborativeArchive;
+import com.bosshand.virgo.file.document.model.Document;
+import com.bosshand.virgo.file.document.model.ElementData;
+import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 @RestController
+@Api(tags = {"文档管理"})
 public class DocumentController {
 	
 	@Autowired
 	private DocumentService documentService;
-	
-	@RequestMapping(value = "/category/{parentId}", method = RequestMethod.POST)
-	public Response createCategory( @RequestBody DocumentCategory category, @PathVariable int parentId) {
-		
-		if(StringUtils.isBlank(category.getName())) {
-			throw new BadRequestException("name was empty");
-		}
-		return Response.ok( documentService.createCategory(category.getName(), parentId));
-		
-	}
-
-	@ApiOperation(value = "待转换全部文档列表", notes = "待转换全部文档列表")
-	@RequestMapping(value = "/category/adjusted", method = RequestMethod.GET)
-	public Response listAdjusted() {
-		return Response.ok(documentService.listAdjusted());
-	}
-
-	@ApiOperation(value = "获取用户上传文档列表", notes = "获取用户上传文档列表")
-	@RequestMapping(value = "/category/list", method = RequestMethod.POST)
-	public Response listCategory(@RequestBody DocumentCategory category) {
-		return Response.ok( documentService.listCategory(category));
-	}
-
-	@ApiOperation(value = "保存用户上传目录或文档", notes = "保存用户上传目录或文档")
-	@RequestMapping(value = "/category/create", method = RequestMethod.POST)
-	public Response saveCategory(@RequestBody DocumentCategory category) {
-		return Response.ok(documentService.saveCategory(category));
-	}
-
-	@ApiOperation(value = "多个文件夹id返回对应数据", notes = "多个文件夹id返回对应数据")
-	@RequestMapping(value = "/category/folder", method = RequestMethod.POST)
-	public Response folder(@RequestBody Long [] ids) {
-		return Response.ok(documentService.folder(ids));
-	}
-
-	@ApiOperation(value = "获取层级", notes = "获取层级")
-	@RequestMapping(value = "/category/directory", method = RequestMethod.POST)
-	public Response getDirectory(@RequestBody DocumentCategory documentCategory) {
-		return Response.ok(documentService.getDirectory(documentCategory));
-	}
-
-	@RequestMapping(value = "/category/{parentId}", method = RequestMethod.GET)
-	public Response listCategory(@PathVariable int parentId) {
-		
-		Map<String, Object> ret = new HashMap<String, Object>();
-		DocumentCategory current = null;
-		if(parentId == DocumentCategory.ROOT_ID ) {
-			current = DocumentCategory.getRoot();
-		}else {
-			current = documentService.getCategory(parentId);
-		}
-			
-		ret.put("category", current );
-		ret.put("sub", documentService.listCategory( parentId));
-		return Response.ok( ret);
-		
-	}
-
-	@ApiOperation(value = "更新操作", notes = "更新操作")
-	@RequestMapping(value = "/category", method = RequestMethod.PUT)
-	public Response updateCategory(@RequestBody DocumentCategory category) {
-		
-		if(StringUtils.isBlank(category.getName())) {
-			throw new BadRequestException("name was empty");
-		}
-		return Response.ok(documentService.updateCategory(category));
-		
-	}
-	
-	@RequestMapping(value = "/category/{parentId}/template", method = RequestMethod.GET)
-	public Response getTemplateList(@PathVariable int parentId) {
-		
-		DocumentCategory category = null;
-		if(parentId == DocumentCategory.ROOT_ID ) {
-			category = DocumentCategory.getRoot();
-		}else {
-			category = documentService.getCategory(parentId);
-		}
-		if(category == null) {
-			throw new BadRequestException("Incorrect category");
-		}
-		return Response.ok(documentService.listTemplate(category.getId()));
-		
-	}
-	
-	@RequestMapping(value = "/category/{parentId}/{currPage}/{pageSize}/template", method = RequestMethod.GET)
-	public Response getTemplateList(@PathVariable int parentId, @PathVariable int currPage, @PathVariable int pageSize) {
-		
-		DocumentCategory category = null;
-		if(parentId == DocumentCategory.ROOT_ID ) {
-			category = DocumentCategory.getRoot();
-		}else {
-			category = documentService.getCategory(parentId);
-		}
-		if(category == null) {
-			throw new BadRequestException("Incorrect category");
-		}
-		
-		int totalCount = documentService.getTotalCount(category.getId());
-		
-		List<DocumentTemplate> list = documentService.getList(category.getId(), currPage, pageSize);
-		
-		Map<String, Object> result = new HashMap<String, Object>();
-		result.put("dataList", list);
-		result.put("totalCount", totalCount);
-		return Response.ok(result);
-		
-	}
-	
-	@RequestMapping(value = "/category/list/{ids}", method = RequestMethod.GET)
-	public Response getTemplateListByIds(@PathVariable String ids) {
-		return Response.ok(documentService.getList(ids));
-	}
-	
-	@RequestMapping(value = "/category/delete/{parentId}/template", method = RequestMethod.DELETE)
-	public Response deleteCategoryAndTemplate(@PathVariable int parentId) {
-		
-		DocumentCategory category = null;
-		if(parentId == DocumentCategory.ROOT_ID ) {
-			category = DocumentCategory.getRoot();
-		}else {
-			category = documentService.getCategory(parentId);
-		}
-		if(category == null) {
-			throw new BadRequestException("Incorrect category");
-		}
-		documentService.deleteCategoryAndTemplate(category.getId());
-		return Response.ok();
-	}
-	
-	@RequestMapping(value = "/template/{id}", method = RequestMethod.GET)
-	public Response getTemplate(@PathVariable int id) {
-		return Response.ok(documentService.getTemplate(id));
-	}
-
-	@RequestMapping(value = "/template/{id}/raw", method = RequestMethod.GET)
-	public Response getRawTemplate(@PathVariable int id, final HttpServletResponse response) {
-		
-		DocumentTemplate template = documentService.getTemplate(id);
-		if(template == null) {
-			throw new BadRequestException("Fail to get template",Constant.RET_DOCUMENT_ERROR);
-		}
-		byte[] data = null;
-		OutputStream outputStream = null;
-		try {
-			data = template.getDocument();
-			outputStream = response.getOutputStream();
-			outputStream.write(data);
-			outputStream.flush();
-		} catch (IOException e) {
-			throw new BadRequestException("Fail to write stream",Constant.RET_DOCUMENT_ERROR, e);
-		}finally {
-			if(outputStream != null) {
-				try {
-					outputStream.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-		return Response.ok();
-		
-	}
-
-	@RequestMapping(value = "/template/{id}/pdf", method = RequestMethod.GET)
-	public Response getTemplatePdf(@PathVariable int id, final HttpServletResponse response) {
-		
-		byte[] data = null;
-		OutputStream outputStream = null;
-		try {
-			data = documentService.renderTemplatePdf(id);
-			outputStream = response.getOutputStream();
-			outputStream.write(data);
-			outputStream.flush();
-		} catch (IOException | DocumentProcessException e) {
-			throw new BadRequestException("Fail to process",Constant.RET_DOCUMENT_ERROR, e);
-		}finally {
-			if(outputStream != null) {
-				try {
-					outputStream.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-		return Response.ok();
-		
-	}
-
-	
-	@RequestMapping(value = "/category/{parentId}/template", method = RequestMethod.POST)
-	public Response uploadTemplate(@RequestBody DocumentTemplate template, @PathVariable int parentId) {
-		if(template.getFileNode() == null) {
-			throw new BadRequestException("Incorrect file node");
-		}
-
-		try {
-			template = documentService.importDocument(template.getFileNode(), parentId, template.getName(), template.getComment(), template.getTag());
-		} catch (DocumentProcessException e) {
-			throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
-		}
-		
-		return Response.ok(template);
-	}
-	
-	@RequestMapping(value = "/updateDocumentTemplate", method = RequestMethod.PUT)
-	public Response updateDocumentTemplate(@RequestBody DocumentTemplate template) {
-		if (template.getFileNode() == null) {
-			throw new BadRequestException("Incorrect file node");
-		}
-
-		try {
-			template = documentService.updateDocumentTemplate(template);
-		} catch (DocumentProcessException e) {
-			throw new BadRequestException("Incorrect file kannode", Constant.RET_DOCUMENT_ERROR, e);
-		}
-
-		return Response.ok(template);
-	}
-	
-	//////////////////////////////////////////////////////////////////////////
-	// !!!TEST!!!
-	@ApiOperation(value = "test", notes = "test")
-	@RequestMapping(value = "/test", method = RequestMethod.POST)
-	public Response test(@ApiParam(name = "uploadFile", required = true) MultipartFile uploadFile) {
-		try {
-			FileNode fileNode = new FileNode();
-			fileNode.setId(454);
-			documentService.importDocument(fileNode, 1, "test", "test", "test");
-		} catch (DocumentProcessException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		return Response.ok();
-	}
 
 	//////////////////////////////////////////////////////////////////////////
 	//Document
+	/////////////////////////////////////////////////////////////////////////
+
 	@RequestMapping(value = "/document", method = RequestMethod.POST)
 	public Response createDocument(@RequestBody Document document) {
-		
 		try {
 			documentService.createDocument(document);
 		} catch (DocumentProcessException e) {
 			throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
 		}
-		
 		return Response.ok(document);
 	}
 
 	@RequestMapping(value = "/document/{id}", method = RequestMethod.GET)
-	public Response getDocument( @PathVariable int id ) {
-		
+	public Response getDocument(@PathVariable int id ) {
 		Document document = null;
 		try {
 			document = documentService.getDocument(id);
@@ -285,12 +51,10 @@ public class DocumentController {
 			throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
 		}
 		return Response.ok(document);
-		
 	}
-	
+
 	@RequestMapping(value = "/document/{id}/pdf.pdf", method = RequestMethod.GET)
-	public Response renderDocumentToPdf( @PathVariable int id , final HttpServletResponse response) {
-		
+	public Response renderDocumentToPdf(@PathVariable int id , final HttpServletResponse response) {
 		byte[] data = null;
 		OutputStream outputStream = null;
 		try {
@@ -309,12 +73,10 @@ public class DocumentController {
 			}
 		}
 		return Response.ok();
-		
 	}
-	
+
 	@RequestMapping(value = "/document/{id}/{projectName}/pdf.pdf", method = RequestMethod.GET)
-	public Response renderDocumentToPdf2( @PathVariable int id , @PathVariable String projectName , final HttpServletResponse response) {
-		
+	public Response renderDocumentToPdf2(@PathVariable int id , @PathVariable String projectName , final HttpServletResponse response) {
 		byte[] data = null;
 		OutputStream outputStream = null;
 		try {
@@ -333,7 +95,6 @@ public class DocumentController {
 			}
 		}
 		return Response.ok();
-		
 	}
 
 	@RequestMapping(value = "/document/test", method = RequestMethod.GET)
@@ -345,8 +106,8 @@ public class DocumentController {
 	public Response renderDocumentTestOnly(@PathVariable int id) {
 		return Response.ok(documentService.renderDocumentTestOnly(id));
 	}
-	
-	// 归档
+
+	@ApiOperation("文件归档")
 	@RequestMapping(value = "/archived/{documentId}/{projectName}", method = RequestMethod.GET)
 	public Response archived(@PathVariable int documentId , @PathVariable String projectName) {
 		return Response.ok(documentService.archived(documentId, projectName));
@@ -399,8 +160,7 @@ public class DocumentController {
 	}
 
 	@RequestMapping(value = "/document/{id}/render", method = RequestMethod.GET)
-	public Response renderDocument( @PathVariable int id , final HttpServletResponse response) {
-		
+	public Response renderDocument(@PathVariable int id , final HttpServletResponse response) {
 		byte[] data = null;
 		OutputStream outputStream = null;
 		try {
@@ -419,15 +179,18 @@ public class DocumentController {
 			}
 		}
 		return Response.ok();
-		
 	}
+
+
 	//////////////////////////////////////////////////////////////////////////
 	//Element data
+	//////////////////////////////////////////////////////////////////////////
+
 	@RequestMapping(value = "/elementdata/{id}", method = RequestMethod.GET)
 	public Response createElementData(@PathVariable int elementDataId) {
 		return Response.ok(documentService.getElementData(elementDataId));
 	}
-	
+
 	@RequestMapping(value = "/elementdata/", method = RequestMethod.POST)
 	public Response createOrUpdateElementData(@RequestBody ElementData elementData) {
 		try {
@@ -436,18 +199,18 @@ public class DocumentController {
 			throw new BadRequestException("update element failed",Constant.RET_DOCUMENT_ERROR, e);
 		}
 	}
-	
+
 	@RequestMapping(value = "/document/fuzzy/{name}", method = RequestMethod.GET)
 	public Response getFuzzyByName(@PathVariable String name) {
 		return Response.ok(documentService.getFuzzy(name));
 	}
-	
+
 	@RequestMapping(value = "/document/delete/{id}", method = RequestMethod.DELETE)
 	public Response deleteDocumentTemplate(@PathVariable int id) {
 		documentService.deleteDocumentTemplate(id);
 		return Response.ok();
 	}
-	
+
 	@RequestMapping(value = "/document/update", method = RequestMethod.PUT)
 	public Response updateDocument(@RequestBody Document document) {
 		try {
@@ -455,10 +218,9 @@ public class DocumentController {
 		} catch (DocumentProcessException e) {
 			throw new BadRequestException("Incorrect file kannode", Constant.RET_DOCUMENT_ERROR, e);
 		}
-
 		return Response.ok(document);
 	}
-	
+
 	@ApiOperation(value = "word转换成pdf", notes = "word转换成pdf")
 	@RequestMapping(value = "/document/conversionToPdf/{documentIds}", method = RequestMethod.GET)
 	public Response conversionToPdf(@PathVariable String documentIds) {
@@ -469,39 +231,28 @@ public class DocumentController {
 		}
 		return Response.fail(20000, "失败!");
 	}
-	
-//	@ApiOperation(value = "预览pdf", notes = "预览pdf")
-//	@RequestMapping(value = "/document/previewPdf/{documentTemplateId}", method = RequestMethod.GET)
-//	public Response previewPdf(@PathVariable int documentTemplateId) {
-//		try {
-//			return Response.ok(documentService.previewTemplatePdf(documentTemplateId));
-//		} catch (DocumentProcessException e) {
-//			e.printStackTrace();
-//		}
-//		return Response.fail(20000, "失败!");
-//	}
-	
-	@ApiOperation(value = "获取流程完成的文档pdf", notes = "获取流程完成的文档pdf")
+
+	@ApiOperation("获取流程完成的文档pdf")
 	@RequestMapping(value = "/document/pdf/{documentIds}", method = RequestMethod.GET)
 	public Response getDocumentToPdf(@PathVariable String documentIds) {
 		return Response.ok(documentService.getDocumentIds(documentIds));
 	}
 
-	@ApiOperation(value = "新增用户在文档的行为轨迹", notes = "新增用户在文档的行为轨迹")
+	@ApiOperation("新增用户在文档的行为轨迹")
 	@RequestMapping(value = "/document/behaviorTrack", method = RequestMethod.POST)
 	public Response saveBehaviorTrack(@RequestBody BehaviorTrack behaviorTrack) {
 		documentService.saveBehaviorTrack(behaviorTrack);
 		return Response.ok();
-	} 
-	
-	@ApiOperation(value = "获取某个用户操作文档的行为轨迹", notes = "获取某个用户操作文档的行为轨迹")
+	}
+
+	@ApiOperation("获取某个用户操作文档的行为轨迹")
 	@RequestMapping(value = "/document/behaviorTrack/{userId}", method = RequestMethod.GET)
 	public Response getBehaviorTrackByUserId(@PathVariable String userId) {
 		return Response.ok(documentService.getBehaviorTrackListByUserId(userId));
-	} 
-	
+	}
+
 	//////////////////////////////////////////////////////////////////////////
-	
+
 	@ApiOperation(value = "retrievers", notes = "retrievers")
 	@RequestMapping(value = "/document/retrievers/{retrievers}", method = RequestMethod.GET)
 	public Response retrievers(@PathVariable String retrievers) {
@@ -514,18 +265,17 @@ public class DocumentController {
 		return Response.ok(ret);
 	}
 
-
-	@ApiOperation(value = "保存协同归档", notes = "保存协同归档")
+	@ApiOperation("保存协同归档")
 	@RequestMapping(value = "/collaborativeArchive", method = RequestMethod.POST)
 	public Response insertCollaborativeArchive(@RequestBody CollaborativeArchive collaborativeArchive){
 		CollaborativeArchive archive = documentService.insertCollaborativeArchive(collaborativeArchive);
 		return Response.ok(archive);
 	}
 
-	@ApiOperation(value = "查询协同归档", notes = "查询协同归档")
+	@ApiOperation("查询协同归档")
 	@RequestMapping(value = "/collaborativeArchive/query", method = RequestMethod.POST)
 	public Response  getListByCollaborativeArchive(@RequestBody CollaborativeArchive collaborativeArchive){
 		return Response.ok(documentService.getListByCollaborativeArchive(collaborativeArchive));
 	}
-	
+
 }

+ 138 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/controller/DocumentTemplateController.java

@@ -0,0 +1,138 @@
+package com.bosshand.virgo.file.controller;
+
+import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.exception.BadRequestException;
+import com.bosshand.virgo.exception.Constant;
+import com.bosshand.virgo.file.document.DocumentService;
+import com.bosshand.virgo.file.document.exception.DocumentProcessException;
+import com.bosshand.virgo.file.document.model.DocumentTemplate;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping({"template"})
+@Api(tags = {"合同模板"})
+public class DocumentTemplateController {
+
+    @Autowired
+    private DocumentService documentService;
+
+    @ApiOperation("模板分页")
+    @RequestMapping(value = "/{categoryId}/{currPage}/{pageSize}", method = RequestMethod.GET)
+    public Response getTemplateList(@PathVariable int categoryId, @PathVariable int currPage, @PathVariable int pageSize) {
+        List<DocumentTemplate> list = documentService.getList(categoryId, currPage, pageSize);
+        int totalCount = documentService.getTotalCount(categoryId);
+        Map<String, Object> result = new HashMap<String, Object>();
+        result.put("dataList", list);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
+    @ApiOperation("获取模板")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public Response getTemplate(@PathVariable Long id) {
+        return Response.ok(documentService.getTemplate(id));
+    }
+
+    @ApiOperation("获取模板流")
+    @RequestMapping(value = "/raw/{id}", method = RequestMethod.GET)
+    public Response getRawTemplate(@PathVariable int id, final HttpServletResponse response) {
+        DocumentTemplate template = documentService.getTemplate(id);
+        if (template == null) {
+            throw new BadRequestException("Fail to get template", Constant.RET_DOCUMENT_ERROR);
+        }
+        byte[] data = null;
+        OutputStream outputStream = null;
+        try {
+            data = template.getDocument();
+            outputStream = response.getOutputStream();
+            outputStream.write(data);
+            outputStream.flush();
+        } catch (IOException e) {
+            throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+        return Response.ok();
+    }
+
+    @ApiOperation("预览模板PDF")
+    @RequestMapping(value = "/pdf/{id}", method = RequestMethod.GET)
+    public Response getTemplatePdf(@PathVariable int id, final HttpServletResponse response) {
+        byte[] data = null;
+        OutputStream outputStream = null;
+        try {
+            data = documentService.renderTemplatePdf(id);
+            outputStream = response.getOutputStream();
+            outputStream.write(data);
+            outputStream.flush();
+        } catch (IOException | DocumentProcessException e) {
+            throw new BadRequestException("Fail to process", Constant.RET_DOCUMENT_ERROR, e);
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+        return Response.ok();
+    }
+
+    @ApiOperation("导入模板")
+    @RequestMapping(value = "/import", method = RequestMethod.POST)
+    public Response uploadTemplate(@RequestBody DocumentTemplate template) {
+        if (template.getFileNode() == null) {
+            throw new BadRequestException("Incorrect file node");
+        }
+        try {
+            template = documentService.importDocument(template.getFileNode(), template.getCategoryId(), template.getName(), template.getComment());
+        } catch (DocumentProcessException e) {
+            throw new BadRequestException("Incorrect file kannode", Constant.RET_DOCUMENT_ERROR, e);
+        }
+        return Response.ok(template);
+    }
+
+    @ApiOperation("更新模板")
+    @RequestMapping(value = "/update", method = RequestMethod.PUT)
+    public Response updateTemplate(@RequestBody DocumentTemplate template) {
+        if (template.getFileNode() == null) {
+            throw new BadRequestException("Incorrect file node");
+        }
+        try {
+            template = documentService.updateDocumentTemplate(template);
+        } catch (DocumentProcessException e) {
+            throw new BadRequestException("Incorrect file kannode", Constant.RET_DOCUMENT_ERROR, e);
+        }
+        return Response.ok(template);
+    }
+
+    @ApiOperation(value = "删除模版", notes = "删除模版")
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public Response deleteTemplate(@PathVariable long id) {
+        documentService.deleteDocumentTemplate(id);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "删除标签下模版", notes = "删除标签下模版")
+    @RequestMapping(value = "/category/{categoryId}", method = RequestMethod.DELETE)
+    public Response deleteCategoryAndTemplate(@PathVariable long categoryId) {
+        documentService.deleteCategoryAndTemplate(categoryId);
+        return Response.ok();
+    }
+
+}

+ 1 - 1
virgo.file/src/main/java/com/bosshand/virgo/file/document/DocumentProcessor.java

@@ -11,7 +11,7 @@ public interface DocumentProcessor {
 	
 	boolean support(DocumentType type);
 	
-	DocumentTemplate importDocument(byte[] documentData, int categoryId,String name, String comment) throws DocumentProcessException;
+	DocumentTemplate importDocument(byte[] documentData, long categoryId,String name, String comment) throws DocumentProcessException;
 	
 	byte[] renderDocument(Document document, DocumentTemplate template) throws DocumentProcessException;
 

+ 79 - 305
virgo.file/src/main/java/com/bosshand/virgo/file/document/DocumentService.java

@@ -20,7 +20,6 @@ import com.bosshand.virgo.file.seal.model.Seal;
 import com.bosshand.virgo.file.seal.model.SealRegister;
 import com.bosshand.virgo.file.seal.model.SealRegisterKey;
 import com.bosshand.virgo.file.seal.model.SealRequest;
-import com.bosshand.virgo.file.service.ApiClient;
 import com.bosshand.virgo.file.service.FileManagerService;
 import com.bosshand.virgo.file.util.AliyunOSSUtil;
 import com.bosshand.virgo.file.util.Doc2Pdf;
@@ -77,192 +76,76 @@ public class DocumentService {
     @Autowired
     SealDao sealDao;
 
-    @Autowired
-    ApiClient apiClient;
-
     @Autowired
     DocumentFileArchivedDao documentFileArchivedDao;
 
     @Autowired
     CollaborativeArchiveDao collaborativeArchiveDao;
 
-    public CollaborativeArchive insertCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
-        collaborativeArchiveDao.insert(collaborativeArchive);
-        return collaborativeArchive;
-    }
-
-    public List<CollaborativeArchive> getListByCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
-        return collaborativeArchiveDao.getList(collaborativeArchive);
-    }
-
-
-    //////////////////////////////////////////////////////////////////
-    // Category management
-    //////////////////////////////////////////////////////////////////
-    public DocumentCategory createCategory(String name, int parentId) throws ServiceException {
-
-        if (parentId != DocumentCategory.ROOT_ID) {
-            DocumentCategory category = documentCategoryDao.get(parentId);
-            if (category == null) {
-                throw new ServiceException("Incorrect parent category");
+    /**
+     * 合同标签
+     */
+    private List<DocumentCategory> getChildren(List<DocumentCategory> list, long parentId) {
+        List<DocumentCategory> tree = new ArrayList<DocumentCategory>();
+        for (DocumentCategory category : list) {
+            if (category.getParentId() == parentId) {
+                tree.add(category);
             }
         }
-
-        if (StringUtils.isBlank(name)) {
-            throw new ServiceException("Incorrect category name");
-        }
-
-        DocumentCategory newCategory = new DocumentCategory();
-        newCategory.setName(name);
-        newCategory.setParentId(parentId);
-
-        documentCategoryDao.create(newCategory);
-
-        return newCategory;
-    }
-
-    public DocumentCategory getCategory(int id) throws ServiceException {
-
-        DocumentCategory newCategory = documentCategoryDao.get(id);
-
-        if (newCategory == null) {
-            throw new ServiceException("No such category");
+        for (DocumentCategory node : tree) {
+            node.setChildren(getChildren(list, node.getId()));
         }
-
-        return newCategory;
-
+        return tree;
     }
 
-    public List<DocumentCategory> listCategory(int id) throws ServiceException {
-
-        if (id != DocumentCategory.ROOT_ID) {
-            DocumentCategory category = documentCategoryDao.get(id);
-            if (category == null) {
-                throw new ServiceException("Incorrect parent category");
-            }
+    public List<DocumentCategory> getDirectory(long organizationId, long projectId){
+        List<DocumentCategory> List = documentCategoryDao.getRoot(organizationId, projectId);
+        List<DocumentCategory> allList = documentCategoryDao.getList(organizationId, projectId);
+        for(DocumentCategory category : List){
+            category.setChildren(this.getChildren(allList, category.getId()));
         }
-
-        return documentCategoryDao.list(id);
+        return List;
     }
 
-    public DocumentCategory updateCategory(int id, String name) throws ServiceException {
-
-        if (id == DocumentCategory.ROOT_ID) {
-            throw new ServiceException("can not update root category");
-        }
-
+    public int deleteCategory(long id) {
         DocumentCategory category = documentCategoryDao.get(id);
         if (category == null) {
             throw new ServiceException("Incorrect  category");
         }
-        category.setName(name);
-
-        documentCategoryDao.update(category);
-
-        return category;
+        return documentCategoryDao.delete(id);
     }
 
-    public void deleteCategory(int id) throws ServiceException {
-
-        if (id == DocumentCategory.ROOT_ID) {
-            throw new ServiceException("can not update root category");
-        }
-
-        DocumentCategory category = documentCategoryDao.get(id);
-        if (category == null) {
-            throw new ServiceException("Incorrect  category");
-        }
-
-        documentCategoryDao.delete(category);
-
+    public int saveCategory(DocumentCategory documentCategory) {
+        return documentCategoryDao.insert(documentCategory);
     }
 
-    public void deleteCategoryAndTemplate(int id) throws ServiceException {
-
-        if (id == DocumentCategory.ROOT_ID) {
-            throw new ServiceException("can not update root category");
-        }
+    public int updateCategory(DocumentCategory documentCategory) {
+        return documentCategoryDao.update(documentCategory);
+    }
 
-        DocumentCategory category = documentCategoryDao.get(id);
+    /**
+     * 合同模板
+     */
+    public void deleteCategoryAndTemplate(long categoryId) throws ServiceException {
+        DocumentCategory category = documentCategoryDao.get(categoryId);
         if (category == null) {
             throw new ServiceException("Incorrect  category");
         }
-
-        documentCategoryDao.delete(category);
-
-        documentTemplateDao.deleteByCategoryId(id);
-
-        List<DocumentCategory> list = documentCategoryDao.list(id);
-
+        documentCategoryDao.delete(categoryId);
+        documentTemplateDao.deleteByCategoryId(categoryId);
+        List<DocumentCategory> list = documentCategoryDao.getParentId(categoryId);
         for (DocumentCategory documentCategory : list) {
-            if (documentCategory.getParentId() == id) {
+            if (documentCategory.getParentId() == categoryId) {
                 deleteCategoryAndTemplate(documentCategory.getId());
             }
         }
-
-    }
-
-    public DocumentCategory saveCategory(DocumentCategory documentCategory) {
-        documentCategoryDao.create(documentCategory);
-        return documentCategory;
-    }
-
-    public DocumentCategory updateCategory(DocumentCategory documentCategory) {
-        documentCategoryDao.update(documentCategory);
-        return documentCategory;
-    }
-
-    public List<DocumentCategory> listCategory(DocumentCategory documentCategory) {
-        return documentCategoryDao.getByList(documentCategory);
-    }
-
-    public List<DocumentCategory> listAdjusted() {
-        return documentCategoryDao.listAdjusted();
-    }
-
-    public List<DocumentCategory> folder(Long[] ids) {
-        return documentCategoryDao.folder(ids);
-    }
-
-    public List<DocumentCategory> getDirectory(DocumentCategory documentCategory) {
-
-        int parentId = documentCategory.getParentId();
-        List<DocumentCategory> list = documentCategoryDao.list(parentId);
-
-        documentCategory.setParentId(0);
-        List<DocumentCategory> byList = documentCategoryDao.getByList(documentCategory);
-        for(DocumentCategory dc : list){
-            dc.setChildren(getChildren(byList, dc.getId()));
-        }
-        return list;
-    }
-
-    private List<DocumentCategory> getChildren(List<DocumentCategory> list, int parentId) {
-
-        List<DocumentCategory> tree = new ArrayList<DocumentCategory>();
-
-        for (DocumentCategory category : list) {
-            if (category.getParentId() == parentId) {
-                tree.add(category);
-            }
-        }
-
-        for (DocumentCategory node : tree) {
-            node.setChildren(getChildren(list, node.getId()));
-        }
-
-        return tree;
     }
 
-
-    //////////////////////////////////////////////////////////////////
-    // Document Template management
-    //////////////////////////////////////////////////////////////////
-    public void deleteDocumentTemplate(int id) {
+    public void deleteDocumentTemplate(long id) {
         documentTemplateDao.delete(id);
     }
 
-    public DocumentTemplate getTemplate(int id) {
+    public DocumentTemplate getTemplate(long id) {
         return documentTemplateDao.get(id);
     }
 
@@ -272,79 +155,13 @@ public class DocumentService {
 
     public List<DocumentTemplate> getList(int categoryId, int currPage, int pageSize) {
         Map<String, Object> data = new HashMap<String, Object>();
-        data.put("id", categoryId);
+        data.put("categoryId", categoryId);
         data.put("currIndex", (currPage - 1) * pageSize);
         data.put("pageSize", pageSize);
-        List<DocumentTemplate> list = documentTemplateDao.getList(data);
-        if (list.size() > 0) {
-            return sort(list);
-        }
-        return list;
+        return documentTemplateDao.getList(data);
     }
 
-    private List<DocumentTemplate> sort(List<DocumentTemplate> list) {
-
-        List<DocumentTemplate> ls = new ArrayList<>();
-
-        List<DocumentTemplate> ll = new ArrayList<>();
-
-        for (DocumentTemplate t : list) {
-            String name = t.getName();
-            if (name.length() < 8) {
-                ll.add(t);
-                continue;
-            }
-            String num = name.substring(0, 8);
-            if (StringUtils.isNumeric(num)) {
-                ls.add(t);
-            } else {
-                ll.add(t);
-            }
-        }
-
-        int listS = ls.size();
-        for (int i = 0; i < listS - 1; i++) {
-            for (int i1 = 0; i1 < listS - 1 - i; i1++) {
-                DocumentTemplate dt1 = ls.get(i1);
-                DocumentTemplate dt2 = ls.get(i1 + 1);
-                String d1 = dt1.getName().substring(0, 8);
-                String d2 = dt2.getName().substring(0, 8);
-                d1 = Integer.parseInt(d1.substring(0, 1)) == 0 ? d1.substring(1, 8) : d1.substring(0, 8);
-                d2 = Integer.parseInt(d2.substring(0, 1)) == 0 ? d2.substring(1, 8) : d2.substring(0, 8);
-                if (Integer.parseInt(d1) > Integer.parseInt(d2)) {
-                    ls.set(i1, dt2);
-                    ls.set(i1 + 1, dt1);
-                }
-            }
-        }
-        if (ll.size() > 0) {
-            ls.addAll(ll);
-        }
-        return ls;
-    }
-
-    public List<DocumentTemplate> getList(String ids) {
-        String[] split = ids.split(",");
-        List<Integer> documentTemplateIds = new ArrayList<>();
-        for (int i = 0; i < split.length; i++) {
-            documentTemplateIds.add(Integer.parseInt(split[i]));
-        }
-        return documentTemplateDao.getIds(documentTemplateIds);
-    }
-
-    public List<DocumentTemplate> listTemplate(int categoryId) {
-        List<DocumentTemplate> list = documentTemplateDao.list(categoryId);
-
-        if (list.size() > 0) {
-            return sort(list);
-        }
-
-        return list;
-    }
-
-    public DocumentTemplate importDocument(FileNode fileNode, int categoryId, String documentName, String comment,
-                                           String tag) throws DocumentProcessException {
-
+    public DocumentTemplate importDocument(FileNode fileNode, long categoryId, String documentName, String comment) throws DocumentProcessException {
         if (fileNode == null) {
             throw new DocumentProcessException("File node was null");
         }
@@ -352,31 +169,24 @@ public class DocumentService {
         if (fileNode == null) {
             throw new DocumentProcessException("File node not found");
         }
-
         log.info("Start import document with name " + fileNode.getName());
-
         byte[] data = fileManagerService.getByte(fileNode.getId());
         if (data == null) {
             throw new DocumentProcessException("No data for import");
         }
-
         DocumentProcessor processor = DocumentProcessFactory.getProcessor(data);
         if (processor == null) {
             throw new DocumentProcessException("No processor match");
         }
-
         DocumentTemplate template = processor.importDocument(data, categoryId, documentName, comment);
         if (template != null) {
             documentTemplateDao.create(template);
         }
-
         return template;
     }
 
     public DocumentTemplate updateDocumentTemplate(DocumentTemplate tp) throws DocumentProcessException {
-
         FileNode fileNode = tp.getFileNode();
-
         if (fileNode == null) {
             throw new DocumentProcessException("File node was null");
         }
@@ -384,21 +194,16 @@ public class DocumentService {
         if (fileNode == null) {
             throw new DocumentProcessException("File node not found");
         }
-
         byte[] data = fileManagerService.getByte(fileNode.getId());
         if (data == null) {
             throw new DocumentProcessException("No data for import");
         }
-
         DocumentProcessor processor = DocumentProcessFactory.getProcessor(data);
         if (processor == null) {
             throw new DocumentProcessException("No processor match");
         }
-
         DocumentTemplate documentTemplate = documentTemplateDao.get(tp.getId());
-
         DocumentTemplate template = processor.importDocument(data, documentTemplate.getCategoryId(), tp.getName(), documentTemplate.getComment());
-
         if (documentTemplate != null) {
             documentTemplate.setName(template.getName());
             documentTemplate.setUpdateTime(template.getUpdateTime());
@@ -413,23 +218,19 @@ public class DocumentService {
         return documentTemplate;
     }
 
-
     public byte[] renderTemplatePdf(int documentTemplateId) throws DocumentProcessException {
-
         DocumentTemplate documentTemplate = documentTemplateDao.get(documentTemplateId);
-
         if (documentTemplate == null) {
             throw new DocumentProcessException("Template not found");
         }
         return DocumentProcessFactory.getProcessor(documentTemplate.getDocumentType()).renderDocumentTemplateToPDF(documentTemplate);
-
     }
 
     //////////////////////////////////////////////////////////////////
     // Document management
     //////////////////////////////////////////////////////////////////
-    public Document createDocument(Document document) throws DocumentProcessException {
 
+    public Document createDocument(Document document) throws DocumentProcessException {
         if (document == null) {
             throw new DocumentProcessException("Empty document");
         }
@@ -442,11 +243,9 @@ public class DocumentService {
         document.setCreateTime(new Date());
         documentDao.insert(document);
         return document;
-
     }
 
     public Document updateDocument(Document document) throws DocumentProcessException {
-
         if (document == null) {
             throw new DocumentProcessException("Empty document");
         }
@@ -459,21 +258,17 @@ public class DocumentService {
         document.setCreateTime(new Date());
         documentDao.update(document);
         return document;
-
     }
 
     public Document getDocument(int documentId) throws DocumentProcessException {
-
         Document document = documentDao.get(documentId);
         if (document == null) {
             throw new DocumentProcessException("document not found");
         }
         return document;
-
     }
 
     public byte[] renderDocument(int documentId) throws DocumentProcessException {
-
         Document document = getDocument(documentId);
         if (document == null) {
             throw new DocumentProcessException("Can not find the document");
@@ -483,15 +278,15 @@ public class DocumentService {
             throw new DocumentProcessException("Can not find the data template");
         }
         return DocumentProcessFactory.getProcessor(document.getDocumentType()).renderDocument(document, template);
-
     }
 
     public byte[] archivedFile(int documentId) {
-//		DocumentFileArchived archived = documentFileArchivedDao.getDocumentId(documentId);
-//		if (archived != null) {
-//			return AliyunOSSUtil.getByte(archived.getNode());
-//		}
-//		return null;
+		/*DocumentFileArchived archived = documentFileArchivedDao.getDocumentId(documentId);
+		if (archived != null) {
+			return AliyunOSSUtil.getByte(archived.getNode());
+		}
+		return null;*/
+
         byte[] pdf = null;
         try {
             pdf = RenderDocumentToPdf(documentId, "");
@@ -560,25 +355,22 @@ public class DocumentService {
     }
 
     public byte[] RenderDocumentToPdf(int documentId, String projectName) throws DocumentProcessException {
-        //return PdfWatermark.watermark(RenderDocumentToPdf(documentId), projectName + "档案文件");
+        /*return PdfWatermark.watermark(RenderDocumentToPdf(documentId), projectName + "档案文件");*/
         return RenderDocumentToPdf(documentId);
     }
 
     public byte[] RenderDocumentToPdf(int documentId) throws DocumentProcessException {
-
         Document document = getDocument(documentId);
         if (document == null) {
             throw new DocumentProcessException("Can not find the document");
         }
-
         DocumentTemplate template = getTemplate(document.getDocumentTemplateId());
         if (template == null) {
             throw new DocumentProcessException("Can not find the data template");
         }
-
         byte[] pdfdata = DocumentProcessFactory.getProcessor(document.getDocumentType()).renderToPDF(document, template);
 
-        // add seal
+        // 加入印章
         byte[] sealToPdf = null;
         List<Map<String, Object>> list = getSealKayWord(documentId);
         if (list.size() > 0) {
@@ -587,12 +379,13 @@ public class DocumentService {
             sealToPdf = pdfdata;
         }
 
-        // add behavior track
-        //List<String> behaviorTrack = getBehaviorTrack(documentId);
+        // 加入操作轨迹
+        /*List<String> behaviorTrack = getBehaviorTrack(documentId);
+        return PdfKeywordFinder.additionalPage(sealToPdf, null, chainQRCode(documentId));*/
 
-        //return PdfKeywordFinder.additionalPage(sealToPdf, null, chainQRCode(documentId));
         return sealToPdf;
     }
+
     //////////////////////////////////////////////////////////////////
     // ElementData management
     //////////////////////////////////////////////////////////////////
@@ -602,9 +395,7 @@ public class DocumentService {
     }
 
     public ElementData saveOrUpdateElementData(ElementData elementData) throws DocumentProcessException {
-
         getDocument(elementData.getDocumentId());
-
         if (elementData.getId() != -1 && elementData.getId() != 0) {
             elementData = getElementData(elementData.getId());
             if (elementData == null) {
@@ -618,14 +409,18 @@ public class DocumentService {
         return elementData;
     }
 
-    // Fuzzy Query
+    /**
+     * 模糊查询
+     */
     public List<DocumentTemplate> getFuzzy(String name) {
         DocumentTemplate documentTemplate = new DocumentTemplate();
         documentTemplate.setName(name);
         return documentTemplateDao.getFuzzy(documentTemplate);
     }
 
-    // Get PDF file
+    /**
+     * 获取pdf文件
+     */
     public List<FileNode> getDocumentIds(String documentIds) {
         List<DocumentFile> dfs = documentFileDao.getListByDocumentIds(documentIds.split(","));
         List<Integer> fileNodeIds = new ArrayList<>();
@@ -633,7 +428,9 @@ public class DocumentService {
         return fileNodeDao.getIds(fileNodeIds);
     }
 
-    // Conversion to PDF file
+    /**
+     * 判断转换成pdf文件
+     */
     public boolean conversionToPdf(String documentIds) throws DocumentProcessException {
         String[] ids = documentIds.split(",");
         List<DocumentFile> list = documentFileDao.getListByDocumentIds(ids);
@@ -644,7 +441,6 @@ public class DocumentService {
             }
             return isS;
         }
-
         List<String> dList = new ArrayList<>();
         for (int i = 0; i < ids.length; i++) {
             boolean find = false;
@@ -669,20 +465,16 @@ public class DocumentService {
     }
 
     public boolean renderDocumentToPdf(int documentId) throws DocumentProcessException {
-
         Document document = getDocument(documentId);
         DocumentTemplate template = getTemplate(document.getDocumentTemplateId());
         if (template == null) {
             throw new DocumentProcessException("Can not find the data template");
         }
-
         byte[] dm = DocumentProcessFactory.getProcessor(document.getDocumentType()).renderDocument(document, template);
         byte[] pdfdata = Doc2Pdf.doc2pdf(dm, getBehaviorTrack(document.getId()), chainQRCode(document.getId()));
-
         if (pdfdata == null) {
             throw new DocumentProcessException("License have failed");
         }
-
         byte[] sealToPdf = null;
         List<Map<String, Object>> list = getSealKayWord(documentId);
         if (list.size() > 0) {
@@ -690,21 +482,20 @@ public class DocumentService {
         } else {
             sealToPdf = pdfdata;
         }
-
         InputStream is = null;
         if (sealToPdf != null) {
             is = new ByteArrayInputStream(sealToPdf);
         }
-
         FileNode fileNode = fileManagerService.create(is, document.getName() + ".pdf", 201);
         DocumentFile documentFile = new DocumentFile();
         documentFile.setDocumentId(documentId);
         documentFile.setFileNodeId(fileNode.getId());
         return documentFileDao.insert(documentFile) == 1;
-
     }
 
-    // seal part
+    /**
+     * 印章区域
+     */
     private List<Map<String, Object>> getSealKayWord(int documentId) {
         List<Map<String, Object>> list = new ArrayList<>();
         List<SealRequest> sealRequestList = sealRequestDao.getByDocumentId(documentId);
@@ -730,7 +521,9 @@ public class DocumentService {
         return list;
     }
 
-    // behavior track
+    /**
+     * 操作轨迹
+     */
     private List<String> getBehaviorTrack(int documentId) {
         List<String> string = new ArrayList<>();
         List<BehaviorTrack> list = behaviorTrackDao.getDocumentId(documentId);
@@ -750,12 +543,13 @@ public class DocumentService {
         return string;
     }
 
-    // chain QRCode
+    /**
+     * 生成区块链二维码
+     */
     private byte[] chainQRCode(int documentId) {
-        String url = JSONObject.parseObject(apiClient.get()).getString("coordinationUrl");
         byte[] qr = null;
         try {
-            qr = QRCodeUtil.getQRCodeBytes(url + "/manager/chain/" + documentId);
+            qr = QRCodeUtil.getQRCodeBytes("https://www.waywish.com/manager/chain/" + documentId);
         } catch (Exception e) {
             throw new ServiceException("qr is fail");
         }
@@ -769,35 +563,6 @@ public class DocumentService {
     public List<BehaviorTrack> getBehaviorTrackListByUserId(String userId) {
         return behaviorTrackDao.getByUserId(userId);
     }
-//
-//	public FileNode previewTemplatePdf(int documentTemplateId) throws DocumentProcessException {
-//
-//		DocumentTemplate documentTemplate = documentTemplateDao.get(documentTemplateId);
-//
-//		byte[] dm = DocumentProcessFactory.getProcessor(documentTemplate.getDocumentType()).renderDocumentTemplateToPDF(documentTemplate);
-//		if(dm == null){
-//			throw new DocumentProcessException("License have failed");
-//		}
-//		
-//		InputStream is = null;
-//		try {
-//			is = new ByteArrayInputStream(dm);
-//			FileNode fileNode = null;
-//			if (is != null) {
-//				fileNode = fileManagerService.create(is, documentTemplate.getName() + ".pdf", 201);
-//			}
-//			return fileNode;
-//		}
-//		finally {
-//			if(is != null) {
-//				try {
-//					is.close();
-//				} catch (IOException e) {
-//				}	
-//			}
-//		}
-//
-//	}
 
     public Map<String, String> getContextData(String dataRetriever) {
         Map<String, String> ret = new HashMap<String, String>();
@@ -813,5 +578,14 @@ public class DocumentService {
         return ret;
     }
 
+    public CollaborativeArchive insertCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
+        collaborativeArchiveDao.insert(collaborativeArchive);
+        return collaborativeArchive;
+    }
+
+    public List<CollaborativeArchive> getListByCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
+        return collaborativeArchiveDao.getList(collaborativeArchive);
+    }
+
 
 }

+ 14 - 10
virgo.file/src/main/java/com/bosshand/virgo/file/document/dao/DocumentCategoryDao.java

@@ -7,15 +7,19 @@ import java.util.List;
 
 @Mapper
 public interface DocumentCategoryDao {
-	
-	public List<DocumentCategory> getList();
-	public List<DocumentCategory> getByList(DocumentCategory category);
-	public List<DocumentCategory> list(int id);
-	public List<DocumentCategory> listAdjusted();
-	public DocumentCategory get(int id);
-	public void create(DocumentCategory category);
-	public void update(DocumentCategory category);
-	public void delete(DocumentCategory category);
-	public List<DocumentCategory> folder(Long[] ids);
+
+    DocumentCategory get(long id);
+
+    List<DocumentCategory> getRoot(long organizationId, long projectId);
+
+    List<DocumentCategory> getParentId(long parentId);
+
+    List<DocumentCategory> getList(long organizationId, long projectId);
+
+    int insert(DocumentCategory category);
+
+    int update(DocumentCategory category);
+
+    int delete(long id);
 
 }

+ 21 - 13
virgo.file/src/main/java/com/bosshand/virgo/file/document/dao/DocumentTemplateDao.java

@@ -8,18 +8,26 @@ import java.util.Map;
 
 
 @Mapper
-public interface DocumentTemplateDao  {
-	
-	void delete(long id);
-	int create(DocumentTemplate template);
-	int update(DocumentTemplate template);	
-	DocumentTemplate get(int id);
-	List<DocumentTemplate> list(int categoryId);
-	void deleteByCategoryId(int categoryId);
-	List<DocumentTemplate> getFuzzy(DocumentTemplate documentTemplate);
-	int getTotalCount(int categoryId);
-	List<DocumentTemplate> getList(Map<String, Object> data);
-	List<DocumentTemplate> getIds(List<Integer> ids);
-	List<DocumentTemplate> getByList();
+public interface DocumentTemplateDao {
+
+    int delete(long id);
+
+    int create(DocumentTemplate template);
+
+    int update(DocumentTemplate template);
+
+    DocumentTemplate get(long id);
+
+    List<DocumentTemplate> list(long categoryId);
+
+    void deleteByCategoryId(long categoryId);
+
+    List<DocumentTemplate> getFuzzy(DocumentTemplate documentTemplate);
+
+    int getTotalCount(int categoryId);
+
+    List<DocumentTemplate> getList(Map<String, Object> data);
+
+    List<DocumentTemplate> getByList();
 
 }

+ 37 - 73
virgo.file/src/main/java/com/bosshand/virgo/file/document/model/DocumentCategory.java

@@ -1,45 +1,49 @@
 package com.bosshand.virgo.file.document.model;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
+/**
+ * 合同标签
+ */
 public class DocumentCategory {
 	
-	public static final int ROOT_ID = -1;
-	
-	public static final String ROOT_NAME = "root";
-	
-	private int id;
-	
+	private long id;
+
+	/**
+	 * 父id
+	 */
 	private int parentId;
-	
+
+	/**
+	 * 名称
+	 */
 	private String name;
 
+	/**
+	 * 描述
+	 */
+	private String description;
+
+	/**
+	 * 组织id
+	 */
 	private long organizationId;
 
+	/**
+	 * 项目id
+	 */
 	private long projectId;
 
-	private long userId;
-
-	private long fileId;
-
-	private long useFileId;
+	/**
+	 * 子结构
+	 */
+	private List<DocumentCategory> children;
 
-	private long state;
-
-	@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
-	private Date date;
-
-	private List<DocumentCategory> children = new ArrayList<DocumentCategory>();
-
-	public int getId() {
+	public long getId() {
 		return id;
 	}
 
-	public void setId(int id) {
+	public void setId(long id) {
 		this.id = id;
 	}
 
@@ -59,6 +63,14 @@ public class DocumentCategory {
 		this.name = name;
 	}
 
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
 	public long getOrganizationId() {
 		return organizationId;
 	}
@@ -75,54 +87,6 @@ public class DocumentCategory {
 		this.projectId = projectId;
 	}
 
-	public long getUserId() {
-		return userId;
-	}
-
-	public void setUserId(long userId) {
-		this.userId = userId;
-	}
-
-	public long getFileId() {
-		return fileId;
-	}
-
-	public void setFileId(long fileId) {
-		this.fileId = fileId;
-	}
-
-	public long getUseFileId() {
-		return useFileId;
-	}
-
-	public void setUseFileId(long useFileId) {
-		this.useFileId = useFileId;
-	}
-
-	public long getState() {
-		return state;
-	}
-
-	public void setState(long state) {
-		this.state = state;
-	}
-
-	public Date getDate() {
-		return date;
-	}
-
-	public void setDate(Date date) {
-		this.date = date;
-	}
-
-	public static DocumentCategory getRoot() {
-		DocumentCategory root = new DocumentCategory();
-		root.setId(ROOT_ID);
-		root.setName(ROOT_NAME);
-		root.setParentId(ROOT_ID);
-		return root;
-	}
-
 	public List<DocumentCategory> getChildren() {
 		return children;
 	}

+ 123 - 141
virgo.file/src/main/java/com/bosshand/virgo/file/document/model/DocumentTemplate.java

@@ -1,149 +1,131 @@
 package com.bosshand.virgo.file.document.model;
 
-import java.util.Date;
-import java.util.List;
-
 import com.bosshand.virgo.file.document.DocumentType;
 import com.bosshand.virgo.file.model.FileNode;
 
+import java.util.Date;
+import java.util.List;
+
 public class DocumentTemplate {
-	
-	private int id;
-	
-	private int categoryId;
-	
-	private String html;
-
-	private String name;
-
-	private String comment;
-
-	private Date createTime;
-	
-	private Date updateTime;
-
-	private DocumentType documentType;
-
-	private String elementJson;  
-	
-	private String tag;
-	
-	private FileNode fileNode;
-	
-	public String getTag() {
-		return tag;
-	}
-
-	public void setTag(String tag) {
-		this.tag = tag;
-	}
-
-	private byte[] document;
-
-	private List<TemplateElement> elementList;
-	
-	public int getId() {
-		return id;
-	}
-
-	public void setId(int id) {
-		this.id = id;
-	}
-
-	public int getCategoryId() {
-		return categoryId;
-	}
-
-	public void setCategoryId(int categoryId) {
-		this.categoryId = categoryId;
-	}
-
-	public String getHtml() {
-		return html;
-	}
-
-	public void setHtml(String html) {
-		this.html = html;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public byte[] getDocument() {
-		return document;
-	}
-
-	public void setDocument(byte[] document) {
-		this.document = document;
-	}
-
-	public String getComment() {
-		return comment;
-	}
-
-	public void setComment(String comment) {
-		this.comment = comment;
-	}
-
-	public Date getCreateTime() {
-		return createTime;
-	}
-
-	public void setCreateTime(Date createTime) {
-		this.createTime = createTime;
-	}
-	
-	public Date getUpdateTime() {
-		return updateTime;
-	}
-
-	public void setUpdateTime(Date updateTime) {
-		this.updateTime = updateTime;
-	}
-
-	public String getElementJson() {
-		return elementJson;
-	}
-
-	public void setElementJson(String elementJson) {
-		this.elementJson = elementJson;
-	}
-
-	public List<TemplateElement> getElementList() {
-		return elementList;
-	}
-
-	public void setElementList(List<TemplateElement> elementList) {
-		this.elementList = elementList;
-	}
-
-	public DocumentType getDocumentType() {
-		return documentType;
-	}
-
-	public void setDocumentType(DocumentType documentType) {
-		this.documentType = documentType;
-	}
-
-	public FileNode getFileNode() {
-		return fileNode;
-	}
-
-	public void setFileNode(FileNode fileNode) {
-		this.fileNode = fileNode;
-	}
-
-	@Override
-	public String toString() {
-		return "DocumentTemplate [id=" + id + ", categoryId=" + categoryId + ", name=" + name + ", comment=" + comment
-				+ ", createTime=" + createTime + ", updateTime=" + updateTime + ", documentType=" + documentType
-				+ ", elementJson=" + elementJson + ", tag=" + tag + ", fileNode=" + fileNode + "]";
-	}
-	
+
+    private long id;
+
+    private long categoryId;
+
+    private String html;
+
+    private String name;
+
+    private String comment;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    private DocumentType documentType;
+
+    private String elementJson;
+
+    private FileNode fileNode;
+
+    private byte[] document;
+
+    private List<TemplateElement> elementList;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getCategoryId() {
+        return categoryId;
+    }
+
+    public void setCategoryId(long categoryId) {
+        this.categoryId = categoryId;
+    }
+
+    public String getHtml() {
+        return html;
+    }
+
+    public void setHtml(String html) {
+        this.html = html;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public byte[] getDocument() {
+        return document;
+    }
+
+    public void setDocument(byte[] document) {
+        this.document = document;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getElementJson() {
+        return elementJson;
+    }
+
+    public void setElementJson(String elementJson) {
+        this.elementJson = elementJson;
+    }
+
+    public List<TemplateElement> getElementList() {
+        return elementList;
+    }
+
+    public void setElementList(List<TemplateElement> elementList) {
+        this.elementList = elementList;
+    }
+
+    public DocumentType getDocumentType() {
+        return documentType;
+    }
+
+    public void setDocumentType(DocumentType documentType) {
+        this.documentType = documentType;
+    }
+
+    public FileNode getFileNode() {
+        return fileNode;
+    }
+
+    public void setFileNode(FileNode fileNode) {
+        this.fileNode = fileNode;
+    }
 
 }

+ 4 - 3
virgo.file/src/main/java/com/bosshand/virgo/file/document/type/AbstractDocumentProcessor.java

@@ -33,7 +33,7 @@ public abstract class AbstractDocumentProcessor implements DocumentProcessor{
 	protected abstract String htmlView(byte[] documentData) throws DocumentProcessException;
 
 	@Override
-	public DocumentTemplate importDocument(byte[] documentData, int categoryId, String name, String comment) throws DocumentProcessException{
+	public DocumentTemplate importDocument(byte[] documentData, long categoryId, String name, String comment) throws DocumentProcessException{
 
 		if(documentData == null) {
 			throw new DocumentProcessException("byte data was null");
@@ -114,23 +114,24 @@ public abstract class AbstractDocumentProcessor implements DocumentProcessor{
 		return doRender(template, model);
 	}
 
+	@Override
 	public byte[] renderDocument(DocumentTemplate template)throws DocumentProcessException , Exception{
 		return doRender(template);
 	}
 
 	protected abstract byte[] pdfView(byte[] documentData) throws DocumentProcessException;
 
+	@Override
 	public byte[] renderToPDF(Document document, DocumentTemplate template) throws DocumentProcessException{
-
 		byte[] documentData = renderDocument(document, template);
 		if(documentData == null) {
 			throw new DocumentProcessException("Render failed");
 		}
 		log.info("start render document to pdf");
-
 		return pdfView(documentData);
 	}
 
+	@Override
 	public byte[] renderWeeklyToPDF(DocumentTemplate template, List<ElementDataWeekly> elementDataWeeklyList)
 			throws DocumentProcessException{
 		Map<Object, Object> model = new HashMap<Object, Object>();

+ 0 - 14
virgo.file/src/main/java/com/bosshand/virgo/file/service/ApiClient.java

@@ -1,14 +0,0 @@
-package com.bosshand.virgo.file.service;
-
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-@FeignClient("virgo-api")
-public interface ApiClient {
-
-    @RequestMapping(value = "/configurationUrl/url", method = RequestMethod.GET)
-    public String get();
-
-}

+ 48 - 80
virgo.file/src/main/resources/mapper/DocumentCategoryMapper.xml

@@ -1,85 +1,53 @@
 <!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- 
-<mapper namespace="com.bosshand.virgo.file.document.dao.DocumentCategoryDao">
-
-<resultMap type="com.bosshand.virgo.file.document.model.DocumentCategory" id="DocumentCategoryResult" >
-		<id column="id" property="id"/>
-		<id column="parentId" property="parentId"/>
-		<id column="name" property="name"/>
-		<id column="organizationId" property="organizationId"/>
-		<id column="projectId" property="projectId"/>
-		<id column="userId" property="userId"/>
-		<id column="fileId" property="fileId"/>
-		<id column="useFileId" property="useFileId"/>
-		<id column="state" property="state"/>
-		<id column="date" property="date"/>
-</resultMap>
-
-<select id="getList" resultMap="DocumentCategoryResult">
-	 select * from metadata_document_category where organizationId = 0
-</select>
-
-<select id="listAdjusted" resultMap="DocumentCategoryResult">
-	select * from metadata_document_category where fileId != 0 and state = 0
-</select>
-
-<select id="getByList" resultMap="DocumentCategoryResult">
-	select * from metadata_document_category
-	<where>
-		<if test="organizationId!=0">and organizationId=#{organizationId}</if>
-		<if test="projectId!=0">and projectId=#{projectId}</if>
-		<if test="userId!=0">and userId=#{userId}</if>
-		<if test="parentId!=0">and parentId=#{parentId}</if>
-	</where>
-</select>
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
-<select id="get" resultMap="DocumentCategoryResult">
-	 select * from metadata_document_category where id = #{id}
-</select>
-
-<select id="list" resultMap="DocumentCategoryResult">
-	 select * from metadata_document_category where parentId = #{id}
-</select>
-
-<select id="folder" resultMap="DocumentCategoryResult">
-	select * from metadata_document_category
-	<choose>
-		<when test="array != null and array.length>0">
-			where id in (
-			<foreach collection="array" item="item" index="index" separator=",">
-				#{item}
-			</foreach>
-			)
-		</when>
-		<otherwise>
-			where 1=0
-		</otherwise>
-	</choose>
-</select>
-
-<delete id="delete">
-	delete from metadata_document_category where id = #{id}
-</delete>
-
-<insert id="create" parameterType="com.bosshand.virgo.file.document.model.DocumentCategory" useGeneratedKeys="true" keyProperty="id">
-	INSERT into metadata_document_category(parentId,name,organizationId,projectId,userId,fileId,date) values(#{parentId}, #{name}, #{organizationId}, #{projectId}, #{userId}, #{fileId}, now())
-</insert>
+<mapper namespace="com.bosshand.virgo.file.document.dao.DocumentCategoryDao">
 
-<update id="update">
-	update metadata_document_category
-	<trim prefix="set" suffixOverrides=",">
-		<if test="name!=null">name=#{name},</if>
-		<if test="parentId!=0">parentId=#{parentId},</if>
-		<if test="organizationId!=0">organizationId=#{organizationId},</if>
-		<if test="projectId!=0">projectId=#{projectId},</if>
-		<if test="userId!=0">userId=#{userId},</if>
-		<if test="fileId!=0">fileId=#{fileId},</if>
-		<if test="useFileId!=0">useFileId=#{useFileId},</if>
-		<if test="state!=0">state=#{state},</if>
-	</trim>
-	WHERE id=#{id}
-</update>
+    <resultMap type="com.bosshand.virgo.file.document.model.DocumentCategory" id="DocumentCategoryResult">
+        <id column="id" property="id"/>
+        <id column="parentId" property="parentId"/>
+        <id column="name" property="name"/>
+        <id column="description" property="description"/>
+        <id column="organizationId" property="organizationId"/>
+        <id column="projectId" property="projectId"/>
+    </resultMap>
+
+    <select id="get" resultMap="DocumentCategoryResult">
+        select * from metadata_document_category where id = #{id}
+    </select>
+
+    <select id="getRoot" resultMap="DocumentCategoryResult">
+        select * from metadata_document_category where organizationId = #{organizationId} and projectId = #{projectId} and parentId = -1
+    </select>
+
+    <select id="getParentId" resultMap="DocumentCategoryResult">
+        select * from metadata_document_category where parentId = #{parentId}
+    </select>
+
+    <select id="getList" resultMap="DocumentCategoryResult">
+        select * from metadata_document_category where organizationId = #{organizationId} and projectId = #{projectId}
+    </select>
+
+    <delete id="delete">
+        delete from metadata_document_category where id = #{id}
+    </delete>
+
+    <insert id="insert" parameterType="com.bosshand.virgo.file.document.model.DocumentCategory" useGeneratedKeys="true" keyProperty="id">
+        INSERT into metadata_document_category(`parentId`, `name`, `description`, `organizationId`, `projectId`)
+        values (#{parentId}, #{name}, #{description}, #{organizationId}, #{projectId})
+    </insert>
+
+    <update id="update">
+        update metadata_document_category
+        <trim prefix="set" suffixOverrides=",">
+            <if test="name!=null">name=#{name},</if>
+            <if test="description!=null">description=#{description},</if>
+            <if test="parentId!=0">parentId=#{parentId},</if>
+            <if test="organizationId!=0">organizationId=#{organizationId},</if>
+            <if test="projectId!=0">projectId=#{projectId},</if>
+        </trim>
+        WHERE id=#{id}
+    </update>
 
 </mapper>

+ 3 - 21
virgo.file/src/main/resources/mapper/DocumentTemplateMapper.xml

@@ -14,7 +14,6 @@
 		<id column="updateTime" property="updateTime"/>
 		<id column="documentType" property="documentType"/>
 		<id column="elementJson" property="elementJson"/>
-		<id column="tag" property="tag"/>
 		<id column="document" property="document"/>
 </resultMap>
 
@@ -27,7 +26,7 @@
 </select>
 
 <select id="getList" parameterType="map" resultMap="DocumentTemplateResult">
-	select * from metadata_document_template where categoryId = #{id} limit #{currIndex} , #{pageSize}
+	select * from metadata_document_template where categoryId = #{categoryId} limit #{currIndex} , #{pageSize}
 </select>
 
 <select id="getByList" resultMap="DocumentTemplateResult">
@@ -38,23 +37,6 @@
 	 select * from metadata_document_template where categoryId = #{id}
 </select>
 
-<select id="getIds" parameterType="list" resultMap="DocumentTemplateResult">
-	select * from metadata_document_template
-	<choose>
-		<when test="list != null and list.size>0">
-			where id in (
-			<foreach collection="list" item="item" index="index"
-				separator=",">
-				#{item}
-			</foreach>
-			)
-		</when>
-		<otherwise>
-			where 1=0
-		</otherwise>
-	</choose>
-</select>
-
 <delete id="delete">
 	delete from metadata_document_template where id = #{id}
 </delete>
@@ -69,7 +51,8 @@
 </select>
 
 <insert id="create" parameterType="com.bosshand.virgo.file.document.model.DocumentTemplate" useGeneratedKeys="true" keyProperty="id">
-	INSERT into metadata_document_template(categoryId, name, html, comment, createTime, updateTime, documentType, elementJson, tag, document) values(#{categoryId}, #{name}, #{html}, #{comment}, #{createTime}, #{updateTime}, #{documentType}, #{elementJson}, #{tag}, #{document})
+	INSERT into metadata_document_template(categoryId, name, html, comment, createTime, updateTime, documentType, elementJson, document)
+	values(#{categoryId}, #{name}, #{html}, #{comment}, #{createTime}, #{updateTime}, #{documentType}, #{elementJson}, #{document})
 </insert>
 
 <update id="update" parameterType="com.bosshand.virgo.file.document.model.DocumentTemplate">
@@ -83,7 +66,6 @@
 		<if test="updateTime!=null">updateTime=#{updateTime},</if>
 		<if test="documentType!=null">documentType=#{documentType},</if>
 		<if test="elementJson!=null">elementJson=#{elementJson},</if>
-		<if test="tag!=null">tag=#{tag},</if>
 		<if test="document!=null">document=#{document},</if>
 	</trim>
 	where id = #{id}