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.service.LEDProgramService; import com.sandu.ximon.dao.domain.LEDProgram; 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; @PostMapping("/add") public ResponseVO addLEDProgram(@RequestBody @Validated LEDProgramParam ledProgramParam) { return ResponseUtil.success(ledProgramService.addProgram(ledProgramParam)); } @PostMapping("/update/{pid}") public ResponseVO updateLEDProgram(@PathVariable Long pid, @RequestBody @Validated LEDProgramParam ledProgramParam) { return ResponseUtil.success(ledProgramService.updateProgram(pid,ledProgramParam)); } @GetMapping("/getbypid/{pid}") public ResponseVO getByPid(@PathVariable Long pid) { return ResponseUtil.success(ledProgramService.getByPid(pid)); } @PostMapping("/delete/{pid}") public ResponseVO deleteLEDProgram(@PathVariable Long pid) { return ResponseUtil.success(ledProgramService.deleteProgram(pid)); } @GetMapping("/list") public ResponseVO listProgram(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); LambdaQueryWrapper wrapper = ledProgramService.listProgram(); if(null!=keyword){ wrapper.like(LEDProgram::getName,keyword); } return ResponseUtil.successPage(ledProgramService.list(wrapper)); } /** * 模糊查询 * * @return */ @GetMapping("/listLike") public ResponseVO listLikeProgram(@RequestBody ReceiveParam receiveParam) { LambdaQueryWrapper 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 list = ledProgramService.list(wrapper); return ResponseUtil.success(ledProgramService.list(wrapper)); } }