kongzy
2024-10-30 6f2e09fa870858d5371ece3a80674bae95288b9b
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
package com.gkhy.hazmat.admin.controller.app;
 
 
import com.gkhy.hazmat.common.annotation.RepeatSubmit;
import com.gkhy.hazmat.common.api.CommonResult;
import com.gkhy.hazmat.system.domain.HzHazmat;
import com.gkhy.hazmat.system.service.HzHazmatService;
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.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 * 危化品表 前端控制器
 * </p>
 *
 * @author kzy
 * @since 2024-08-05 14:41:40
 */
@Api(tags = "APP原材料危化品前端控制器")
@RestController
@RequestMapping("/app/hazmat")
public class AppHazmatController {
    @Autowired
    private HzHazmatService hazmatService;
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
    @ApiOperation(value = "根据条码查询危化品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "code", dataType = "string", required = true, value = "条码code")
    })
    @GetMapping("/getHazmatByCode")
    public CommonResult getHazmatByCode(@RequestParam(required = true) String code){
        return CommonResult.success(hazmatService.selectHazmatByCode(code));
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
    @RepeatSubmit
    @ApiOperation(value = "领用")
    @PostMapping(value = { "/hazmatUse/{hazmatId}" })
    public CommonResult hazmatUse(@PathVariable(value = "hazmatId", required = true) Long hazmatId,@RequestParam(defaultValue = "0",required = true) Integer used){
        hazmatService.hazmatUse(hazmatId,used);
        return CommonResult.success();
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
    @RepeatSubmit
    @ApiOperation(value = "归还")
    @PostMapping(value = { "/hazmatReturn" })
    public CommonResult hazmatReturn(@RequestBody HzHazmat hazmat){
        hazmatService.hazmatReturn(hazmat);
        return CommonResult.success();
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
    @RepeatSubmit
    @ApiOperation(value = "用尽登记")
    @PostMapping(value = { "/hazmatUsed/{hazmatId}" })
    public CommonResult hazmatUsed(@PathVariable(value = "hazmatId", required = true) Long hazmatId){
        hazmatService.hazmatUsed(hazmatId);
        return CommonResult.success();
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
    @RepeatSubmit
    @ApiOperation(value = "二维码作废")
    @PostMapping(value = { "/hazmatDiscard/{hazmatId}" })
    public CommonResult hazmatDiscard(@PathVariable(value = "hazmatId", required = true) Long hazmatId){
        hazmatService.hazmatDiscard(hazmatId);
        return CommonResult.success();
    }
}