|
package org.springblade.mdm.gkw.programnode.controller;
|
|
import com.alibaba.excel.util.StringUtils;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.tenant.annotation.NonDS;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.mdm.gkw.programnode.entity.MachineFile;
|
import org.springblade.mdm.gkw.programnode.service.MachineFileService;
|
import org.springblade.mdm.gkw.programnode.vo.MachineFileQueryVO;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.io.IOException;
|
|
/**
|
* 公开网程序节点
|
*
|
* @author yangys
|
*/
|
@NonDS
|
@RestController
|
@RequestMapping("/gkw/node")
|
@AllArgsConstructor
|
@Tag(name = "工控网程序节点", description = "工控网程序节点")
|
@Slf4j
|
public class MachineFileController {
|
private final MachineFileService machineFileService;
|
|
@GetMapping("/file-page")
|
@Operation(summary = "工控网目录文件列表", description = "工控网目录文件列表")
|
public R<IPage<MachineFile>> page(MachineFileQueryVO query) {
|
|
IPage<MachineFile> pageData = machineFileService.lambdaQuery()
|
.eq(MachineFile::getMachineCode,query.getMachineCode())
|
.eq(MachineFile::getDirType,query.getDirType())
|
.ne(MachineFile::getStatus,MachineFile.STATUS_REMOVED).like(StringUtils.isNotBlank(query.getName()),MachineFile::getName,query.getName())
|
.page(Condition.getPage(query));
|
return R.data(pageData);
|
}
|
|
|
@GetMapping("/file-content")
|
@Operation(summary = "获取机床目录文件内容", description = "工控网目录文件列表")
|
public R<String> machineFileContent(Long id) {
|
String content = machineFileService.getMachineFileContent(id);
|
return R.data(content);
|
}
|
|
@PostMapping("/file-save")
|
@Operation(summary = "保存机床文件", description = "保存机床文件到磁盘")
|
public R<Void> machineFileSave(Long id,String content) {
|
try {
|
machineFileService.saveFileContent(id,content);
|
} catch (IOException e) {
|
log.error(e.getMessage());
|
return R.fail(e.getMessage());
|
}
|
return R.success();
|
}
|
|
}
|