diff --git a/tamguo-mms/src/main/java/com/tamguo/web/DocumentController.java b/tamguo-mms/src/main/java/com/tamguo/web/DocumentController.java index 1c019a1..0a37177 100644 --- a/tamguo-mms/src/main/java/com/tamguo/web/DocumentController.java +++ b/tamguo-mms/src/main/java/com/tamguo/web/DocumentController.java @@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PathPathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -35,35 +35,45 @@ import com.tamguo.modules.book.service.IFileEntityService; import com.tamguo.modules.book.service.IFileUploadService; import com.tamguo.utils.FileMd5Utils; +/** + * DocumentController 类,处理文档相关的请求 + */ @Controller -@RequestMapping(value="document") +@RequestMapping(value = "document") public class DocumentController { - private Logger logger = LoggerFactory.getLogger(getClass()); + private Logger logger = LoggerFactory.getLogger(getClass()); // 创建日志记录器对象 @Autowired - IDocumentService iDocumentService; + IDocumentService iDocumentService; // 自动注入文档服务 + @Autowired - IFileEntityService iFileEntityService; + IFileEntityService iFileEntityService; // 自动注入文件实体服务 + @Autowired - IFileUploadService iFileUploadService; - + IFileUploadService iFileUploadService; // 自动注入文件上传服务 + @Value("${file.storage.path}") - private String fileStoragePath; + private String fileStoragePath; // 文件存储路径配置 + @Value("${tamguo.domain.name}") - private String domainName; - - @SuppressWarnings("unchecked") - @RequestMapping(value = "{id}" , method = RequestMethod.GET) + private String domainName; // 域名配置 + + /** + * 获取文档信息的请求处理 + * @param id 文档 ID + * @return 返回处理结果 + */ + @RequestMapping(value = "{id}", method = RequestMethod.GET) @ResponseBody public Result getDocument(@PathVariable String id) { - DocumentEntity document = null; + DocumentEntity document = null; // 定义文档对象 try { - document = iDocumentService.selectById(id); + document = iDocumentService.selectById(id); // 根据 ID 获取文档信息 // 查询附件 List fileUploads = iFileUploadService.selectList(Condition.create().eq("biz_key", document.getId()).eq("biz_type", BizTypeEnum.DOCUMENT.getValue())); - if(!CollectionUtils.isEmpty(fileUploads)) { - for(int i=0 ; i