lyh
2025-01-17 73f636092a4de604e5308a9a851f504d60a4c003
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
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);
    }
}