| | |
| | | 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; |
| | | 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; |
| | |
| | | @AllArgsConstructor |
| | | public class LEDProgramService extends BaseServiceImpl<LEDProgramMapper, LEDProgram> { |
| | | |
| | | 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.setUserId(SecurityUtils.getClientId()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | led.setUserName(SecurityUtils.getUsername()); |
| | | } |
| | | led.setName(receiveParam.getName()); |
| | | led.setKind(receiveParam.getKind()); |
| | | |
| | | led.setPreview(receiveParam.getPreviewUrl()); |
| | | led.setPages(JSON.toJSONString(receiveParam.getPages())); |
| | | // led.setPages(JSONArray.fromObject(receiveParam.getPages()).toString()); |
| | | 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.setUserId(SecurityUtils.getClientId()); |
| | | led.setId(pid); |
| | | //led.setUserId(SecurityUtils.getClientId()); |
| | | led.setName(receiveParam.getName()); |
| | | led.setKind(receiveParam.getKind()); |
| | | if (receiveParam.getPixel() != null) { |
| | | led.setPixel(receiveParam.getPixel()); |
| | | } |
| | | if (receiveParam.getSize() != null) { |
| | | led.setSize(receiveParam.getSize()); |
| | | } |
| | | led.setPreview(receiveParam.getPreviewUrl()); |
| | | led.setPages(receiveParam.getPages().toString()); |
| | | return updateById(led); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public LambdaQueryWrapper<LEDProgram> listProgram() { |
| | | if (SecurityUtils.getClientId() != null) { |
| | | return Wrappers.lambdaQuery(LEDProgram.class).eq(LEDProgram::getUserId, SecurityUtils.getClientId()); |
| | | } else { |
| | | return Wrappers.lambdaQuery(LEDProgram.class); |
| | | } |
| | | } |
| | | |
| | | } |