| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.PlayPlanParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.service.PlayPlanNvService; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import com.sandu.ximon.admin.vo.NovaPushResultVO; |
| | | import com.sandu.ximon.dao.domain.PlayPlanNv; |
| | | import com.sandu.ximon.dao.enums.AdministratorEnums; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author liuhaonan |
| | |
| | | @RequestMapping("/v1/ledPlan") |
| | | public class PlayPlanNvController { |
| | | private final PlayPlanNvService playPlanNvService; |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addLEDPlan(@RequestBody @Validated PlayPlanParam param) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_ADD.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(playPlanNvService.addPlan(param)); |
| | | } |
| | | |
| | | @GetMapping("/getByPlanId/{planId}") |
| | | public ResponseVO<Object> getPlan(@PathVariable Long planId) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_DETAIL.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(playPlanNvService.getByPlanId(planId)); |
| | | } |
| | | |
| | | @PostMapping("/update/{planId}") |
| | | public ResponseVO<Object> updateLEDPlan(@PathVariable Long planId,@RequestBody @Validated PlayPlanParam param) { |
| | | public ResponseVO<Object> updateLEDPlan(@PathVariable Long planId, @RequestBody @Validated PlayPlanParam param) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(playPlanNvService.updatePlan(planId, param)); |
| | | } |
| | | |
| | | @PostMapping("/delete/{plianId}") |
| | | public ResponseVO<Object> deleteLEDPlan(@PathVariable Long plianId) { |
| | | return ResponseUtil.success(playPlanNvService.deletePlan(plianId)); |
| | | @PostMapping("/delete") |
| | | public ResponseVO<Object> deleteLEDPlan(@RequestBody List<Long> plianIds) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_DETELE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(playPlanNvService.deletePlan(plianIds)); |
| | | } |
| | | |
| | | @PostMapping("/push/{plianId}") |
| | | public ResponseVO<Object> pushToLed(@PathVariable Long plianId) { |
| | | return ResponseUtil.success(playPlanNvService.pushToLed(plianId)); |
| | | /** |
| | | * 定时节目 |
| | | * |
| | | * @param planId |
| | | * @param playerIds |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/push/{planId}", produces = "application/json;charset=UTF-8") |
| | | public ResponseVO<Object> pushToLed(@PathVariable Long planId, @RequestBody List<NovaPushResultVO> playerIds) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_PUSH.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(playPlanNvService.pushToLed(planId, playerIds)); |
| | | } |
| | | @GetMapping("/listPaln") |
| | | public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | LambdaQueryWrapper<PlayPlanNv> wrapper = new LambdaQueryWrapper<>();// |
| | | if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())){ |
| | | wrapper= Wrappers.lambdaQuery(PlayPlanNv.class).eq(PlayPlanNv::getUserId,SecurityUtils.getUserId()); |
| | | |
| | | |
| | | @PostMapping(value = "/pushSchedule/{planId}", produces = "application/json;charset=UTF-8") |
| | | public ResponseVO<Object> pushSchedule(@PathVariable Long planId, @RequestBody List<NovaPushResultVO> playerIds) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_PUSH_SCHEDULE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | wrapper=Wrappers.lambdaQuery(PlayPlanNv.class); |
| | | if(null!=keyword){ |
| | | wrapper.like(PlayPlanNv::getName,keyword); |
| | | return ResponseUtil.success(playPlanNvService.pushSchedule(planId, playerIds)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 实时节目 |
| | | * |
| | | * @param pid |
| | | * @param playerIds |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/pushProgram/{pid}", produces = "application/json;charset=UTF-8") |
| | | public ResponseVO<Object> pushProgram(@PathVariable Long pid, @RequestBody List<NovaPushResultVO> playerIds) { |
| | | if (!permissionConfig.check(MenuEnum.LED_N_PLAY_PLAN_PUSH.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.successPage(playPlanNvService.list(wrapper)); |
| | | return ResponseUtil.success(playPlanNvService.pushProgram(pid, playerIds)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/listPlan") |
| | | public ResponseVO<Object> list(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.PLAYPLAN_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | //排序字段 |
| | | String orderByResult = "id"; |
| | | //正序、倒叙 |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.LED_N_PLAY_PLAN_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = " ASC"; |
| | | break; |
| | | case 2: |
| | | orderBySeq = " DESC"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //排序方式 |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy); |
| | | } |
| | | LambdaQueryWrapper<PlayPlanNv> wrapper = Wrappers.lambdaQuery(PlayPlanNv.class); |
| | | |
| | | if (SecurityUtils.getClientId() != null) { |
| | | wrapper = wrapper.eq(PlayPlanNv::getUserId, SecurityUtils.getUserId()).or(w -> { |
| | | w.eq(PlayPlanNv::getClientId, SecurityUtils.getUserId()); |
| | | }); |
| | | } |
| | | if (keyword != null && !keyword.isEmpty()) { |
| | | wrapper = wrapper.like(PlayPlanNv::getName, keyword); |
| | | } |
| | | List<PlayPlanNv> list = playPlanNvService.list(wrapper); |
| | | list.forEach(plan -> { |
| | | plan.setPlan(JSON.parseObject(plan.getSchedules(), List.class)); |
| | | }); |
| | | return ResponseUtil.successPage(list); |
| | | } |
| | | |
| | | } |