| | |
| | | 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.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | 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.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; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addLEDProgram(@RequestBody LEDProgramParam ledProgramParam) { |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addLEDProgram(@RequestBody @Validated LEDProgramParam ledProgramParam) { |
| | | return ResponseUtil.success(ledProgramService.addProgram(ledProgramParam)); |
| | | } |
| | | |
| | | @GetMapping("/update") |
| | | public ResponseVO<Object> updateLEDProgram( @RequestBody LEDProgramParam ledProgramParam) { |
| | | return ResponseUtil.success(ledProgramService.updateProgram(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("/setGroup") |
| | | public ResponseVO<Object> setGroup(@RequestBody GroupParam groupParam){ |
| | | lampPostService.setGroup(groupParam.getGroup(), groupParam.getId()); |
| | | return ResponseUtil.success("分组设置成功"); |
| | | }*/ |
| | | |
| | | @GetMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteLEDProgram(@PathVariable Long id) { |
| | | return ResponseUtil.success(ledProgramService.deleteProgram(id)); |
| | | @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 (keyword != null && !keyword.isEmpty()) { |
| | | wrapper.like(LEDProgram::getName, keyword); |
| | | } |
| | | return ResponseUtil.successPage(ledProgramService.list(wrapper)); |
| | | |
| | | @PostMapping("/list") |
| | | public ResponseVO<Object> listProgram() { |
| | | //List<LampPost> list = lampPostService.list(); |
| | | return ResponseUtil.success(ledProgramService.list()); |
| | | //return ResponseUtil.success(lampPostService.listLamp()); |
| | | } |
| | | |
| | | // /** |
| | | // * 模糊查询 |
| | | // * |
| | | // * @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)); |
| | | // |
| | | // } |
| | | |
| | | } |