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.LEDProgramParam; import com.sandu.ximon.admin.security.SecurityUtils; import com.sandu.ximon.dao.domain.LEDProgram; import com.sandu.ximon.dao.enums.AdministratorEnums; import com.sandu.ximon.dao.mapper.LEDProgramMapper; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @Service @AllArgsConstructor public class LEDProgramService extends BaseServiceImpl { private final LEDProgramMapper ledProgramMapper; public boolean addProgram(LEDProgramParam receiveParam) { LEDProgram led = new LEDProgram(); if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getClientId())) { led.setUserId(SecurityUtils.getUserId()); } led.setName(receiveParam.getName()); led.setKind(receiveParam.getKind()); 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()); if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getClientId())) { led.setUserId(SecurityUtils.getUserId()); } led.setName(receiveParam.getName()); led.setKind(receiveParam.getKind()); if (receiveParam.getPixel() != null) { led.setPixel(receiveParam.getPixel()); } if (receiveParam.getSize() != null) { led.setSize(receiveParam.getSize()); } return updateById(led); } public boolean deleteProgram(Long id) { LEDProgram byId = getById(id); if (byId == null) { throw new BusinessException("未找到该节目"); } return removeById(id); } }