| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.GroupParam; |
| | | import com.sandu.ximon.admin.param.LEDProgramParam; |
| | | import com.sandu.ximon.admin.param.LampPostParam; |
| | | import com.sandu.ximon.admin.param.ReceiveParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | 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.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * led节目 |
| | |
| | | public class LEDProgramController { |
| | | private final LEDProgramService ledProgramService; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addLEDProgram(@RequestBody LEDProgramParam ledProgramParam) { |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addLEDProgram(@RequestBody @Validated LEDProgramParam ledProgramParam) { |
| | | // public ResponseVO<Object> addLEDProgram(@RequestParam(name = "name") @Validated String name,@RequestParam(name = "kind") @Validated Integer kind,@RequestParam(name = "programBase64") @Validated String programBase64) { |
| | | return ResponseUtil.success(ledProgramService.addProgram(ledProgramParam)); |
| | | //return ResponseUtil.success(ledProgramService.addProgram(name,kind,programBase64)); |
| | | } |
| | | |
| | | @GetMapping("/update") |
| | | public ResponseVO<Object> updateLEDProgram( @RequestBody LEDProgramParam ledProgramParam) { |
| | | @PostMapping("/update") |
| | | public ResponseVO<Object> updateLEDProgram(@RequestBody @Validated LEDProgramParam ledProgramParam) { |
| | | return ResponseUtil.success(ledProgramService.updateProgram(ledProgramParam)); |
| | | } |
| | | |
| | | |
| | | /* @PostMapping("/setGroup") |
| | | public ResponseVO<Object> setGroup(@RequestBody GroupParam groupParam){ |
| | | lampPostService.setGroup(groupParam.getGroup(), groupParam.getId()); |
| | | return ResponseUtil.success("分组设置成功"); |
| | | }*/ |
| | | |
| | | @GetMapping("/delete/{id}") |
| | | @PostMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteLEDProgram(@PathVariable Long id) { |
| | | return ResponseUtil.success(ledProgramService.deleteProgram(id)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/list") |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listProgram() { |
| | | //List<LampPost> list = lampPostService.list(); |
| | | return ResponseUtil.success(ledProgramService.list()); |
| | | //return ResponseUtil.success(lampPostService.listLamp()); |
| | | //LambdaQueryWrapper<LEDProgram> wrapper = ledProgramService.listProgram(); |
| | | return ResponseUtil.success(ledProgramService.list(ledProgramService.listProgram())); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 模糊查询 |
| | | * |
| | | * @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)); |
| | | |
| | | } |
| | | |
| | | } |