yangys
2025-06-12 80a641659a361c9f55c57936daca0a1790f777d5
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
package org.springblade.mdm.basesetting.machinegroup.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.mdm.basesetting.machine.MachineService;
import org.springblade.mdm.basesetting.machinegroup.MachineGroupService;
import org.springblade.mdm.basesetting.machinegroup.entity.MachineGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
@Slf4j
@RestController
@RequestMapping("/machinegroup")
@Tag(name = "机床组", description = "机床组")
@Hidden
public class MachineGroupController {
 
    @Autowired
    private MachineGroupService grpService;
 
    /**
     * 新增
     */
    @PostMapping("/save")
    @Operation(summary = "新增", description = "机床组信息")
    public R<Boolean> save(@RequestBody MachineGroup grp) {
 
        return R.<Boolean>status(grpService.save(grp));
    }
 
    /**
     * 修改
     */
    @Operation(summary = "修改", description = "机床组信息")
    @PostMapping("/update")
    public R<Boolean> update(@RequestBody MachineGroup grp) {
 
        return R.<Boolean>status(grpService.updateById(grp));
    }
 
    /**
     * 删除
     */
    @Operation(summary = "删除", description = "删除")
    @PostMapping("/remove")
    public R<Void> remove(@RequestParam String ids) {
        try {
            grpService.removeGroups(Func.toLongList(ids));
        } catch (Exception e) {
            log.error("删除异常",e);
            return R.fail(e.getMessage());
        }
        return R.status(true);
    }
 
    /**
     * 分页
     */
    @Operation(summary = "分页查询", description = "名称或编码")
    @GetMapping("/page")
    public R<IPage<MachineGroup>> page(String keyword, Query query) {
 
        LambdaQueryWrapper<MachineGroup> wrapper = new LambdaQueryWrapper<>();
        //wrapper.like(StringUtils.isNotBlank(keyword),MachineGroup::getName, "%"+keyword+"%");
        wrapper.and(StringUtils.isNotBlank(keyword),(w1)->{
            w1.like(MachineGroup::getName,"%"+keyword+"%")
                .or().like(MachineGroup::getCode,"%"+keyword+"%");
        });
 
        IPage<MachineGroup> pages = grpService.page(Condition.getPage(query), wrapper);
        return R.data(pages);
    }
}