|
|
|
|
package com.nov.KgLowDurable.controller;
|
|
|
|
|
import com.nov.KgLowDurable.enums.MaterialCategoryEnum;
|
|
|
|
|
import com.nov.KgLowDurable.pojo.entity.LdMaterial;
|
|
|
|
|
import com.nov.KgLowDurable.service.ILdMaterialService;
|
|
|
|
|
import com.nov.KgLowDurable.util.ImageUploadUtil;
|
|
|
|
|
import com.nov.KgLowDurable.util.Result;
|
|
|
|
|
import com.nov.KgLowDurable.util.StringUtils;
|
|
|
|
|
import io.swagger.annotations.*;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author liweidong
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
@RequestMapping("/material")
|
|
|
|
|
public class LdMaterialController {
|
|
|
|
|
|
|
|
|
|
private final ILdMaterialService materialService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/detail")
|
|
|
|
|
@ApiOperationSort(1)
|
|
|
|
|
@ApiOperation(value = "获取物料详情", notes = "根据物料ID获取详细信息")
|
|
|
|
|
public Result<LdMaterial> detail(@RequestParam Long id) {
|
|
|
|
|
return Result.OK(materialService.getById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
@ApiOperationSort(2)
|
|
|
|
|
@ApiOperation(value = "获取物料列表", notes = "获取物料列表,支持条件筛选", httpMethod = "GET", response = Result.class)
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "materialName", value = "物料名称", dataType = "string", paramType = "query")
|
|
|
|
|
})
|
|
|
|
|
public Result list(@ApiParam(hidden = true)
|
|
|
|
|
@RequestParam(required = false) String materialName,
|
|
|
|
|
@RequestParam(required = false ,defaultValue = "1") Integer pageNum,
|
|
|
|
|
@RequestParam(required = false ,defaultValue = "10") Integer pageSize) {
|
|
|
|
|
|
|
|
|
|
return Result.OK(materialService.getMaterialList(materialName,pageNum,pageSize));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增或修改
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/submit")
|
|
|
|
|
@ApiOperationSort(3)
|
|
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入material")
|
|
|
|
|
public Result submit(@RequestBody LdMaterial material) {
|
|
|
|
|
|
|
|
|
|
return Result.OK(materialService.submit(material));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 任务分派表 删除
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/remove")
|
|
|
|
|
@ApiOperationSort(4)
|
|
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
|
|
public Result remove(@RequestParam String ids) {
|
|
|
|
|
if(StringUtils.isEmpty(ids)){
|
|
|
|
|
return Result.error("ids为空");
|
|
|
|
|
}
|
|
|
|
|
return Result.OK(materialService.deleteLogic(ids));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getMaterialList")
|
|
|
|
|
@ApiOperationSort(5)
|
|
|
|
|
@ApiOperation(value = "获取物料列表", notes = "获取所有物料列表", httpMethod = "GET", response = Result.class)
|
|
|
|
|
public Result getMaterialList() {
|
|
|
|
|
|
|
|
|
|
return Result.OK(materialService.getMaterialList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getMaterialEnumList")
|
|
|
|
|
@ApiOperationSort(6)
|
|
|
|
|
@ApiOperation(value = "获取物料分类", notes = "获取所有物料列表", httpMethod = "GET", response = Result.class)
|
|
|
|
|
public Result getMaterialEnumList() {
|
|
|
|
|
|
|
|
|
|
return Result.OK(MaterialCategoryEnum.getEnumList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ImageUploadUtil imageUploadUtil;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/upload")
|
|
|
|
|
@ApiOperationSort(7)
|
|
|
|
|
public Result uploadImage(
|
|
|
|
|
@RequestParam("file") MultipartFile file) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String module = "material";
|
|
|
|
|
String fileUrl = imageUploadUtil.uploadImage(file, module);
|
|
|
|
|
return Result.ok(fileUrl);
|
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
|
return Result.error(e.getMessage());
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
return Result.error("文件上传失败: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|