From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LEDProgramService.java |   69 +++++++++++++++++++++++++++++++---
 1 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LEDProgramService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LEDProgramService.java
index ee80711..346f302 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LEDProgramService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LEDProgramService.java
@@ -3,16 +3,18 @@
 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.execption.BusinessException;
+import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
 import com.sandu.ximon.admin.param.LEDProgramParam;
 import com.sandu.ximon.admin.security.SecurityUtils;
 import com.sandu.ximon.dao.domain.LEDProgram;
+import com.sandu.ximon.dao.enums.OrderByEnums;
 import com.sandu.ximon.dao.mapper.LEDProgramMapper;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
-import java.time.LocalDateTime;
 import java.util.List;
 
 @Service
@@ -33,6 +35,9 @@
         led.setPreview(receiveParam.getPreviewUrl());
         led.setWidth(receiveParam.getWidth());
         led.setHeight(receiveParam.getHeight());
+        if (receiveParam.getPages() == null) {
+            throw new BusinessException("鑺傜洰鍐呭涓㈠け");
+        }
         led.setPages(JSON.toJSONString(receiveParam.getPages()));
         return save(led);
     }
@@ -49,18 +54,21 @@
         led.setPreview(receiveParam.getPreviewUrl());
         led.setWidth(receiveParam.getWidth());
         led.setHeight(receiveParam.getHeight());
+        if (receiveParam.getPages() == null) {
+            throw new BusinessException("鑺傜洰鍐呭涓㈠け");
+        }
         led.setPages(JSON.toJSONString(receiveParam.getPages()));
         return updateById(led);
     }
 
 
-    public boolean deleteProgram(Long id) {
-        LEDProgram byId = getById(id);
-        if (byId == null) {
+    public boolean deleteProgram(List<Long> pids) {
+        List<LEDProgram> ledPrograms = listByIds(pids);
+        if (ledPrograms.isEmpty()) {
             throw new BusinessException("鏈壘鍒拌鑺傜洰");
         }
 
-        return removeById(id);
+        return removeByIds(pids);
 
     }
 
@@ -79,8 +87,57 @@
         return param;
     }
 
+    public List<LEDProgram> listProgram(BaseConditionVO baseConditionVO, Integer order, Integer seq, String keyword) {
+        LambdaQueryWrapper<LEDProgram> wrapper = listPrograms();
 
-    public LambdaQueryWrapper<LEDProgram> listProgram() {
+        if (keyword != null && !keyword.isEmpty()) {
+            wrapper.like(LEDProgram::getName, keyword);
+        }
+        //鎺掑簭瀛楁
+        String orderByResult = "id";
+        //姝e簭銆佸�掑彊
+        String orderBySeq = OrderByEnums.ASC.getCode();
+        if (order != null) {
+            switch (order) {
+                case 1:
+                    orderByResult = OrderByEnums.LED_N_PROGRAM_CREATE_TIME.getCode();
+                    break;
+                default:
+            }
+        }
+        if (seq != null) {
+            switch (seq) {
+                case 1:
+                    orderBySeq = OrderByEnums.ASC.getCode();
+                    break;
+                case 2:
+                    orderBySeq = OrderByEnums.DESC.getCode();
+                    break;
+                default:
+                    break;
+            }
+        }
+        //鎺掑簭鏂瑰紡
+        String orderBy = orderByResult + " " + orderBySeq;
+
+        if (baseConditionVO != null) {
+            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy);
+        }
+        return list(wrapper);
+    }
+
+    public List<LEDProgram> listProgramOnBinding(String keyword) {
+        LambdaQueryWrapper<LEDProgram> wrapper = listPrograms();
+
+        if (keyword != null && !keyword.isEmpty()) {
+            wrapper.like(LEDProgram::getName, keyword);
+        }
+
+        return list(wrapper);
+    }
+
+
+    public LambdaQueryWrapper<LEDProgram> listPrograms() {
         if (SecurityUtils.getClientId() == null) {
             return Wrappers.lambdaQuery(LEDProgram.class);
         } else {

--
Gitblit v1.9.3