package com.lxzn.nc.controller; import com.lxzn.api.nc.ComponentInfoControllerApi; import com.lxzn.framework.domain.nc.ComponentInfo; import com.lxzn.framework.domain.nc.PermissionStream; import com.lxzn.framework.model.response.CommonCode; import com.lxzn.framework.model.response.ResponseResult; import com.lxzn.nc.service.IComponentInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/nc/component") public class ComponentInfoController implements ComponentInfoControllerApi { @Autowired private IComponentInfoService componentInfoService; @Override @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); } @Override @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); } @Override @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); } @Override @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); } }