gongchunyi
16 小时以前 1db111fdf6c65fa1debadf648e4c22bd466744f8
src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -11,8 +11,8 @@
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.sales.pojo.CommonFile;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -39,35 +39,35 @@
    @ApiModelProperty("设备台账列表")
    @ApiOperation("设备台账列表")
    @GetMapping("/page")
    public AjaxResult page(Page page , DeviceLedgerDto deviceLedger) {
        return AjaxResult.success(deviceLedgerService.queryPage(page,deviceLedger));
    }
    @PostMapping()
    @ApiModelProperty("添加设备台账")
    @ApiOperation("添加设备台账")
    public AjaxResult add(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.saveDeviceLedger(deviceLedger);
    }
    @ApiModelProperty("根据id查询设备台账")
    @ApiOperation("根据id查询设备台账")
    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        return AjaxResult.success(deviceLedgerService.getById(id));
        return AjaxResult.success(deviceLedgerService.getDetailById(id));
    }
    @PutMapping ()
    @ApiModelProperty("修改设备台账")
    @ApiOperation("修改设备台账")
    public AjaxResult update(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.updateDeviceLedger(deviceLedger);
    }
    @DeleteMapping("/{ids}")
    @ApiModelProperty("删除设备台账")
    @ApiOperation("删除设备台账")
    public AjaxResult delete(@PathVariable("ids") ArrayList<Long> ids) {
        boolean b = deviceLedgerService.removeBatchByIds(ids);
        boolean b = deviceLedgerService.deleteLedgerAndFiles(ids);
        if (!b) {
            return AjaxResult.error("删除失败");
        }
@@ -75,13 +75,13 @@
    }
    @PostMapping("export")
    @ApiModelProperty("导出设备台账")
    @ApiOperation("导出设备台账")
    public void export(HttpServletResponse response, Long[] ids) {
         deviceLedgerService.export(response, ids);
    }
    @PostMapping("import")
    @ApiModelProperty("导入设备台账")
    @ApiOperation("导入设备台账")
    public AjaxResult importData(MultipartFile file) throws IOException {
        Boolean b = deviceLedgerService.importData(file);
        if (b) {
@@ -92,7 +92,7 @@
    @GetMapping("getDeviceLedger")
    @ApiModelProperty("获取设备台账")
    @ApiOperation("获取设备台账")
    public AjaxResult getDeviceLedger( ) {
        return AjaxResult.success(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
                .select(DeviceLedger::getId, DeviceLedger::getDeviceName,DeviceLedger::getDeviceModel)));
@@ -110,4 +110,24 @@
        deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//下次维护时间
        return AjaxResult.success(deviceLedger);
    }
    @PostMapping("/uploadFile")
    @ApiOperation("设备台账-附件上传")
    public AjaxResult uploadFile(MultipartFile file, Long deviceLedgerId, Integer fileType) {
        deviceLedgerService.uploadFile(file, deviceLedgerId, fileType);
        return AjaxResult.success();
    }
    @GetMapping("/file/{deviceLedgerId}")
    @ApiOperation("设备台账-文件列表")
    public AjaxResult getFiles(@PathVariable("deviceLedgerId") Long deviceLedgerId) {
        java.util.List<CommonFile> list = deviceLedgerService.getFiles(deviceLedgerId);
        return AjaxResult.success(list);
    }
    @DeleteMapping("/file/{fileId}")
    @ApiOperation("设备台账-删除文件")
    public AjaxResult deleteFile(@PathVariable("fileId") Long fileId) {
        deviceLedgerService.deleteFile(fileId);
        return AjaxResult.success();
    }
}