baoshiwei
2025-03-12 3c2c87364b89de46d12e95abd5bdf8cbd2c6dbf6
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package cn.shlanbao.qms.controller;
 
import java.util.List;
 
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import cn.shlanbao.qms.domain.vo.LbBatchVo;
import cn.shlanbao.qms.domain.bo.LbBatchBo;
import cn.shlanbao.qms.service.ILbBatchService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
 
/**
 * 批次管理
 *
 * @author bsw
 * @date 2024-12-12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/qms/batch")
public class LbBatchController extends BaseController {
 
    private final ILbBatchService lbBatchService;
 
    /**
     * 查询批次管理列表
     */
    @SaCheckPermission("qms:batch:list")
    @GetMapping("/list")
    public TableDataInfo<LbBatchVo> list(LbBatchBo bo, PageQuery pageQuery) {
        return lbBatchService.queryPageList(bo, pageQuery);
    }
 
    /**
     * 查询分组去重后的所有产品型号
     */
    @SaCheckPermission("qms:batch:list")
    @GetMapping("/distinctProductModels")
    public R<List<String>> getDistinctProductModels() {
        return R.ok(lbBatchService.queryDistinctProductModels());
    }
 
    /**
     * 导出批次管理列表
     */
    @SaCheckPermission("qms:batch:export")
    @Log(title = "批次管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(LbBatchBo bo, HttpServletResponse response) {
        List<LbBatchVo> list = lbBatchService.queryList(bo);
        ExcelUtil.exportExcel(list, "批次管理", LbBatchVo.class, response);
    }
 
    /**
     * 获取批次管理详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("qms:batch:query")
    @GetMapping("/{id}")
    public R<LbBatchVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(lbBatchService.queryById(id));
    }
 
    /**
     * 新增批次管理
     */
    @SaCheckPermission("qms:batch:add")
    @Log(title = "批次管理", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody LbBatchBo bo) {
        return toAjax(lbBatchService.insertByBo(bo));
    }
 
    /**
     * 修改批次管理
     */
    @SaCheckPermission("qms:batch:edit")
    @Log(title = "批次管理", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody LbBatchBo bo) {
        return toAjax(lbBatchService.updateByBo(bo));
    }
 
    /**
     * 删除批次管理
     *
     * @param ids 主键串
     */
    @SaCheckPermission("qms:batch:remove")
    @Log(title = "批次管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(lbBatchService.deleteWithValidByIds(List.of(ids), true));
    }
}