| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class LEDProgramService extends BaseServiceImpl<LEDProgramMapper, LEDProgram> { |
| | | |
| | | |
| | | private final ClientService clientService; |
| | | |
| | | public boolean addProgram(LEDProgramParam receiveParam) { |
| | | |
| | | LEDProgram led = new LEDProgram(); |
| | | led.setUserId(SecurityUtils.getClientId()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | led.setUserName(SecurityUtils.getUsername()); |
| | | led.setUserId(SecurityUtils.getUserId()); |
| | | led.setUserName(SecurityUtils.getUsername()); |
| | | if (clientService.findClientId()) { |
| | | led.setClientId(clientService.getClientId()); |
| | | } |
| | | led.setName(receiveParam.getName()); |
| | | led.setPreview(receiveParam.getPreviewUrl()); |
| | |
| | | } |
| | | |
| | | |
| | | public boolean updateProgram(Long pid,LEDProgramParam receiveParam) { |
| | | public boolean updateProgram(Long pid, LEDProgramParam receiveParam) { |
| | | |
| | | LEDProgram byId = getById(pid); |
| | | if (byId == null) { |
| | | LEDProgram led = getById(pid); |
| | | if (led == null) { |
| | | throw new BusinessException("未找到该节目"); |
| | | } |
| | | |
| | | LEDProgram led = new LEDProgram(); |
| | | led.setId(pid); |
| | | //led.setUserId(SecurityUtils.getClientId()); |
| | | led.setName(receiveParam.getName()); |
| | | led.setPreview(receiveParam.getPreviewUrl()); |
| | | led.setWidth(receiveParam.getWidth()); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | public LambdaQueryWrapper<LEDProgram> listProgram() { |
| | | if (SecurityUtils.getClientId() != null) { |
| | | return Wrappers.lambdaQuery(LEDProgram.class).eq(LEDProgram::getUserId, SecurityUtils.getClientId()); |
| | | } else { |
| | | return Wrappers.lambdaQuery(LEDProgram.class); |
| | | public LEDProgramParam getByPid(Long id) { |
| | | LEDProgram byId = getById(id); |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到该节目"); |
| | | } |
| | | LEDProgramParam param = new LEDProgramParam(); |
| | | param.setId(byId.getId()); |
| | | param.setHeight(byId.getHeight()); |
| | | param.setWidth(byId.getWidth()); |
| | | param.setName(byId.getName()); |
| | | param.setPreviewUrl(byId.getPreview()); |
| | | param.setPages(JSON.parseObject(byId.getPages(), List.class)); |
| | | return param; |
| | | } |
| | | |
| | | |
| | | public LambdaQueryWrapper<LEDProgram> listProgram() { |
| | | if (SecurityUtils.getClientId() == null) { |
| | | return Wrappers.lambdaQuery(LEDProgram.class); |
| | | } else { |
| | | return Wrappers.lambdaQuery(LEDProgram.class).eq(LEDProgram::getUserId, SecurityUtils.getUserId()) |
| | | .or(w -> { |
| | | w.eq(LEDProgram::getClientId, SecurityUtils.getClientId()); |
| | | }); |
| | | } |
| | | } |
| | | } |