13 changed files with 664 additions and 0 deletions
@ -0,0 +1,83 @@ |
|||
package org.dromara.common.sdk.mqtt; |
|||
|
|||
/** |
|||
* Unified topic request format. |
|||
* @author sean.zhou |
|||
* @date 2021/11/10 |
|||
* @version 0.1 |
|||
*/ |
|||
public class MegaphoneTopicRequest<T> { |
|||
|
|||
/** |
|||
* The command is sent and the response is matched by the tid and bid fields in the message, |
|||
* and the reply should keep the tid and bid the same. |
|||
*/ |
|||
protected String tid; |
|||
|
|||
protected String bid; |
|||
|
|||
protected Long timestamp; |
|||
|
|||
protected String method; |
|||
|
|||
protected T data; |
|||
|
|||
public MegaphoneTopicRequest() { |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "CommonTopicRequest{" + |
|||
"tid='" + tid + '\'' + |
|||
", bid='" + bid + '\'' + |
|||
", method='" + method + '\'' + |
|||
", timestamp=" + timestamp + |
|||
", data=" + data + |
|||
'}'; |
|||
} |
|||
|
|||
public String getTid() { |
|||
return tid; |
|||
} |
|||
|
|||
public MegaphoneTopicRequest<T> setTid(String tid) { |
|||
this.tid = tid; |
|||
return this; |
|||
} |
|||
|
|||
public String getBid() { |
|||
return bid; |
|||
} |
|||
|
|||
public MegaphoneTopicRequest<T> setBid(String bid) { |
|||
this.bid = bid; |
|||
return this; |
|||
} |
|||
|
|||
public String getMethod() { |
|||
return method; |
|||
} |
|||
|
|||
public MegaphoneTopicRequest<T> setMethod(String method) { |
|||
this.method = method; |
|||
return this; |
|||
} |
|||
|
|||
public Long getTimestamp() { |
|||
return timestamp; |
|||
} |
|||
|
|||
public MegaphoneTopicRequest<T> setTimestamp(Long timestamp) { |
|||
this.timestamp = timestamp; |
|||
return this; |
|||
} |
|||
|
|||
public T getData() { |
|||
return data; |
|||
} |
|||
|
|||
public MegaphoneTopicRequest<T> setData(T data) { |
|||
this.data = data; |
|||
return this; |
|||
} |
|||
} |
@ -0,0 +1,172 @@ |
|||
package org.dromara.sample.manage.controller; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import io.seata.common.util.CollectionUtils; |
|||
import io.seata.common.util.StringUtils; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.annotation.Resource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.dubbo.config.annotation.DubboReference; |
|||
import org.dromara.business.api.RemoteBusinessTaskService; |
|||
import org.dromara.common.satoken.utils.LoginHelper; |
|||
import org.dromara.common.sdk.common.HttpResultResponse; |
|||
import org.dromara.common.sdk.common.PaginationData; |
|||
import org.dromara.common.sdk.exception.CloudSDKErrorEnum; |
|||
import org.dromara.common.sdk.mqtt.CommonTopicRequest; |
|||
import org.dromara.common.sdk.mqtt.MegaphoneTopicRequest; |
|||
import org.dromara.common.sdk.mqtt.MqttGatewayPublish; |
|||
import org.dromara.common.sdk.mqtt.TopicConst; |
|||
import org.dromara.common.sdk.mqtt.property.PropertySetPublish; |
|||
import org.dromara.common.sdk.mqtt.property.PropertySetReplyResultEnum; |
|||
import org.dromara.common.sdk.mqtt.property.TopicPropertySetRequest; |
|||
import org.dromara.sample.manage.model.dto.*; |
|||
import org.dromara.sample.manage.service.IDeviceService; |
|||
import org.dromara.system.api.RemoteConfigService; |
|||
import org.dromara.system.api.model.LoginUser; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/15 |
|||
*/ |
|||
@RestController |
|||
@Slf4j |
|||
@RequestMapping("${url.manage.prefix}${url.manage.version}/megaphone") |
|||
@Tag(name = "无人机喊话模块") |
|||
public class MegaphoneController { |
|||
|
|||
public static final String TOPIC = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT; |
|||
|
|||
@Resource |
|||
private MqttGatewayPublish gatewayPublish; |
|||
|
|||
@Resource |
|||
PropertySetPublish propertySetPublish; |
|||
|
|||
@DubboReference |
|||
private RemoteConfigService remoteConfigService; |
|||
/** |
|||
* 喊话器-开始播放文档(对应遥控器的录音广播模式) |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/playStart") |
|||
@Operation(summary = "喊话器-开始播放文档(对应遥控器的录音广播模式)。", description = "喊话器-开始播放文档(对应遥控器的录音广播模式)") |
|||
public HttpResultResponse playStart(@PathVariable("workspace_id") String workspaceId, |
|||
@RequestParam("gatewaySn") String gatewaySn, |
|||
@RequestBody PlayStartDTO param |
|||
) { |
|||
String top = TOPIC+"gatewaySn"+"/services"; |
|||
//发送mqtt
|
|||
propertySetPublish.publishPlayText(top,param,"speaker_tts_play_start"); |
|||
return HttpResultResponse.success(); |
|||
} |
|||
|
|||
/** |
|||
* 喊话器-重新播放文档 |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/replay") |
|||
@Operation(summary = "喊话器-重新播放文档。", description = "喊话器-重新播放文档。") |
|||
public HttpResultResponse replay(@PathVariable("workspace_id") String workspaceId, |
|||
@RequestParam("gatewaySn") String gatewaySn, |
|||
@RequestBody RePlayDTO param |
|||
) { |
|||
String top = TOPIC+gatewaySn+"/services"; |
|||
//发送mqtt
|
|||
propertySetPublish.publishPlayText(top,param,"speaker_replay"); |
|||
return HttpResultResponse.success(); |
|||
} |
|||
/** |
|||
* 喊话器-暂停播放文档 |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/playStop") |
|||
@Operation(summary = "喊话器-暂停播放文档。", description = "喊话器-暂停播放文档。") |
|||
public HttpResultResponse playStop(@PathVariable("workspace_id") String workspaceId, |
|||
@RequestParam("gatewaySn") String gatewaySn, |
|||
@RequestBody RePlayDTO param |
|||
) { |
|||
String top = TOPIC+gatewaySn+"/services"; |
|||
//发送mqtt
|
|||
propertySetPublish.publishPlayText(top,param,"speaker_play_stop"); |
|||
return HttpResultResponse.success(); |
|||
} |
|||
|
|||
/** |
|||
* 喊话器-设置播放模式 |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/playModeSet") |
|||
@Operation(summary = "喊话器-设置播放模式。", description = "喊话器-设置播放模式。") |
|||
public HttpResultResponse playModeSet(@PathVariable("workspace_id") String workspaceId, |
|||
@RequestParam("gatewaySn") String gatewaySn, |
|||
@RequestBody RePlayDTO param |
|||
) { |
|||
String top = TOPIC+gatewaySn+"/services"; |
|||
//发送mqtt
|
|||
propertySetPublish.publishPlayText(top,param,"speaker_play_mode_set"); |
|||
return HttpResultResponse.success(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 喊话器-设置播放模式 |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/widgetValueSet") |
|||
@Operation(summary = "喊话器-设置音量。", description = "喊话器-设置音量。") |
|||
public int widgetValueSet(@PathVariable("workspace_id") String workspaceId, |
|||
@RequestParam("gatewaySn") String gatewaySn, |
|||
@RequestBody PlayVolumeDTO param |
|||
) { |
|||
String top = TOPIC+gatewaySn+"/services"; |
|||
//发送mqtt
|
|||
PropertySetReplyResultEnum psdkWidgetValueSet = propertySetPublish.publishPlayText(top,param,"psdk_widget_value_set"); |
|||
return psdkWidgetValueSet.getResult(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 获取媒体流ip |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/getStreamIp") |
|||
@Operation(summary = "获取媒体流ip。", description = "获取媒体流ip。") |
|||
public HttpResultResponse getStreamIp(@PathVariable("workspace_id") String workspaceId, |
|||
@RequestBody DisobeyDTO param |
|||
) { |
|||
String top = "task/image/disobey/smoke"; |
|||
//发送mqtt
|
|||
String s = remoteConfigService.selectStreamIp(); |
|||
if (StringUtils.isNotEmpty(param.getModel())){ |
|||
String[] split = param.getModel().split(","); |
|||
for (String type : split){ |
|||
List<String> list = new ArrayList<>(); |
|||
list.add(type); |
|||
DisobeyDTO disobeyDTO = new DisobeyDTO(); |
|||
disobeyDTO.setUrl(s); |
|||
disobeyDTO.setOpen(param.getOpen()); |
|||
disobeyDTO.setType(list); |
|||
gatewayPublish.publish(top,new CommonTopicRequest<>() |
|||
.setData(Objects.requireNonNull(disobeyDTO)),1); |
|||
} |
|||
} |
|||
return HttpResultResponse.success(); |
|||
} |
|||
} |
@ -0,0 +1,77 @@ |
|||
package org.dromara.sample.manage.controller; |
|||
|
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.annotation.Resource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.dromara.common.satoken.utils.LoginHelper; |
|||
import org.dromara.common.sdk.common.HttpResultResponse; |
|||
import org.dromara.common.sdk.common.PaginationData; |
|||
import org.dromara.common.sdk.mqtt.MegaphoneTopicRequest; |
|||
import org.dromara.common.sdk.mqtt.MqttGatewayPublish; |
|||
import org.dromara.common.sdk.mqtt.TopicConst; |
|||
import org.dromara.sample.manage.model.dto.DeviceDTO; |
|||
import org.dromara.sample.manage.model.dto.TextDTO; |
|||
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
|||
import org.dromara.sample.manage.service.IDeviceService; |
|||
import org.dromara.sample.manage.service.IPlayTextService; |
|||
import org.dromara.system.api.model.LoginUser; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Objects; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/15 |
|||
*/ |
|||
@RestController |
|||
@Slf4j |
|||
@RequestMapping("${url.manage.prefix}${url.manage.version}/playText") |
|||
@Tag(name = "喊话text模版") |
|||
public class PlayTextController { |
|||
|
|||
|
|||
@Autowired |
|||
private IPlayTextService playTextService; |
|||
|
|||
/** |
|||
* 获取一个工作区中所有在线设备的列表。 |
|||
* Get the topology list of all online devices in one workspace. |
|||
* @return |
|||
*/ |
|||
@PostMapping("/{workspace_id}/playText/add") |
|||
@Operation(summary = "喊话text模版新增。", description = "喊话text模版新增") |
|||
public HttpResultResponse playTextAdd(@RequestBody PlayTextEntity param |
|||
) { |
|||
return playTextService.insertPlayText(param); |
|||
} |
|||
|
|||
@PostMapping("/{workspace_id}/playText/update") |
|||
@Operation(summary = "喊话text模版修改。", description = "喊话text模版修改") |
|||
public HttpResultResponse playTextUpdate(@RequestBody PlayTextEntity param |
|||
) { |
|||
return playTextService.updatePlayText(param); |
|||
} |
|||
|
|||
@PutMapping("/{workspace_id}/playText/deleted") |
|||
@Operation(summary = "喊话text模版删除", description = "喊话text模版删除") |
|||
public HttpResultResponse playTextDeleted(@RequestParam(name = "textSn") String textSn |
|||
) { |
|||
return playTextService.deletedPlayText(textSn); |
|||
} |
|||
|
|||
@PostMapping("/{workspace_id}/playText/page") |
|||
@Operation(summary = "喊话text模版列表", description = "喊话text模版列表") |
|||
public HttpResultResponse<PaginationData<PlayTextEntity>> pageText( |
|||
@RequestParam(name = "pageNum", defaultValue = "1") Long page, |
|||
@RequestParam(name = "pageSize", defaultValue = "10") Long pageSize |
|||
) { |
|||
PaginationData<PlayTextEntity> pageText = playTextService.pageText(page, pageSize); |
|||
return HttpResultResponse.success(pageText); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.sample.manage.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.dromara.sample.manage.model.entity.DeviceEntity; |
|||
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
|||
|
|||
/** |
|||
* |
|||
* @author sean.zhou |
|||
* @date 2021/11/10 |
|||
* @version 0.1 |
|||
*/ |
|||
public interface IPlayTextMapper extends BaseMapper<PlayTextEntity> { |
|||
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package org.dromara.sample.manage.model.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/23 |
|||
*/ |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class DisobeyDTO { |
|||
//1 开 2 关
|
|||
private int open; |
|||
|
|||
private String url; |
|||
|
|||
private String model; |
|||
|
|||
private List<String> type; |
|||
} |
@ -0,0 +1,22 @@ |
|||
package org.dromara.sample.manage.model.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/23 |
|||
*/ |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class FileDTO { |
|||
|
|||
private String format; |
|||
|
|||
private String md5; |
|||
|
|||
private String name; |
|||
|
|||
private String url; |
|||
} |
@ -0,0 +1,18 @@ |
|||
package org.dromara.sample.manage.model.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/23 |
|||
*/ |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class PlayStartDTO { |
|||
|
|||
private int psdkIndex; |
|||
|
|||
TextDTO tts; |
|||
} |
@ -0,0 +1,19 @@ |
|||
package org.dromara.sample.manage.model.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/23 |
|||
*/ |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class PlayVolumeDTO { |
|||
|
|||
private int psdk_index; |
|||
|
|||
private int play_volume; |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package org.dromara.sample.manage.model.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/23 |
|||
*/ |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class RePlayDTO { |
|||
|
|||
private int psdk_index; |
|||
|
|||
private int play_mode; |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package org.dromara.sample.manage.model.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/23 |
|||
*/ |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class TextDTO { |
|||
|
|||
private String md5; |
|||
|
|||
private String name; |
|||
|
|||
private String text; |
|||
} |
@ -0,0 +1,48 @@ |
|||
package org.dromara.sample.manage.model.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.time.LocalDateTime; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* The entity class of the device |
|||
* |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/10 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@TableName(value = "play_text") |
|||
public class PlayTextEntity implements Serializable { |
|||
|
|||
@TableId(type = IdType.AUTO) |
|||
private Integer id; |
|||
|
|||
@TableField(value = "text_sn") |
|||
private String textSn; |
|||
|
|||
@TableField(value = "name") |
|||
private String name; |
|||
|
|||
@TableField(value = "text") |
|||
private String text; |
|||
|
|||
@TableField(value = "md5") |
|||
private String md5; |
|||
|
|||
@TableField(fill = FieldFill.INSERT) |
|||
private Date createTime; |
|||
|
|||
@TableField(fill = FieldFill.INSERT_UPDATE) |
|||
private Date updateTime; |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package org.dromara.sample.manage.service; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import org.dromara.common.sdk.cloudapi.device.ControlSourceEnum; |
|||
import org.dromara.common.sdk.cloudapi.device.DeviceOsdHost; |
|||
import org.dromara.common.sdk.cloudapi.device.DockModeCodeEnum; |
|||
import org.dromara.common.sdk.cloudapi.device.DroneModeCodeEnum; |
|||
import org.dromara.common.sdk.common.HttpResultResponse; |
|||
import org.dromara.common.sdk.common.PaginationData; |
|||
import org.dromara.common.sdk.config.version.GatewayManager; |
|||
import org.dromara.common.websocket.dto.BizCodeEnum; |
|||
import org.dromara.sample.manage.model.dto.DeviceDTO; |
|||
import org.dromara.sample.manage.model.dto.DeviceFirmwareUpgradeDTO; |
|||
import org.dromara.sample.manage.model.dto.TopologyDeviceDTO; |
|||
import org.dromara.sample.manage.model.dto.WorkspaceDTO; |
|||
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
|||
import org.dromara.sample.manage.model.param.DeviceQueryParam; |
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
/** |
|||
* @author sean.zhou |
|||
* @date 2021/11/10 |
|||
* @version 0.1 |
|||
*/ |
|||
public interface IPlayTextService { |
|||
|
|||
HttpResultResponse insertPlayText(PlayTextEntity param); |
|||
|
|||
HttpResultResponse updatePlayText(PlayTextEntity param); |
|||
|
|||
HttpResultResponse deletedPlayText(String textSn); |
|||
|
|||
PaginationData<PlayTextEntity> pageText(Long page, Long pageSize); |
|||
|
|||
} |
@ -0,0 +1,110 @@ |
|||
package org.dromara.sample.manage.service.impl; |
|||
|
|||
import cn.hutool.crypto.SecureUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.dromara.common.sdk.cloudapi.device.*; |
|||
import org.dromara.common.sdk.cloudapi.firmware.*; |
|||
import org.dromara.common.sdk.cloudapi.firmware.api.AbstractFirmwareService; |
|||
import org.dromara.common.sdk.cloudapi.property.api.AbstractPropertyService; |
|||
import org.dromara.common.sdk.cloudapi.tsa.DeviceIconUrl; |
|||
import org.dromara.common.sdk.cloudapi.tsa.TopologyDeviceModel; |
|||
import org.dromara.common.sdk.common.*; |
|||
import org.dromara.common.sdk.config.version.GatewayManager; |
|||
import org.dromara.common.sdk.exception.CloudSDKException; |
|||
import org.dromara.common.sdk.mqtt.IMqttTopicService; |
|||
import org.dromara.common.sdk.mqtt.MqttGatewayPublish; |
|||
import org.dromara.common.sdk.mqtt.events.EventsSubscribe; |
|||
import org.dromara.common.sdk.mqtt.osd.OsdSubscribe; |
|||
import org.dromara.common.sdk.mqtt.property.PropertySetReplyResultEnum; |
|||
import org.dromara.common.sdk.mqtt.property.PropertySetSubscribe; |
|||
import org.dromara.common.sdk.mqtt.requests.RequestsSubscribe; |
|||
import org.dromara.common.sdk.mqtt.services.ServicesReplyData; |
|||
import org.dromara.common.sdk.mqtt.services.ServicesSubscribe; |
|||
import org.dromara.common.sdk.mqtt.services.TopicServicesResponse; |
|||
import org.dromara.common.sdk.mqtt.state.StateSubscribe; |
|||
import org.dromara.common.sdk.mqtt.status.StatusSubscribe; |
|||
import org.dromara.common.websocket.dto.BizCodeEnum; |
|||
import org.dromara.sample.common.error.CommonErrorEnum; |
|||
import org.dromara.sample.component.mqtt.model.EventsReceiver; |
|||
import org.dromara.sample.control.model.enums.DroneAuthorityEnum; |
|||
import org.dromara.sample.manage.mapper.IDeviceMapper; |
|||
import org.dromara.sample.manage.mapper.IPlayTextMapper; |
|||
import org.dromara.sample.manage.model.dto.*; |
|||
import org.dromara.sample.manage.model.entity.DeviceEntity; |
|||
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
|||
import org.dromara.sample.manage.model.enums.DeviceFirmwareStatusEnum; |
|||
import org.dromara.sample.manage.model.enums.PropertySetFieldEnum; |
|||
import org.dromara.sample.manage.model.enums.UserTypeEnum; |
|||
import org.dromara.sample.manage.model.param.DeviceQueryParam; |
|||
import org.dromara.sample.manage.model.receiver.BasicDeviceProperty; |
|||
import org.dromara.sample.manage.service.*; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
import java.util.UUID; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* |
|||
* @author sean.zhou |
|||
* @version 0.1 |
|||
* @date 2021/11/10 |
|||
*/ |
|||
@Service |
|||
@Slf4j |
|||
@Transactional |
|||
public class PlayTextServiceImpl implements IPlayTextService { |
|||
@Autowired |
|||
private IPlayTextMapper playTextMapper; |
|||
|
|||
|
|||
@Override |
|||
public HttpResultResponse insertPlayText(PlayTextEntity param) { |
|||
param.setTextSn(String.valueOf(UUID.randomUUID())); |
|||
param.setMd5(SecureUtil.md5(param.getText())); |
|||
if(playTextMapper.insert(param) > 0){ |
|||
return HttpResultResponse.success(); |
|||
} |
|||
return HttpResultResponse.error("新增失败"); |
|||
} |
|||
|
|||
@Override |
|||
public HttpResultResponse updatePlayText(PlayTextEntity param) { |
|||
param.setMd5(SecureUtil.md5(param.getText())); |
|||
int update = playTextMapper.update(param, |
|||
new LambdaUpdateWrapper<PlayTextEntity>().eq(PlayTextEntity::getTextSn, param.getTextSn())); |
|||
if(update > 0){ |
|||
return HttpResultResponse.success(); |
|||
} |
|||
return HttpResultResponse.error("修改失败"); |
|||
} |
|||
|
|||
@Override |
|||
public HttpResultResponse deletedPlayText(String textSn) { |
|||
int delete = playTextMapper.delete( |
|||
new LambdaUpdateWrapper<PlayTextEntity>().eq(PlayTextEntity::getTextSn, textSn)); |
|||
if(delete > 0){ |
|||
return HttpResultResponse.success(); |
|||
} |
|||
return HttpResultResponse.error("删除失败"); |
|||
} |
|||
|
|||
@Override |
|||
public PaginationData<PlayTextEntity> pageText(Long page, Long pageSize) { |
|||
Page<PlayTextEntity> pagination = playTextMapper.selectPage(new Page<>(page, pageSize), |
|||
new LambdaQueryWrapper<PlayTextEntity>() |
|||
.orderByDesc(true,PlayTextEntity::getId)); |
|||
return new PaginationData<PlayTextEntity>(pagination.getRecords(), new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal())); |
|||
} |
|||
} |
Loading…
Reference in new issue