2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-04-18 f2dfd5e6fbbb9c4e96e91c86be0bb6f7a44d87c3
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
package com.sandu.ximon.admin.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.param.LEDProgramParam;
import com.sandu.ximon.admin.param.ReceiveParam;
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.service.LEDProgramService;
import com.sandu.ximon.dao.domain.LEDProgram;
import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * LED节目处理
 */
@RestController
@AllArgsConstructor
@RequestMapping("/v1/LEDProgram")
public class LEDProgramController {
    private final LEDProgramService ledProgramService;
    private PermissionConfig permissionConfig;
 
    @PostMapping("/add")
    public ResponseVO<Object> addLEDProgram(@RequestBody @Validated LEDProgramParam ledProgramParam) {
        return ResponseUtil.success(ledProgramService.addProgram(ledProgramParam));
    }
 
    @PostMapping("/update/{pid}")
    public ResponseVO<Object> updateLEDProgram(@PathVariable Long pid, @RequestBody @Validated LEDProgramParam ledProgramParam) {
        return ResponseUtil.success(ledProgramService.updateProgram(pid, ledProgramParam));
    }
 
    @GetMapping("/getbypid/{pid}")
    public ResponseVO<Object> getByPid(@PathVariable Long pid) {
        return ResponseUtil.success(ledProgramService.getByPid(pid));
    }
 
 
    @PostMapping("/delete/{pid}")
    public ResponseVO<Object> deleteLEDProgram(@PathVariable Long pid) {
        return ResponseUtil.success(ledProgramService.deleteProgram(pid));
    }
 
 
    @GetMapping("/list")
    public ResponseVO<Object> listProgram(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
        if (!permissionConfig.check(MenuEnum.LED_PROGRAM_LIST.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        LambdaQueryWrapper<LEDProgram> wrapper = ledProgramService.listProgram();
        if (null != keyword) {
            wrapper.like(LEDProgram::getName, keyword);
        }
        return ResponseUtil.successPage(ledProgramService.list(wrapper));
 
    }
 
    /**
     * 模糊查询
     *
     * @return
     */
    @GetMapping("/listLike")
    public ResponseVO<Object> listLikeProgram(@RequestBody ReceiveParam receiveParam) {
        LambdaQueryWrapper<LEDProgram> wrapper = ledProgramService.listProgram();
        if (receiveParam.getKind() != null || receiveParam.getName() != null) {
 
            wrapper.like(LEDProgram::getName, receiveParam.getName())
                    .or(
                            ledProgramLambdaQueryWrapper -> {
                                ledProgramLambdaQueryWrapper.like(LEDProgram::getKind, receiveParam.getKind());
                            }
                    );
 
        }
 
        // List<LEDProgram> list = ledProgramService.list(wrapper);
        return ResponseUtil.success(ledProgramService.list(wrapper));
 
    }
 
}