package org.jeecg.modules.dnc.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.modules.dnc.entity.ComponentInfo;
|
import org.jeecg.modules.dnc.entity.PermissionStream;
|
import org.jeecg.modules.dnc.response.CommonCode;
|
import org.jeecg.modules.dnc.response.ResponseResult;
|
import org.jeecg.modules.dnc.service.IComponentInfoService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
@Slf4j
|
@Api(tags = "部件管理")
|
@RestController
|
@RequestMapping("/nc/component")
|
public class ComponentInfoController {
|
@Autowired
|
private IComponentInfoService componentInfoService;
|
|
|
@AutoLog(value = "部件管理-新增")
|
@ApiOperation(value = "部件管理-新增", notes = "部件管理-新增")
|
@PostMapping("/add")
|
public ResponseResult addComponentInfo(@RequestBody ComponentInfo componentInfo) {
|
boolean b = componentInfoService.addComponentInfo(componentInfo);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "部件管理-修改")
|
@ApiOperation(value = "部件管理-修改", notes = "部件管理-修改")
|
@PutMapping("/edit/{id}")
|
public ResponseResult editComponentInfo(@PathVariable("id") String id,@RequestBody ComponentInfo componentInfo) {
|
boolean b = componentInfoService.editComponentInfo(id,componentInfo);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "部件管理-删除")
|
@ApiOperation(value = "部件管理-修改", notes = "部件管理-删除")
|
@DeleteMapping("/delete")
|
public ResponseResult deleteComponentInfo(@RequestParam("id") String id) {
|
boolean b = componentInfoService.deleteComponentInfo(id);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "检查pn码的有效性")
|
@ApiOperation(value = "检查pn码的有效性", notes = "检查pn码的有效性")
|
@GetMapping("/valid/pnCode")
|
public ResponseResult validateComponentOrPartsPnCode(String pnCode) {
|
PermissionStream b = componentInfoService.validateComponentOrPartsPnCode(pnCode);
|
if(b != null) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "查询可以被引用的部件")
|
@ApiOperation(value = "查询可以被引用的部件", notes = "查询可以被引用的部件")
|
@GetMapping("/getByComponentId")
|
public Result<?> getByComponentId(ComponentInfo componentInfo, Integer pageNo, Integer pageSize) {
|
IPage<ComponentInfo> iPage = componentInfoService.getByComponentId(componentInfo, pageNo, pageSize);
|
return Result.OK(iPage);
|
}
|
|
|
@AutoLog(value = "借用部件(可批量)")
|
@ApiOperation(value = "借用部件(可批量)", notes = "借用部件(可批量)")
|
@GetMapping("/borrow")
|
public Result<?> borrowComponent(String oldId, String newIds) {
|
return componentInfoService.borrowComponent(oldId,newIds);
|
}
|
}
|