liding
2025-12-11 c999acf2f8fe57bdf6b97681bfdfe47ce5c102a6
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
package com.ruoyi.production.controller;
 
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.pojo.ProductionLine;
import com.ruoyi.production.service.ProductionLineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @author :yys
 * @date : 2025/12/4 11:19
 */
@RestController
@Api(tags = "产线管理")
@RequestMapping("/productionLine")
public class ProductionLineController extends BaseController {
 
    @Autowired
    private ProductionLineService productionLineService;
 
    /**
     * 递归查询产线树
     */
    @GetMapping("/listTree")
    @ApiOperation(value = "递归查询产线树")
    public AjaxResult listTree() {
        List<ProductionLine> productionLines = productionLineService.listTree();
        return AjaxResult.success(productionLines);
    }
 
    /**
     * 分页-根据父节点ID查询子树(如查询ID=1的产线下的所有工序)
     */
    @GetMapping("/pageList")
    @ApiOperation(value = "分页-根据父节点ID查询子树")
    public AjaxResult getSubTree(Page page, ProductionLine productionLine) {
        return AjaxResult.success(productionLineService.getSubTreeByParentId(page ,productionLine));
    }
 
    @PostMapping("/add")
    @ApiOperation(value = "添加产线")
    @Log(title = "产线管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody ProductionLine productionLine) {
        return AjaxResult.success(productionLineService.save(productionLine));
    }
 
    @PostMapping("/update")
    @ApiOperation(value = "修改产线")
    @Log(title = "产线管理", businessType = BusinessType.UPDATE)
    public AjaxResult update(@RequestBody ProductionLine productionLine) {
        return AjaxResult.success(productionLineService.updateById(productionLine));
    }
 
    @DeleteMapping("/delete")
    @ApiOperation(value = "删除产线")
    @Log(title = "产线管理", businessType = BusinessType.DELETE)
    public AjaxResult delete(@RequestBody List<Long> ids) {
        if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("请传入要删除的ID");
        return AjaxResult.success(productionLineService.removeBatchByIds(ids));
    }
 
}