2021与蓝度共同重构项目,服务端
liuhaonan
2021-12-20 28ff98c0b807dd212fbda4505f41605f38fc98d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.sandu.ximon.admin.service;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
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.mapper.LEDProgramMapper;
import lombok.AllArgsConstructor;
import nova.traffic.utils.NovaTraffic;
import org.springframework.stereotype.Service;
 
@Service
@AllArgsConstructor
public class LEDProgramService extends BaseServiceImpl<LEDProgramMapper, LEDProgram> {
 
    private final LEDProgramMapper ledProgramMapper;
 
    public boolean addProgram(LEDProgramParam receiveParam) {
  //  public boolean addProgram(String name,Integer kind,String url ) {
 
        LEDProgram led = new LEDProgram();
        led.setUserId(SecurityUtils.getClientId());
        led.setPixel(receiveParam.getPixel());
        led.setSize(receiveParam.getSize());
        led.setName(receiveParam.getName());
        led.setKind(receiveParam.getKind());
        led.setProgramBase64(receiveParam.getProgramBase64());
      /*  LEDProgram led = new LEDProgram();
        led.setUserId(SecurityUtils.getClientId());
        led.setName(name);
        led.setKind(kind);
        led.setProgramBase64(url);*/
 
        return save(led);
    }
 
 
    public boolean updateProgram(LEDProgramParam receiveParam) {
 
        LEDProgram byId = getById(receiveParam.getId());
        if (byId == null) {
            throw new BusinessException("未找到该节目");
        }
 
        LEDProgram led = new LEDProgram();
        led.setId(receiveParam.getId());
        //led.setUserId(SecurityUtils.getClientId());
        led.setPixel(receiveParam.getPixel());
        led.setSize(receiveParam.getSize());
        led.setName(receiveParam.getName());
        led.setKind(receiveParam.getKind());
        led.setProgramBase64(receiveParam.getProgramBase64());
        return updateById(led);
    }
 
 
    public boolean deleteProgram(Long id) {
        LEDProgram byId = getById(id);
        if (byId == null) {
            throw new BusinessException("未找到该节目");
        }
 
        return removeById(id);
 
    }
 
 
    public LambdaQueryWrapper<LEDProgram> listProgram() {
       // LambdaQueryWrapper<LEDProgram> wrapper= new LambdaQueryWrapper<>();
       /* if(SecurityUtils.getClientId()!=null){
            return list(Wrappers.lambdaQuery(LEDProgram.class).eq(LEDProgram::getUserId, SecurityUtils.getClientId()));
        }else {
            return list(Wrappers.lambdaQuery(LEDProgram.class));
        }*/
        if(SecurityUtils.getClientId()!=null){
          return   Wrappers.lambdaQuery(LEDProgram.class).eq(LEDProgram::getUserId,SecurityUtils.getClientId());
        }else {
          return   Wrappers.lambdaQuery(LEDProgram.class);
        }
 
 
    }
 
 
    public void NovaTraffic(String ip, int port){
        NovaTraffic novaTraffic = new NovaTraffic("192.168.0.220", 5000);
 
 
 
    }
 
}