gaoluyang
8 天以前 9e9f0e2d9f6fcce7dcea88b181b3c7e6069e8a1b
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
86
87
88
89
package cn.iocoder.yudao.module.hrm.controller.admin.supply;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.hrm.controller.admin.supply.vo.HrmSupplyAlertRespVO;
import cn.iocoder.yudao.module.hrm.controller.admin.supply.vo.HrmSupplyPageReqVO;
import cn.iocoder.yudao.module.hrm.controller.admin.supply.vo.HrmSupplyRespVO;
import cn.iocoder.yudao.module.hrm.controller.admin.supply.vo.HrmSupplySaveReqVO;
import cn.iocoder.yudao.module.hrm.controller.admin.supply.vo.HrmSupplySimpleRespVO;
import cn.iocoder.yudao.module.hrm.dal.dataobject.supply.HrmSupplyDO;
import cn.iocoder.yudao.module.hrm.service.supply.HrmSupplyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - HRM 办公用品档案")
@RestController
@RequestMapping("/hrm/supply")
@Validated
public class HrmSupplyController {
 
    @Resource
    private HrmSupplyService supplyService;
 
    @PostMapping("/create")
    @Operation(summary = "新增办公用品")
    @PreAuthorize("@ss.hasPermission('hrm:supply:create')")
    public CommonResult<Long> createSupply(@Valid @RequestBody HrmSupplySaveReqVO createReqVO) {
        return success(supplyService.createSupply(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新办公用品")
    @PreAuthorize("@ss.hasPermission('hrm:supply:update')")
    public CommonResult<Boolean> updateSupply(@Valid @RequestBody HrmSupplySaveReqVO updateReqVO) {
        supplyService.updateSupply(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除办公用品")
    @Parameter(name = "id", description = "用品编号", required = true)
    @PreAuthorize("@ss.hasPermission('hrm:supply:delete')")
    public CommonResult<Boolean> deleteSupply(@RequestParam("id") Long id) {
        supplyService.deleteSupply(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得办公用品")
    @Parameter(name = "id", description = "用品编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('hrm:supply:query')")
    public CommonResult<HrmSupplyRespVO> getSupply(@RequestParam("id") Long id) {
        HrmSupplyDO supply = supplyService.getSupply(id);
        return success(BeanUtils.toBean(supply, HrmSupplyRespVO.class));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得办公用品分页")
    @PreAuthorize("@ss.hasPermission('hrm:supply:query')")
    public CommonResult<PageResult<HrmSupplyRespVO>> getSupplyPage(@Valid HrmSupplyPageReqVO pageReqVO) {
        return success(supplyService.getSupplyPage(pageReqVO));
    }
 
    @GetMapping("/simple-list")
    @Operation(summary = "获得办公用品精简列表", description = "只返回启用的用品,主要用于前端下拉")
    public CommonResult<List<HrmSupplySimpleRespVO>> getSupplySimpleList() {
        List<HrmSupplyDO> list = supplyService.getSupplyList();
        return success(BeanUtils.toBean(list, HrmSupplySimpleRespVO.class));
    }
 
    @GetMapping("/alert-list")
    @Operation(summary = "获得办公用品库存预警列表", description = "返回当前库存低于库存下限或高于库存上限的启用用品")
    @PreAuthorize("@ss.hasPermission('hrm:supply:query')")
    public CommonResult<List<HrmSupplyAlertRespVO>> getSupplyAlertList() {
        return success(supplyService.getSupplyAlertList());
    }
 
}