yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
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
90
91
92
93
94
95
96
97
98
99
100
package com.qianwen.smartman.modules.cps.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.smartman.common.enums.StatusType;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.mp.support.Condition;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.scanner.modular.annotation.DeleteResource;
import com.qianwen.core.scanner.modular.annotation.GetResource;
import com.qianwen.core.scanner.modular.annotation.PostResource;
import com.qianwen.core.scanner.modular.annotation.PutResource;
import com.qianwen.core.scanner.modular.stereotype.ApiResource;
import com.qianwen.core.secure.annotation.PreAuth;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.convert.StockInTypeConvert;
import com.qianwen.smartman.modules.cps.entity.StockInType;
import com.qianwen.smartman.modules.cps.service.IStockInTypeService;
import com.qianwen.smartman.modules.cps.vo.StockInTypeVO;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
 
@Api(value = "StockInType管理", tags = {"StockInType管理"})
@ApiResource({"blade-cps/stock-in-type"})
@RestController
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/controller/StockInTypeController.class */
public class StockInTypeController extends BladeController {
    private final IStockInTypeService stockInTypeService;
 
    public StockInTypeController(final IStockInTypeService stockInTypeService) {
        this.stockInTypeService = stockInTypeService;
    }
 
    @ApiOperationSupport(order = 1)
    @GetResource({"/get/{id}"})
    @ApiOperation(value = "入库类型详情", notes = "传入stockInType")
    public R<StockInTypeVO> detail(@PathVariable String id) {
        StockInType stockInType = (StockInType) this.stockInTypeService.getById(id);
        return R.data(StockInTypeConvert.INSTANCE.convert(stockInType));
    }
 
    @ApiOperationSupport(order = 2)
    @GetResource({"/list"})
    @ApiOperation(value = "入库类型列表", notes = "传入map")
    public R<List<StockInTypeVO>> list(@RequestParam @ApiIgnore Map<String, Object> params) {
        List<StockInType> list = this.stockInTypeService.list(Condition.getQueryWrapper(params, StockInType.class));
        return R.data(StockInTypeConvert.INSTANCE.convert(list));
    }
 
    @ApiOperationSupport(order = 3)
    @GetResource({"/page"})
    @ApiOperation(value = "入库类型分页", notes = "传入map")
    @PreAuth
    public R<IPage<StockInTypeVO>> page(Query query, @RequestParam(value = "key", required = false) String key, @RequestParam(value = "status", required = false) Integer status) {
        return R.data(this.stockInTypeService.pageStockInType(query, key, Func.isNull(status) ? CommonConstant.ENABLE : status));
    }
 
    @ApiOperationSupport(order = 4)
    @PostResource({"/insert"})
    @ApiOperation(value = "入库类型新增", notes = "传入stockInTypeVO")
    @PreAuth
    public R<StockInTypeVO> insert(@Valid @RequestBody StockInTypeVO stockInTypeVO) {
        StockInType stockInType = this.stockInTypeService.createStockInType(stockInTypeVO);
        return R.data(StockInTypeConvert.INSTANCE.convert(stockInType));
    }
 
    @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL)
    @PutResource({"/update"})
    @ApiOperation(value = "入库类型修改", notes = "传入stockInTypeVO")
    @PreAuth
    public R<StockInTypeVO> update(@Valid @RequestBody StockInTypeVO vo) {
        return R.data(this.stockInTypeService.updateStockIn(vo));
    }
 
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "入库类型删除", notes = "传入ids")
    @PreAuth
    @DeleteResource({"/remove"})
    public R<Boolean> remove(@ApiParam(value = "主键", required = true) @RequestBody List<String> ids, @RequestParam("type") @ApiParam("删除传0 停用传1") Integer type) {
        if (ids.isEmpty()) {
            return R.status(false);
        }
        if (StatusType.REMOVE.getType().equals(type)) {
            return R.data(Boolean.valueOf(this.stockInTypeService.removeByIds(Func.toLongList(ids))));
        }
        return R.data(Boolean.valueOf(this.stockInTypeService.changeStatus(Func.toLongList(ids), CommonConstant.DEACTIVATE)));
    }
}