| | |
| | | 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; |
| | |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addLEDProgram(@RequestBody @Validated LEDProgramParam ledProgramParam) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_ADD.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(ledProgramService.addProgram(ledProgramParam)); |
| | | } |
| | | |
| | | @PostMapping("/update/{pid}") |
| | | public ResponseVO<Object> updateLEDProgram(@PathVariable Long pid, @RequestBody @Validated LEDProgramParam ledProgramParam) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(ledProgramService.updateProgram(pid, ledProgramParam)); |
| | | } |
| | | |
| | | @GetMapping("/getbypid/{pid}") |
| | | public ResponseVO<Object> getByPid(@PathVariable Long pid) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_DETAIL.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(ledProgramService.getByPid(pid)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/delete/{pid}") |
| | | public ResponseVO<Object> deleteLEDProgram(@PathVariable Long pid) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_DELETE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(ledProgramService.deleteProgram(pid)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listProgram(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | public ResponseVO<Object> listProgram(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq, |
| | | @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)); |
| | | return ResponseUtil.successPage(ledProgramService.listProgram(baseConditionVO, order, seq, keyword)); |
| | | |
| | | } |
| | | |
| | | // /** |
| | | // * 模糊查询 |
| | | // * |
| | | // * @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)); |
| | | // |
| | | // } |
| | | |
| | | } |