From 098dd2ed33b90a8a14ff0b04bace845ec119244c Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期一, 09 五月 2022 10:40:21 +0800
Subject: [PATCH] fix

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PlayPlanNvController.java |   71 +++++++++++++++++++++++++++++++----
 1 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PlayPlanNvController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PlayPlanNvController.java
index 7fc29c9..6734851 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PlayPlanNvController.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PlayPlanNvController.java
@@ -1,12 +1,24 @@
 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.domain.ResponseVO;
+import com.sandu.common.object.BaseConditionVO;
+import com.sandu.common.security.annotation.AnonymousAccess;
 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.admin.vo.NovaPushResultVO;
+import com.sandu.ximon.dao.domain.PlayPlanNv;
 import lombok.AllArgsConstructor;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * @Author liuhaonan
@@ -18,24 +30,67 @@
 @RequestMapping("/v1/ledPlan")
 public class PlayPlanNvController {
     private final PlayPlanNvService playPlanNvService;
+    private PermissionConfig permissionConfig;
 
+    @AnonymousAccess
     @PostMapping("/add")
     public ResponseVO<Object> addLEDPlan(@RequestBody @Validated PlayPlanParam param) {
         return ResponseUtil.success(playPlanNvService.addPlan(param));
     }
 
-    @PostMapping("/update")
-    public ResponseVO<Object> updateLEDPlan(@RequestBody @Validated Long planId, PlayPlanParam param) {
+    @AnonymousAccess
+    @GetMapping("/getByPlanId/{planId}")
+    public ResponseVO<Object> getPlan(@PathVariable Long planId) {
+        return ResponseUtil.success(playPlanNvService.getByPlanId(planId));
+    }
+
+    @PostMapping("/update/{planId}")
+    public ResponseVO<Object> updateLEDPlan(@PathVariable Long planId, @RequestBody @Validated PlayPlanParam param) {
         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) {
+        return ResponseUtil.success(playPlanNvService.deletePlan(plianIds));
     }
 
-    @PostMapping("/push{plianId}")
-    public ResponseVO<Object> pushToLed(@PathVariable Long plianId) {
-        return ResponseUtil.success(playPlanNvService.pushToLed(plianId));
+    @AnonymousAccess
+    @PostMapping(value = "/push/{plianId}", produces = "application/json;charset=UTF-8")
+    public ResponseVO<Object> pushToLed(@PathVariable Long plianId, @RequestBody List<NovaPushResultVO> playerIds) {
+        return ResponseUtil.success(playPlanNvService.pushToLed(plianId, playerIds));
     }
+
+
+    @AnonymousAccess
+    @PostMapping(value = "/pushSchedule/{planId}", produces = "application/json;charset=UTF-8")
+    public ResponseVO<Object> pushSchedule(@PathVariable Long planId, @RequestBody List<NovaPushResultVO> playerIds) {
+        return ResponseUtil.success(playPlanNvService.pushSchedule(planId, playerIds));
+    }
+
+    @AnonymousAccess
+    @GetMapping("/listPlan")
+    public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+//        if (!permissionConfig.check(MenuEnum.PLAYPLAN_LIST.getCode())) {
+//            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+//        }
+        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+        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.getSchedule(), Map.class));
+            plan.setPlan(JSON.parseObject(plan.getSchedules(), List.class));
+//            plan.setPlan(JSON.parseArray(plan.getSchedule(), SchedulesDTO.class));
+        });
+        return ResponseUtil.successPage(list);
+    }
+
 }

--
Gitblit v1.9.3