yangys
2025-06-27 26f07223e1b33a8eb5ee184041575e9b204cfebe
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/controller/NcProgramController.java
@@ -7,6 +7,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.mdm.program.entity.NcProgram;
import org.springblade.mdm.program.service.NcProgramService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -30,9 +31,30 @@
   @Operation(summary = "上传", description = "上传程序/附件文件")
   public R<Boolean> upload(@RequestParam MultipartFile file,Long nodeId,
                      @RequestParam String category) {
      ncProgramService.uploadNcFile(file,nodeId,category);
      ncProgramService.uploadProgramFile(file,nodeId,category);
      return R.<Boolean>status(true);
   }
   @PostMapping("/remove")
   @Operation(summary = "删除程序文件", description = "")
   public R<Boolean> removeFile(Long id) {
      try {
         ncProgramService.removeProgram(id);
         return R.success();
      }catch(Exception e) {
         log.error("删除文件失败",e);
         return R.fail(e.getMessage());
      }
   }
   @GetMapping("/content")
   @Operation(summary = "获取文件内容", description = "仅限文本格式的内容,二进制文件将返回空串")
   public R<String> fileContent(Long id) {
      try {
         return R.data(ncProgramService.getFileContent(id));
      }catch(Exception e) {
         log.error("删除文件失败",e);
         return R.fail(e.getMessage());
      }
   }
}