2021与蓝度共同重构项目,服务端
liuhaonan
2021-12-13 e99a7c85fa0864e7b326b8d3ae7234d228f5cdb1
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
package com.sandu.ximon.admin.service;
 
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.param.PlayPlanParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.domain.PlayPlan;
import com.sandu.ximon.dao.enums.AdministratorEnums;
import com.sandu.ximon.dao.mapper.PlayPlanMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
/**
 * 播放计划
 */
@Service
@AllArgsConstructor
public class PlayPlanService extends BaseServiceImpl<PlayPlanMapper, PlayPlan> {
 
    private final PlayPlanMapper playPlanMapper;
 
    public boolean addPlan(PlayPlanParam playPlanParam){
 
        PlayPlan playPlan=new PlayPlan();
        if( AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())){
            playPlan.setUserId(SecurityUtils.getUserId());
        }
        playPlan.setName(playPlanParam.getName());
        playPlan.setLedProgramName(playPlanParam.getLedProgramName());
        playPlan.setLedProgramId(playPlanParam.getLedProgramId());
        playPlan.setVolume(playPlanParam.getVolume());
        playPlan.setApplySeries(playPlanParam.getApplySeries());
        playPlan.setOnDateRange(playPlanParam.getOnDateRange());
        playPlan.setOffDateRange(playPlanParam.getOffDateRange());
        playPlan.setWeekRange(playPlanParam.getWeekRange());
        playPlan.setOnTime(playPlanParam.getOnTime());
        playPlan.setOffTime(playPlanParam.getOffTime());
 
     return save(playPlan);
 
    }
    public boolean updatePlan(Long id,PlayPlanParam playPlanParam){
        PlayPlan byId = getById(id);
        if(byId==null){
            throw new BusinessException("操作对象不存在");
        }
        PlayPlan playPlan=new PlayPlan();
        playPlan.setId(id);
        playPlan.setName(playPlanParam.getName());
        playPlan.setLedProgramName(playPlanParam.getLedProgramName());
        playPlan.setLedProgramId(playPlanParam.getLedProgramId());
        playPlan.setVolume(playPlanParam.getVolume());
        playPlan.setApplySeries(playPlanParam.getApplySeries());
        playPlan.setOnDateRange(playPlanParam.getOnDateRange());
        playPlan.setOffDateRange(playPlanParam.getOffDateRange());
        playPlan.setWeekRange(playPlanParam.getWeekRange());
        playPlan.setOnTime(playPlanParam.getOnTime());
        playPlan.setOffTime(playPlanParam.getOffTime());
 
        return updateById(playPlan);
 
    }
    public boolean deletePlan(Long id){
        PlayPlan byId = getById(id);
        if(byId==null){
            throw new BusinessException("操作对象不存在");
        }
 
     return removeById(id);
 
    }
}