package org.jeecg.modules.dnc.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; 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); } }