yangys
2024-04-02 6bed83e92f67954cd2135071133329f2205efe4f
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
package com.qianwen.smartman.modules.cps.controller;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.lang.invoke.SerializedLambda;
import java.util.List;
import javax.validation.Valid;
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.core.boot.ctrl.BladeController;
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.secure.utils.AuthUtil;
import com.qianwen.core.tenant.mp.TenantEntity;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.convert.MaterialTypeConvert;
import com.qianwen.smartman.modules.cps.entity.MaterialType;
import com.qianwen.smartman.modules.cps.service.IMaterialTypeService;
import com.qianwen.smartman.modules.cps.vo.MaterialTypeAddVO;
import com.qianwen.smartman.modules.cps.vo.MaterialTypeUpdateVO;
import com.qianwen.smartman.modules.cps.vo.MaterialTypeVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@ApiResource({"blade-cps/material-type"})
@Api(value = "物料类型", tags = {"物料类型"})
@RestController
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/controller/MaterialTypeController.class */
public class MaterialTypeController extends BladeController {
    private final IMaterialTypeService materialTypeService;
 
 
    public MaterialTypeController(final IMaterialTypeService materialTypeService) {
        this.materialTypeService = materialTypeService;
    }
 
    @PreAuth
    @GetResource({"/list"})
    @ApiOperation(value = "查询物料类型列表(不分页)", notes = "查询物料类型列表(不分页)")
    public R<List<MaterialTypeVO>> getMaterialTypeList(@RequestParam(value = "keyWord", required = false) String keyWord, @RequestParam(value = "status", required = false) Integer status) {
        if (Func.isNull(status)) {
            status = CommonConstant.ENABLE;
        }
        List<MaterialType> list = this.materialTypeService.list(Wrappers.<MaterialType>query().lambda()
                .eq(MaterialType::getStatus, status)
                .eq(Func.isNotEmpty(AuthUtil.getTenantId()), TenantEntity::getTenantId, AuthUtil.getTenantId())
                .and(Func.isNotEmpty(keyWord), i -> i.likeRight(MaterialType::getCode, keyWord).or().likeRight(MaterialType::getName, keyWord)
                .orderByDesc(MaterialType::getCreateTime)));
            return R.data(MaterialTypeConvert.INSTANCE.convert(list));
    }
 
    @PreAuth
    @GetResource({"/page"})
    @ApiOperation(value = "查询分页", notes = "查询分页")
    public R<IPage<MaterialTypeVO>> getPageMaterialType(Query query, @RequestParam(value = "keyWord", required = false) String keyWord, @RequestParam(value = "status", required = false) Integer status) {
        return R.data(MaterialTypeConvert.INSTANCE.convert(this.materialTypeService.getPageMaterialType(query, keyWord, Func.isNull(status) ? CommonConstant.ENABLE : status)));
    }
 
    @PreAuth
    @PostResource({"/create-material-type"})
    @ApiOperation("新增物料类型")
    public R<MaterialTypeVO> createMaterialType(@Valid @RequestBody MaterialTypeAddVO materialTypeAddVO) {
        return R.data(this.materialTypeService.createMaterialType(materialTypeAddVO));
    }
 
    @PreAuth
    @PutResource({"/update-material-type"})
    @ApiOperation("修改物料类型")
    public R<MaterialTypeVO> updateMaterialType(@Valid @RequestBody MaterialTypeUpdateVO materialTypeUpdateVO) {
        return R.data(this.materialTypeService.updateMaterialType(materialTypeUpdateVO));
    }
 
    @ApiOperationSupport(order = 3)
    @ApiOperation("删除物料类型(支持批量)")
    @PreAuth
    @DeleteResource({"/delete-material-type"})
    public R<List<String>> deleteMaterialType(@RequestParam(value = "ids", required = true) List<String> ids, @RequestParam("type") @ApiParam("删除传0 停用传1") Integer type) {
        this.materialTypeService.deleteMaterialType(ids, type);
        return R.data(ids);
    }
}