dcs 1 year ago
parent
commit
638b90c2cf

+ 9 - 14
virgo.file/src/main/java/com/bosshand/virgo/file/controller/DocumentController.java

@@ -32,6 +32,7 @@ public class DocumentController {
 	//Document
 	/////////////////////////////////////////////////////////////////////////
 
+	@ApiOperation("创建文档")
 	@RequestMapping(value = "/document", method = RequestMethod.POST)
 	public Response createDocument(@RequestBody Document document) {
 		try {
@@ -42,6 +43,7 @@ public class DocumentController {
 		return Response.ok(document);
 	}
 
+	@ApiOperation("获取文档")
 	@RequestMapping(value = "/document/{id}", method = RequestMethod.GET)
 	public Response getDocument(@PathVariable int id ) {
 		Document document = null;
@@ -53,6 +55,7 @@ public class DocumentController {
 		return Response.ok(document);
 	}
 
+	@ApiOperation("获取PDF文档")
 	@RequestMapping(value = "/document/{id}/pdf.pdf", method = RequestMethod.GET)
 	public Response renderDocumentToPdf(@PathVariable int id , final HttpServletResponse response) {
 		byte[] data = null;
@@ -186,12 +189,14 @@ public class DocumentController {
 	//Element data
 	//////////////////////////////////////////////////////////////////////////
 
+	@ApiOperation("获取文档数据")
 	@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)
+	@ApiOperation("保存或更新文档数据")
+	@RequestMapping(value = "/elementdata", method = RequestMethod.POST)
 	public Response createOrUpdateElementData(@RequestBody ElementData elementData) {
 		try {
 			return Response.ok(documentService.saveOrUpdateElementData(elementData));
@@ -200,17 +205,7 @@ public class DocumentController {
 		}
 	}
 
-	@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();
-	}
-
+	@ApiOperation("更新文档")
 	@RequestMapping(value = "/document/update", method = RequestMethod.PUT)
 	public Response updateDocument(@RequestBody Document document) {
 		try {
@@ -221,7 +216,7 @@ public class DocumentController {
 		return Response.ok(document);
 	}
 
-	@ApiOperation(value = "word转换成pdf", notes = "word转换成pdf")
+	@ApiOperation("word转换成pdf")
 	@RequestMapping(value = "/document/conversionToPdf/{documentIds}", method = RequestMethod.GET)
 	public Response conversionToPdf(@PathVariable String documentIds) {
 		try {
@@ -253,7 +248,7 @@ public class DocumentController {
 
 	//////////////////////////////////////////////////////////////////////////
 
-	@ApiOperation(value = "retrievers", notes = "retrievers")
+	@ApiOperation("retrievers")
 	@RequestMapping(value = "/document/retrievers/{retrievers}", method = RequestMethod.GET)
 	public Response retrievers(@PathVariable String retrievers) {
 		Map<String, Map<String, String>> ret = new HashMap<String, Map<String, String>>();

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

@@ -130,8 +130,8 @@ public class DocumentTemplateController {
 
     @ApiOperation(value = "删除标签下模版", notes = "删除标签下模版")
     @RequestMapping(value = "/category/{categoryId}", method = RequestMethod.DELETE)
-    public Response deleteCategoryAndTemplate(@PathVariable long categoryId) {
-        documentService.deleteCategoryAndTemplate(categoryId);
+    public Response deleteTemplateUnderCategory(@PathVariable long categoryId) {
+        documentService.deleteTemplateUnderCategory(categoryId);
         return Response.ok();
     }
 

+ 19 - 16
virgo.file/src/main/java/com/bosshand/virgo/file/document/DocumentService.java

@@ -107,12 +107,18 @@ public class DocumentService {
         return List;
     }
 
-    public int deleteCategory(long id) {
+    public void deleteCategory(long id) {
         DocumentCategory category = documentCategoryDao.get(id);
         if (category == null) {
             throw new ServiceException("Incorrect  category");
         }
-        return documentCategoryDao.delete(id);
+        documentCategoryDao.delete(id);
+        List<DocumentCategory> list = documentCategoryDao.getParentId(id);
+        for (DocumentCategory documentCategory : list) {
+            if (documentCategory.getParentId() == id) {
+                deleteCategory(documentCategory.getId());
+            }
+        }
     }
 
     public int saveCategory(DocumentCategory documentCategory) {
@@ -126,17 +132,16 @@ public class DocumentService {
     /**
      * 合同模板
      */
-    public void deleteCategoryAndTemplate(long categoryId) throws ServiceException {
+    public void deleteTemplateUnderCategory(long categoryId) throws ServiceException {
         DocumentCategory category = documentCategoryDao.get(categoryId);
         if (category == null) {
             throw new ServiceException("Incorrect  category");
         }
-        documentCategoryDao.delete(categoryId);
         documentTemplateDao.deleteByCategoryId(categoryId);
         List<DocumentCategory> list = documentCategoryDao.getParentId(categoryId);
         for (DocumentCategory documentCategory : list) {
             if (documentCategory.getParentId() == categoryId) {
-                deleteCategoryAndTemplate(documentCategory.getId());
+                deleteTemplateUnderCategory(documentCategory.getId());
             }
         }
     }
@@ -153,6 +158,15 @@ public class DocumentService {
         return documentTemplateDao.getTotalCount(categoryId);
     }
 
+    /**
+     * 名称模糊查询模板
+     */
+    public List<DocumentTemplate> getFuzzy(String name) {
+        DocumentTemplate documentTemplate = new DocumentTemplate();
+        documentTemplate.setName(name);
+        return documentTemplateDao.getFuzzy(documentTemplate);
+    }
+
     public List<DocumentTemplate> getList(int categoryId, int currPage, int pageSize) {
         Map<String, Object> data = new HashMap<String, Object>();
         data.put("categoryId", categoryId);
@@ -395,7 +409,6 @@ 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) {
@@ -405,19 +418,9 @@ public class DocumentService {
         } else {
             elementDataDao.insert(elementData);
         }
-
         return elementData;
     }
 
-    /**
-     * 模糊查询
-     */
-    public List<DocumentTemplate> getFuzzy(String name) {
-        DocumentTemplate documentTemplate = new DocumentTemplate();
-        documentTemplate.setName(name);
-        return documentTemplateDao.getFuzzy(documentTemplate);
-    }
-
     /**
      * 获取pdf文件
      */

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

@@ -12,7 +12,7 @@ public class DocumentCategory {
 	/**
 	 * 父id
 	 */
-	private int parentId;
+	private long parentId;
 
 	/**
 	 * 名称
@@ -47,11 +47,11 @@ public class DocumentCategory {
 		this.id = id;
 	}
 
-	public int getParentId() {
+	public long getParentId() {
 		return parentId;
 	}
 
-	public void setParentId(int parentId) {
+	public void setParentId(long parentId) {
 		this.parentId = parentId;
 	}