lyh
8 小时以前 371365543363969fd3afcc404440c838817ecc3d
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
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);
    }
}