Fixiaobai
2023-09-08 d2ce4553e18131b9a60d7be53c496f0cbce699ca
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
package com.yuanchu.limslaboratory.controller;
 
import com.yuanchu.limslaboratory.annotation.AuthHandler;
import com.yuanchu.limslaboratory.enums.InterfaceType;
import com.yuanchu.limslaboratory.enums.MenuEnums;
import com.yuanchu.limslaboratory.pojo.dto.AddMaterialDto;
import com.yuanchu.limslaboratory.service.MaterialService;
import com.yuanchu.limslaboratory.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-07-17
 */
@Api(tags = "标准库-->1、物料")
@RestController
@RequestMapping("/material")
public class MaterialController {
 
    @Autowired
    private MaterialService materialService;
 
    @ApiOperation(value = "添加指标-->选择样品名称")
    @GetMapping("/selectmater")
    @AuthHandler
    public Result selectmater() {
        return Result.success(materialService.selectmater());
    }
 
    @ApiOperation("添加指标")
    @PostMapping("/add")
    @AuthHandler
    public Result<?> addMaterialInformation(@Validated @RequestBody AddMaterialDto addMaterialDto) {
        Integer isMaterialSuccess = materialService.addMaterialInformation(addMaterialDto);
        if (isMaterialSuccess == 1) {
            return Result.success("添加物料【"+ addMaterialDto.getMaterialName() +"】成功!");
        }
        return Result.fail("添加物料【"+ addMaterialDto.getMaterialName() +"】失败!");
    }
 
    @ApiOperation("根据物料ID删除物料")
    @DeleteMapping("/delete")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(value = "物料ID", name = "materialId", dataTypeClass = Integer.class)
    })
    @AuthHandler
    public Result<?> deleteMaterialInformation(Integer materialId) {
        Integer isDeleteMaterialSuccess = materialService.deleteMaterialInformation(materialId);
        if (isDeleteMaterialSuccess == 1) {
            return Result.success("删除成功!");
        }
        return Result.fail("删除失败!");
    }
 
    @ApiOperation(value = "标准库-->物料-->侧边栏四级展开")
    @GetMapping("/list")
    @AuthHandler
    public Result<?> getFourLevelInformation() {
        List<Map<String, Object>> fourLevelInformation = materialService.getFourLevelInformation();
        return Result.success(fourLevelInformation);
    }
 
    @ApiOperation(value = "标准库-->下拉基础数据样品")
    @GetMapping("/getSample")
    @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.index,isAdd = true)
    public Result<?> getSample() {
        return Result.success(materialService.getSample());
    }
}