lyh
2025-06-25 e756af0f5bfd1addbd5d5c145441fb34aad91a28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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);
    }
}