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 { 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); } }