¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dnc.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.modules.dnc.entity.DocFile; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dnc.request.DocInfoQueryRequest; |
| | | import org.jeecg.modules.dnc.request.DocInfoUploadRequest; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.QueryListResponseResult; |
| | | import org.jeecg.modules.dnc.response.ResponseResult; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Api(tags = "ææ¡£è¡¨") |
| | | @RestController |
| | | @RequestMapping("/nc/doc") |
| | | public class DocInfoController extends JeecgController<DocInfo, IDocInfoService> { |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-导å
¥ææ¡£è¿å£") |
| | | @ApiOperation(value = "ææ¡£è¡¨-导å
¥ææ¡£è¿å£", notes = "ææ¡£è¡¨-导å
¥ææ¡£è¿å£") |
| | | @PostMapping("/add") |
| | | public ResponseResult addDocInfo(@RequestParam("file") MultipartFile file, DocInfoUploadRequest docInfo) { |
| | | boolean b = docInfoService.addDocInfo(file, docInfo); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-ç¼è¾ææ¡£åºæ¬ä¿¡æ¯") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ç¼è¾ææ¡£åºæ¬ä¿¡æ¯", notes = "ææ¡£è¡¨-ç¼è¾ææ¡£åºæ¬ä¿¡æ¯") |
| | | @PutMapping("/edit/{id}") |
| | | public ResponseResult editDocInfo(@PathVariable("id") String id, @RequestBody DocInfo docInfo) { |
| | | boolean b = docInfoService.editDocInfo(id, docInfo); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-å é¤ææ¡£ä¿¡æ¯") |
| | | @ApiOperation(value = "ææ¡£è¡¨-å é¤ææ¡£ä¿¡æ¯", notes = "ææ¡£è¡¨-å é¤ææ¡£ä¿¡æ¯") |
| | | @DeleteMapping("/delete/{id}/{attrType}/{attrId}") |
| | | public ResponseResult deleteDocInfo(@PathVariable("id") String id, @PathVariable("attrType") String attrType, @PathVariable("attrId") String attrId) { |
| | | boolean b = docInfoService.deleteDocInfo(id,attrType,attrId); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-å
¥åºæä½ ææ¡£å¯¹åºæä»¶åç") |
| | | @ApiOperation(value = "ææ¡£è¡¨-å
¥åºæä½ ææ¡£å¯¹åºæä»¶åç", notes = "ææ¡£è¡¨-å
¥åºæä½ ææ¡£å¯¹åºæä»¶åç") |
| | | @PostMapping("/push/{id}") |
| | | public ResponseResult pushDocFile(@PathVariable("id") String id, @RequestParam("file") MultipartFile file) { |
| | | boolean b = docInfoService.pushDocFile(id, file); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-åºåº") |
| | | @ApiOperation(value = "ææ¡£è¡¨-åºåº", notes = "ææ¡£è¡¨-åºåº") |
| | | @GetMapping("/pull/{id}") |
| | | public ResponseResult pullDocFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) { |
| | | return docInfoService.pullDocFile(request, response, id); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-åæ¶åºåº") |
| | | @ApiOperation(value = "ææ¡£è¡¨-åæ¶åºåº", notes = "ææ¡£è¡¨-åæ¶åºåº") |
| | | @PutMapping("/cancel/pull/{id}") |
| | | public ResponseResult cancelPullDocInfo(@PathVariable("id") String id) { |
| | | boolean b = docInfoService.cancelPullDocInfo(id); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-ææ¡£åå¸") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ææ¡£åå¸", notes = "ææ¡£è¡¨-ææ¡£åå¸") |
| | | @PutMapping("/publish/{id}") |
| | | public ResponseResult publishDocInfo(@PathVariable("id") String id) { |
| | | boolean b = docInfoService.publishDocInfo(id); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-ææ¡£éåå¸") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ææ¡£éåå¸", notes = "ææ¡£è¡¨-ææ¡£éåå¸") |
| | | @PutMapping("/republish/{id}") |
| | | public ResponseResult republishDocInfo(@PathVariable("id") String id) { |
| | | boolean b = docInfoService.republishDocInfo(id); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-ææ¡£å½æ¡£") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ææ¡£å½æ¡£", notes = "ææ¡£è¡¨-ææ¡£å½æ¡£") |
| | | @PutMapping("/pigeonhole/{id}") |
| | | public ResponseResult pigeonholeDocInfo(@PathVariable("id") String id) { |
| | | boolean b = docInfoService.pigeonholeDocInfo(id); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-å页æ¥è¯¢æ¥å£") |
| | | @ApiOperation(value = "ææ¡£è¡¨-å页æ¥è¯¢æ¥å£", notes = "ææ¡£è¡¨-å页æ¥è¯¢æ¥å£") |
| | | @GetMapping("/find/page/{page}/{size}") |
| | | public Result<?> findPageList(@PathVariable("page") int page, @PathVariable("size") int size, DocInfoQueryRequest docQuery) { |
| | | return docInfoService.findPageList(page, size, docQuery); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-æ¥è¯¢è®¾å¤åéç®å½çææ¡£ç¶æ") |
| | | @ApiOperation(value = "ææ¡£è¡¨-æ¥è¯¢è®¾å¤åéç®å½çææ¡£ç¶æ", notes = "ææ¡£è¡¨-æ¥è¯¢è®¾å¤åéç®å½çææ¡£ç¶æ") |
| | | @GetMapping("/find/page/device/{page}/{size}") |
| | | public Result<?> findPageListByDevice(@PathVariable("page") int page, @PathVariable("size") int size, DocInfoQueryRequest docQuery) { |
| | | return Result.ok(docInfoService.findPageListByDevice(page, size, docQuery)); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-ææ¡£æä»¶é¢è§") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ææ¡£æä»¶é¢è§", notes = "ææ¡£è¡¨-ææ¡£æä»¶é¢è§") |
| | | @GetMapping("/preview/{id}") |
| | | public QueryListResponseResult previewDocFile(@PathVariable("id") String id) { |
| | | DocFile docFile = docInfoService.previewDocFile(id); |
| | | if(!ValidateUtil.validateString(docFile.getFilePath()) || !ValidateUtil.validateString(docFile.getFileName()) |
| | | // || !ValidateUtil.validateString(docFile.getFileSuffix()) |
| | | || !ValidateUtil.validateString(docFile.getFileEncodeName())) |
| | | return new QueryListResponseResult(CommonCode.FAIL, null); |
| | | String filePath = docFile.getFilePath(); |
| | | String fileEncodeName = docFile.getFileEncodeName(); |
| | | List<String> list = FileUtilS.readFile(fileEncodeName, filePath); |
| | | if(list == null || list.isEmpty()) |
| | | return new QueryListResponseResult(CommonCode.FAIL, null); |
| | | return new QueryListResponseResult(CommonCode.SUCCESS, list); |
| | | } |
| | | |
| | | @AutoLog(value = "ææ¡£è¡¨-ææ¡£æä»¶é¢è§pdf") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ææ¡£æä»¶é¢è§pdf", notes = "ææ¡£è¡¨-ææ¡£æä»¶é¢è§pdf") |
| | | @GetMapping("/preview/pdf/{id}") |
| | | public ResponseResult previewPdfDocFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) { |
| | | DocFile docFile = docInfoService.previewDocFile(id); |
| | | if(!ValidateUtil.validateString(docFile.getFilePath()) || !ValidateUtil.validateString(docFile.getFileName()) || |
| | | /*!ValidateUtil.validateString(docFile.getFileSuffix()) ||*/ !ValidateUtil.validateString(docFile.getFileEncodeName())) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | String fileName; |
| | | if(ValidateUtil.validateString(docFile.getFileSuffix())) { |
| | | fileName = docFile.getFileName() + "." + docFile.getFileSuffix(); |
| | | }else { |
| | | fileName = docFile.getFileName(); |
| | | } |
| | | String filePath = docFile.getFilePath(); |
| | | String fileEncodeName = docFile.getFileEncodeName(); |
| | | FileUtilS.downLoadFile(response, fileEncodeName, filePath, fileName); |
| | | return null; |
| | | } |
| | | |
| | | @AutoLog(value = "æä»¶è¡¨-æ¥è¯¢å¯ææ´¾çææ¡£ä¿¡æ¯å表") |
| | | @ApiOperation(value = "æä»¶è¡¨-æ¥è¯¢å¯ææ´¾çææ¡£ä¿¡æ¯å表", notes = "æä»¶è¡¨-æ¥è¯¢å¯ææ´¾çææ¡£ä¿¡æ¯å表") |
| | | @GetMapping("/find/list") |
| | | public Result<?> findList(DocInfoQueryRequest docQuery) { |
| | | List<DocInfo> docInfoList=docInfoService.findList(docQuery); |
| | | return Result.ok(docInfoList); |
| | | } |
| | | |
| | | @AutoLog(value = "æä»¶è¡¨-æ¹éå é¤ææ¡£æ¥å£") |
| | | @ApiOperation(value = "æä»¶è¡¨-æ¹éå é¤ææ¡£æ¥å£", notes = "æä»¶è¡¨-æ¹éå é¤ææ¡£æ¥å£") |
| | | @PostMapping("/batch/remove/{docIds}/{attrType}/{attrId}") |
| | | public ResponseResult batchRemoveDocInfo(@PathVariable("docIds") String[] docIds, @PathVariable("attrType") String attrType, @PathVariable("attrId") String attrId) { |
| | | boolean b = docInfoService.batchRemoveDocInfo(docIds,attrType,attrId); |
| | | if(!b) |
| | | return new ResponseResult(CommonCode.FAIL); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | @AutoLog(value = "æä»¶è¡¨-ææ¡£ä¸è½½") |
| | | @ApiOperation(value = "æä»¶è¡¨-ææ¡£ä¸è½½", notes = "æä»¶è¡¨-ææ¡£ä¸è½½") |
| | | @GetMapping("/download/{id}") |
| | | public ResponseResult downloadDocFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) { |
| | | return docInfoService.downloadDocFile(request, response, id); |
| | | } |
| | | } |