2021与蓝度共同重构项目,服务端
liuhaonan
2022-03-04 213ead12843a2cf6be2a3fd8c46c20ddd27bf359
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LEDProgramService.java
@@ -1,5 +1,6 @@
package com.sandu.ximon.admin.service;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
@@ -10,6 +11,8 @@
import com.sandu.ximon.dao.mapper.LEDProgramMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
@@ -26,24 +29,28 @@
        }
        led.setName(receiveParam.getName());
        led.setPreview(receiveParam.getPreviewUrl());
        led.setPages(receiveParam.getPages());
        led.setWidth(receiveParam.getWidth());
        led.setHeight(receiveParam.getHeight());
        led.setPages(JSON.toJSONString(receiveParam.getPages()));
        return save(led);
    }
    public boolean updateProgram(LEDProgramParam receiveParam) {
    public boolean updateProgram(Long pid,LEDProgramParam receiveParam) {
        LEDProgram byId = getById(receiveParam.getId());
        LEDProgram byId = getById(pid);
        if (byId == null) {
            throw new BusinessException("未找到该节目");
        }
        LEDProgram led = new LEDProgram();
        led.setId(receiveParam.getId());
        led.setId(pid);
        //led.setUserId(SecurityUtils.getClientId());
        led.setName(receiveParam.getName());
        led.setPreview(receiveParam.getPreviewUrl());
        led.setPages(receiveParam.getPages());
        led.setWidth(receiveParam.getWidth());
        led.setHeight(receiveParam.getHeight());
        led.setPages(JSON.toJSONString(receiveParam.getPages()));
        return updateById(led);
    }
@@ -58,6 +65,21 @@
    }
    public LEDProgramParam getByPid(Long id) {
        LEDProgram byId = getById(id);
        if (byId == null) {
            throw new BusinessException("未找到该节目");
        }
        LEDProgramParam param=new LEDProgramParam();
        param.setId(byId.getId());
        param.setHeight(byId.getHeight());
        param.setWidth(byId.getWidth());
        param.setName(byId.getName());
        param.setPreviewUrl(byId.getPreview());
        param.setPages(JSON.parseObject(byId.getPages(), List.class));
        return param;
    }
    public LambdaQueryWrapper<LEDProgram> listProgram() {
        if (SecurityUtils.getClientId() != null) {