fix:通道配置和模板配置完成

V0.5.x
tangfudong 2023-06-16 18:44:35 +08:00
parent d85c06e5fc
commit 04505e3495
27 changed files with 175 additions and 192 deletions

View File

@ -1,20 +1,20 @@
[ [
{ {
"id": "1", "id": 1,
"code": "DingTalk", "code": "DingTalk",
"title": "钉钉", "title": "钉钉",
"icon": "http://www.baidu.com", "icon": "http://www.baidu.com",
"createAt": 1683816661690 "createAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb832", "id": 2,
"code": "QyWechat", "code": "QyWechat",
"title": "企业微信", "title": "企业微信",
"icon": "http://www.baidu.com", "icon": "http://www.baidu.com",
"createAt": 1683816661690 "createAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb833", "id": 3,
"code": "Email", "code": "Email",
"title": "邮箱", "title": "邮箱",
"icon": "http://www.baidu.com", "icon": "http://www.baidu.com",

View File

@ -1,7 +1,7 @@
[ [
{ {
"id": "947d22b7-305b-d959-874a-06e277143d44", "id": 1312312,
"channelId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831", "channelId": 3,
"title": "告警邮件配置", "title": "告警邮件配置",
"param": { "param": {
"userName":"xxx", "userName":"xxx",
@ -15,8 +15,8 @@
"createAt": 1683816661690 "createAt": 1683816661690
}, },
{ {
"id": "75f37720-22bb-4f0b-f127-78f2091507a0", "id": 1313123,
"channelId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb832", "channelId": 1,
"title": "告警钉钉配置", "title": "告警钉钉配置",
"param": { "param": {
"dingTalkWebhook":"xxxxxxxxxxxxxxxx", "dingTalkWebhook":"xxxxxxxxxxxxxxxx",
@ -25,8 +25,8 @@
"createAt": 1683816661690 "createAt": 1683816661690
}, },
{ {
"id": "6e5db9b5-a709-723b-665b-bbca5ce6a62c", "id": 32141342,
"channelId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb833", "channelId": 2,
"title": "告警企业微信配置", "title": "告警企业微信配置",
"param": { "param": {
"qyWechatWebhook":"xxxxxxxxxxxxxxxx" "qyWechatWebhook":"xxxxxxxxxxxxxxxx"

View File

@ -1,23 +1,23 @@
[ [
{ {
"id": "0640bbe2-788e-ca94-5fb4-c5e7f91e546d", "id": 12312312,
"channelConfigId": "947d22b7-305b-d959-874a-06e277143d44", "channelConfigId": 1312312,
"channelCode": "Email", "channelCode": "Email",
"title": "告警邮件模板", "title": "告警邮件模板",
"content": "您的设备【${title}】<font color=\"warning\">温度过高</font>", "content": "您的设备【${title}】<font color=\"warning\">温度过高</font>",
"createAt": 1683816661690 "createAt": 1683816661690
}, },
{ {
"id": "7fd90ab1-63c8-cd92-2a58-b7bd04f557f1", "id": 342353425,
"channelConfigId": "75f37720-22bb-4f0b-f127-78f2091507a0", "channelConfigId": 1313123,
"channelCode": "DingTalk", "channelCode": "DingTalk",
"title": "告警钉钉模板", "title": "告警钉钉模板",
"content": "您的设备【${title}】<font color=\"warning\">温度过高</font>", "content": "您的设备【${title}】<font color=\"warning\">温度过高</font>",
"createAt": 1683816661690 "createAt": 1683816661690
}, },
{ {
"id": "74ece781-1d84-220b-cbb2-3270e245bb3b", "id": 786778567,
"channelConfigId": "6e5db9b5-a709-723b-665b-bbca5ce6a62c", "channelConfigId": 32141342,
"channelCode": "QyWechat", "channelCode": "QyWechat",
"title": "告警企业微信模板", "title": "告警企业微信模板",
"content": "您的设备【${title}】<font color=\"warning\">温度过高</font>", "content": "您的设备【${title}】<font color=\"warning\">温度过高</font>",

View File

@ -1,6 +1,6 @@
[ [
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831", "id": 1231312,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -8,7 +8,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb832", "id": 4324234,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -16,7 +16,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb833", "id": 151515,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": false, "status": false,
@ -24,7 +24,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb834", "id": 4534636,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -32,7 +32,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb835", "id":4534346,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": false, "status": false,
@ -40,7 +40,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb836", "id": 64432342,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -48,7 +48,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb837", "id": 5756,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -56,7 +56,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb838", "id": 56856,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -64,7 +64,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb839", "id": 31,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": false, "status": false,
@ -72,7 +72,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb840", "id": 67567,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,
@ -80,7 +80,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb841", "id": 9789,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": false, "status": false,
@ -88,7 +88,7 @@
"updateAt": 1683816661690 "updateAt": 1683816661690
}, },
{ {
"id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb842", "id": 90890,
"content": "你的设备【热水器】温度过高", "content": "你的设备【热水器】温度过高",
"messageType": "alert", "messageType": "alert",
"status": true, "status": true,

View File

@ -15,9 +15,9 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class Channel implements Id<String> { public class Channel implements Id<Long> {
private String id; private Long id;
private String code; private String code;

View File

@ -18,11 +18,11 @@ import java.io.Serializable;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ChannelConfig implements Id<String> { public class ChannelConfig implements Id<Long> {
private String id; private Long id;
private String channelId; private Long channelId;
private String title; private String title;

View File

@ -15,11 +15,11 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ChannelTemplate implements Id<String> { public class ChannelTemplate implements Id<Long> {
private String id; private Long id;
private String channelConfigId; private Long channelConfigId;
private String title; private String title;

View File

@ -15,9 +15,9 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class NotifyMessage implements Id<String> { public class NotifyMessage implements Id<Long> {
private String id; private Long id;
private String content; private String content;

View File

@ -10,11 +10,10 @@
package cc.iotkit.data; package cc.iotkit.data;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.model.Id;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.model.Id;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**

View File

@ -8,5 +8,5 @@ import cc.iotkit.model.notify.ChannelConfig;
* date: 2023-05-11 17:15 * date: 2023-05-11 17:15
* description: * description:
**/ **/
public interface IChannelConfigData extends ICommonData<ChannelConfig, String> { public interface IChannelConfigData extends ICommonData<ChannelConfig, Long> {
} }

View File

@ -8,6 +8,6 @@ import cc.iotkit.model.notify.Channel;
* date: 2023-05-11 17:15 * date: 2023-05-11 17:15
* description: * description:
**/ **/
public interface IChannelData extends ICommonData<Channel, String> { public interface IChannelData extends ICommonData<Channel, Long> {
} }

View File

@ -8,5 +8,5 @@ import cc.iotkit.model.notify.ChannelTemplate;
* date: 2023-05-11 17:15 * date: 2023-05-11 17:15
* description: * description:
**/ **/
public interface IChannelTemplateData extends ICommonData<ChannelTemplate, String> { public interface IChannelTemplateData extends ICommonData<ChannelTemplate, Long> {
} }

View File

@ -8,5 +8,5 @@ import cc.iotkit.model.notify.NotifyMessage;
* @Date: 2023/5/13 18:32 * @Date: 2023/5/13 18:32
* @Description: * @Description:
*/ */
public interface INotifyMessageData extends ICommonData<NotifyMessage, String> { public interface INotifyMessageData extends ICommonData<NotifyMessage, Long> {
} }

View File

@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
* @Date: 2023/5/11 21:00 * @Date: 2023/5/11 21:00
* @Description: * @Description:
*/ */
public interface ChannelConfigRepository extends JpaRepository<TbChannelConfig, String> { public interface ChannelConfigRepository extends JpaRepository<TbChannelConfig, Long> {
} }

View File

@ -25,7 +25,7 @@ public class TbChannel {
@GeneratedValue(generator = "SnowflakeIdGenerator") @GeneratedValue(generator = "SnowflakeIdGenerator")
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator") @GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
@ApiModelProperty(value = "通道id") @ApiModelProperty(value = "通道id")
private String id; private Long id;
@ApiModelProperty(value = "通道名称") @ApiModelProperty(value = "通道名称")
private String code; private String code;

View File

@ -24,10 +24,10 @@ public class TbChannelConfig {
@GeneratedValue(generator = "SnowflakeIdGenerator") @GeneratedValue(generator = "SnowflakeIdGenerator")
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator") @GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
@ApiModelProperty(value = "通道配置id") @ApiModelProperty(value = "通道配置id")
private String id; private Long id;
@ApiModelProperty(value = "通道id") @ApiModelProperty(value = "通道id")
private String channelId; private Long channelId;
@ApiModelProperty(value = "通道配置名称") @ApiModelProperty(value = "通道配置名称")
private String title; private String title;

View File

@ -27,10 +27,10 @@ public class TbChannelTemplate {
@GeneratedValue(generator = "SnowflakeIdGenerator") @GeneratedValue(generator = "SnowflakeIdGenerator")
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator") @GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
@ApiModelProperty(value = "通道模板id") @ApiModelProperty(value = "通道模板id")
private String id; private Long id;
@ApiModelProperty(value = "通道配置id") @ApiModelProperty(value = "通道配置id")
private String channelConfigId; private Long channelConfigId;
@ApiModelProperty(value = "通道模板名称") @ApiModelProperty(value = "通道模板名称")
private String title; private String title;

View File

@ -1,5 +1,7 @@
package cc.iotkit.data.model; package cc.iotkit.data.model;
import cc.iotkit.model.notify.NotifyMessage;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -19,12 +21,13 @@ import javax.persistence.Table;
@Entity @Entity
@ApiModel(value = "通知消息") @ApiModel(value = "通知消息")
@Table(name = "notify_message") @Table(name = "notify_message")
@AutoMapper(target= NotifyMessage.class)
public class TbNotifyMessage { public class TbNotifyMessage {
@Id @Id
@GeneratedValue(generator = "SnowflakeIdGenerator") @GeneratedValue(generator = "SnowflakeIdGenerator")
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator") @GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
@ApiModelProperty(value = "通知消息id") @ApiModelProperty(value = "通知消息id")
private String id; private Long id;
private String content; private String content;

View File

@ -1,14 +1,13 @@
package cc.iotkit.data.service; package cc.iotkit.data.service;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.data.dao.ChannelConfigRepository;
import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.manager.IChannelConfigData; import cc.iotkit.data.manager.IChannelConfigData;
import cc.iotkit.data.dao.ChannelConfigRepository;
import cc.iotkit.data.model.ChannelConfigMapper; import cc.iotkit.data.model.ChannelConfigMapper;
import cc.iotkit.data.model.TbChannelConfig; import cc.iotkit.data.model.TbChannelConfig;
import cc.iotkit.common.api.Paging;
import cc.iotkit.model.notify.ChannelConfig; import cc.iotkit.model.notify.ChannelConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -16,9 +15,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -28,7 +24,7 @@ import java.util.stream.Collectors;
**/ **/
@Primary @Primary
@Service @Service
public class ChannelConfigDataImpl implements IChannelConfigData, IJPACommData<ChannelConfig, String> { public class ChannelConfigDataImpl implements IChannelConfigData, IJPACommData<ChannelConfig, Long> {
@Resource @Resource
private ChannelConfigRepository channelConfigRepository; private ChannelConfigRepository channelConfigRepository;
@ -51,31 +47,6 @@ public class ChannelConfigDataImpl implements IChannelConfigData, IJPACommData<C
return ChannelConfig.class; return ChannelConfig.class;
} }
@Override
public ChannelConfig findById(String id) {
return channelConfigMapper.toDto(channelConfigRepository.findById(id).orElse(null));
}
@Override
public List<ChannelConfig> findByIds(Collection<String> id) {
return null;
}
@Override
public ChannelConfig save(ChannelConfig data) {
if (StringUtils.isBlank(data.getId())) {
data.setId(UUID.randomUUID().toString());
}
channelConfigRepository.save(channelConfigMapper.toVo(data));
return data;
}
@Override
public List<ChannelConfig> findAll() {
return channelConfigRepository.findAll().stream().map(channelConfigMapper::toDto)
.collect(Collectors.toList());
}
@Override @Override
public Paging<ChannelConfig> findAll(PageRequest<ChannelConfig> pageRequest) { public Paging<ChannelConfig> findAll(PageRequest<ChannelConfig> pageRequest) {
Page<TbChannelConfig> tbChannelConfigs = channelConfigRepository.findAll(Pageable.ofSize(pageRequest.getPageSize()).withPage(pageRequest.getPageNum() - 1)); Page<TbChannelConfig> tbChannelConfigs = channelConfigRepository.findAll(Pageable.ofSize(pageRequest.getPageSize()).withPage(pageRequest.getPageNum() - 1));

View File

@ -1,24 +1,15 @@
package cc.iotkit.data.service; package cc.iotkit.data.service;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.data.dao.ChannelRepository;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.manager.IChannelData; import cc.iotkit.data.manager.IChannelData;
import cc.iotkit.data.dao.ChannelRepository;
import cc.iotkit.data.model.TbChannel; import cc.iotkit.data.model.TbChannel;
import cc.iotkit.common.api.Paging;
import cc.iotkit.model.notify.Channel; import cc.iotkit.model.notify.Channel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
/** /**
* author: * author:
@ -27,7 +18,7 @@ import java.util.UUID;
**/ **/
@Primary @Primary
@Service @Service
public class ChannelDataImpl implements IChannelData, IJPACommData<Channel, String> { public class ChannelDataImpl implements IChannelData, IJPACommData<Channel, Long> {
@Resource @Resource
private ChannelRepository channelRepository; private ChannelRepository channelRepository;
@ -47,29 +38,6 @@ public class ChannelDataImpl implements IChannelData, IJPACommData<Channel, Stri
return Channel.class; return Channel.class;
} }
@Override
public Channel findById(String id) {
return MapstructUtils.convert(channelRepository.findById(id).orElse(null), Channel.class);
}
@Override
public Channel save(Channel data) {
if (StringUtils.isBlank(data.getId())) {
data.setId(UUID.randomUUID().toString());
}
channelRepository.save(
MapstructUtils.convert(data, TbChannel.class)
);
return data;
}
@Override
public List<Channel> findAll() {
return MapstructUtils.convert(channelRepository.findAll(), Channel.class);
}
} }

View File

@ -1,24 +1,17 @@
package cc.iotkit.data.service; package cc.iotkit.data.service;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.ChannelTemplateRepository;
import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.manager.IChannelTemplateData; import cc.iotkit.data.manager.IChannelTemplateData;
import cc.iotkit.data.dao.ChannelTemplateRepository;
import cc.iotkit.data.model.TbChannelTemplate; import cc.iotkit.data.model.TbChannelTemplate;
import cc.iotkit.common.api.Paging;
import cc.iotkit.model.notify.ChannelTemplate; import cc.iotkit.model.notify.ChannelTemplate;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -28,7 +21,7 @@ import java.util.stream.Collectors;
**/ **/
@Primary @Primary
@Service @Service
public class ChannelTemplateDataImpl implements IChannelTemplateData, IJPACommData<ChannelTemplate, String> { public class ChannelTemplateDataImpl implements IChannelTemplateData, IJPACommData<ChannelTemplate, Long> {
@Resource @Resource
private ChannelTemplateRepository channelTemplateRepository; private ChannelTemplateRepository channelTemplateRepository;
@ -48,43 +41,12 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData, IJPACommDa
return ChannelTemplate.class; return ChannelTemplate.class;
} }
@Override
public ChannelTemplate findById(String id) {
return MapstructUtils.convert(channelTemplateRepository.findById(id).orElse(null), ChannelTemplate.class);
}
@Override
public List<ChannelTemplate> findByIds(Collection<String> id) {
return null;
}
@Override
public ChannelTemplate save(ChannelTemplate data) {
if (StringUtils.isBlank(data.getId())) {
data.setId(UUID.randomUUID().toString());
}
channelTemplateRepository.save(MapstructUtils.convert(data, TbChannelTemplate.class));
return data;
}
@Override @Override
public void batchSave(List<ChannelTemplate> data) { public void batchSave(List<ChannelTemplate> data) {
} }
@Override
public void deleteById(String id) {
channelTemplateRepository.deleteById(id);
}
@Override
public void deleteByIds(Collection<String> strings) {
}
@Override @Override
public long count() { public long count() {
return channelTemplateRepository.count(); return channelTemplateRepository.count();
@ -97,11 +59,6 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData, IJPACommDa
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public Paging<ChannelTemplate> findAll(PageRequest<ChannelTemplate> pageRequest) {
return null;
}
@Override @Override
public List<ChannelTemplate> findAllByCondition(ChannelTemplate data) { public List<ChannelTemplate> findAllByCondition(ChannelTemplate data) {
return null; return null;

View File

@ -1,25 +1,15 @@
package cc.iotkit.data.service; package cc.iotkit.data.service;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.NotifyMessageRepository; import cc.iotkit.data.dao.NotifyMessageRepository;
import cc.iotkit.data.manager.INotifyMessageData; import cc.iotkit.data.manager.INotifyMessageData;
import cc.iotkit.data.model.TbNotifyMessage; import cc.iotkit.data.model.TbNotifyMessage;
import cc.iotkit.data.model.TbOtaPackage;
import cc.iotkit.model.notify.Channel;
import cc.iotkit.model.notify.NotifyMessage; import cc.iotkit.model.notify.NotifyMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/** /**
* @Author: * @Author:
@ -28,7 +18,7 @@ import java.util.stream.Collectors;
*/ */
@Primary @Primary
@Service @Service
public class NotifyMessageDataImpl implements INotifyMessageData, IJPACommData<NotifyMessage, String> { public class NotifyMessageDataImpl implements INotifyMessageData, IJPACommData<NotifyMessage, Long> {
@Resource @Resource
private NotifyMessageRepository notifyMessageRepository; private NotifyMessageRepository notifyMessageRepository;

View File

@ -3,8 +3,12 @@ package cc.iotkit.manager.controller;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request; import cc.iotkit.common.api.Request;
import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.common.validate.QueryGroup;
import cc.iotkit.manager.dto.bo.channel.ChannelConfigBo; import cc.iotkit.manager.dto.bo.channel.ChannelConfigBo;
import cc.iotkit.manager.dto.bo.channel.ChannelTemplateBo;
import cc.iotkit.manager.dto.vo.channel.ChannelConfigVo; import cc.iotkit.manager.dto.vo.channel.ChannelConfigVo;
import cc.iotkit.manager.dto.vo.channel.ChannelTemplateVo;
import cc.iotkit.manager.service.NotifyService; import cc.iotkit.manager.service.NotifyService;
import cc.iotkit.model.notify.Channel; import cc.iotkit.model.notify.Channel;
import cc.iotkit.model.notify.ChannelConfig; import cc.iotkit.model.notify.ChannelConfig;
@ -41,21 +45,27 @@ public class NotifyController {
return notifyService.getChannelList(); return notifyService.getChannelList();
} }
@ApiOperation("获取通道配置列表") @ApiOperation("获取通道配置分页列表")
@PostMapping("/channel/config/getList") @PostMapping("/channel/config/getList")
public Paging<ChannelConfigVo> getChannelConfigList(PageRequest<ChannelConfigBo> request) { public Paging<ChannelConfigVo> getChannelConfigList(@RequestBody @Validated(QueryGroup.class) PageRequest<ChannelConfigBo> request) {
return notifyService.getChannelConfigList(request); return notifyService.getChannelConfigList(request);
} }
@ApiOperation("获取通道配置列表")
@PostMapping("/channel/config/getAll")
public List<ChannelConfigVo> getChannelConfigAll() {
return notifyService.getChannelConfigAll();
}
@ApiOperation("新增通道配置") @ApiOperation("新增通道配置")
@PostMapping("/channel/config/add") @PostMapping("/channel/config/add")
public ChannelConfig addChannelConfig(@RequestBody @Validated Request<ChannelConfig> request) { public ChannelConfig addChannelConfig(@RequestBody @Validated(EditGroup.class) Request<ChannelConfig> request) {
return notifyService.addChannelConfig(request.getData()); return notifyService.addChannelConfig(request.getData());
} }
@ApiOperation("根据ID获取通道配置") @ApiOperation("根据ID获取通道配置")
@PostMapping("/channel/config/getById") @PostMapping("/channel/config/getById")
public ChannelConfig getChannelConfigById(@RequestBody @Validated Request<String> request) { public ChannelConfig getChannelConfigById(@RequestBody @Validated(QueryGroup.class) Request<Long> request) {
return notifyService.getChannelConfigById(request.getData()); return notifyService.getChannelConfigById(request.getData());
} }
@ -67,25 +77,25 @@ public class NotifyController {
@ApiOperation("删除通道配置") @ApiOperation("删除通道配置")
@PostMapping("/channel/config/delById") @PostMapping("/channel/config/delById")
public Boolean delChannelConfigById(@RequestBody @Validated Request<String> request) { public Boolean delChannelConfigById(@RequestBody @Validated Request<Long> request) {
return notifyService.delChannelConfigById(request.getData()); return notifyService.delChannelConfigById(request.getData());
} }
@ApiOperation("获取通道模板列表") @ApiOperation("获取通道模板列表")
@PostMapping("/channel/template/getList") @PostMapping("/channel/template/getList")
public List<ChannelTemplate> getChannelTemplateList() { public Paging<ChannelTemplateVo> getChannelTemplateList(@RequestBody @Validated(QueryGroup.class) PageRequest<ChannelTemplateBo> request) {
return notifyService.getChannelTemplateList(); return notifyService.getChannelTemplateList(request);
} }
@ApiOperation("新增通道模板") @ApiOperation("新增通道模板")
@PostMapping("/channel/template/add") @PostMapping("/channel/template/add")
public ChannelTemplate addChannelTemplate(@RequestBody @Validated Request<ChannelTemplate> request) { public ChannelTemplate addChannelTemplate(@RequestBody @Validated(EditGroup.class) Request<ChannelTemplateBo> request) {
return notifyService.addChannelTemplate(request.getData()); return notifyService.addChannelTemplate(request.getData());
} }
@ApiOperation("根据ID获取通道模板") @ApiOperation("根据ID获取通道模板")
@PostMapping("/channel/template/getById") @PostMapping("/channel/template/getById")
public ChannelTemplate getChannelTemplateById(@RequestBody @Validated Request<String> request) { public ChannelTemplate getChannelTemplateById(@RequestBody @Validated Request<Long> request) {
return notifyService.getChannelTemplateById(request.getData()); return notifyService.getChannelTemplateById(request.getData());
} }
@ -97,7 +107,7 @@ public class NotifyController {
@ApiOperation("删除通道模板") @ApiOperation("删除通道模板")
@PostMapping("/channel/template/delById") @PostMapping("/channel/template/delById")
public Boolean delChannelTemplateById(@RequestBody @Validated Request<String> request) { public Boolean delChannelTemplateById(@RequestBody @Validated(EditGroup.class) Request<Long> request) {
return notifyService.delChannelTemplateById(request.getData()); return notifyService.delChannelTemplateById(request.getData());
} }

View File

@ -22,7 +22,7 @@ public class ChannelConfigBo extends BaseDto {
private String id; private String id;
@ApiModelProperty(value="通道id") @ApiModelProperty(value="通道id")
private String channelId; private Long channelId;
@ApiModelProperty(value="通道配置名称") @ApiModelProperty(value="通道配置名称")
private String title; private String title;

View File

@ -0,0 +1,39 @@
package cc.iotkit.manager.dto.bo.channel;
import cc.iotkit.common.api.BaseDto;
import cc.iotkit.model.notify.ChannelTemplate;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel(value = "ChannelTemplateVo")
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = ChannelTemplate.class, reverseConvertGenerate = false)
public class ChannelTemplateBo extends BaseDto {
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="通道模板id")
@ExcelProperty(value = "通道模板id")
private Long id;
@ApiModelProperty(value="通道配置id")
@ExcelProperty(value = "通道配置id")
private Long channelConfigId;
@ApiModelProperty(value="通道模板名称")
@ExcelProperty(value = "通道模板名称")
private String title;
@ApiModelProperty(value="通道模板内容")
@ExcelProperty(value = "通道模板内容")
private String content;
@ApiModelProperty(value="创建时间")
@ExcelProperty(value = "创建时间")
private Long createAt;
}

View File

@ -0,0 +1,40 @@
package cc.iotkit.manager.dto.vo.channel;
import cc.iotkit.model.notify.ChannelTemplate;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel(value = "ChannelTemplateVo")
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = ChannelTemplate.class)
public class ChannelTemplateVo implements Serializable {
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="通道模板id")
@ExcelProperty(value = "通道模板id")
private Long id;
@ApiModelProperty(value="通道配置id")
@ExcelProperty(value = "通道配置id")
private Long channelConfigId;
@ApiModelProperty(value="通道模板名称")
@ExcelProperty(value = "通道模板名称")
private String title;
@ApiModelProperty(value="通道模板内容")
@ExcelProperty(value = "通道模板内容")
private String content;
@ApiModelProperty(value="创建时间")
@ExcelProperty(value = "创建时间")
private Long createAt;
}

View File

@ -2,11 +2,14 @@ package cc.iotkit.manager.service;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.manager.IChannelConfigData; import cc.iotkit.data.manager.IChannelConfigData;
import cc.iotkit.data.manager.IChannelData; import cc.iotkit.data.manager.IChannelData;
import cc.iotkit.data.manager.IChannelTemplateData; import cc.iotkit.data.manager.IChannelTemplateData;
import cc.iotkit.manager.dto.bo.channel.ChannelConfigBo; import cc.iotkit.manager.dto.bo.channel.ChannelConfigBo;
import cc.iotkit.manager.dto.bo.channel.ChannelTemplateBo;
import cc.iotkit.manager.dto.vo.channel.ChannelConfigVo; import cc.iotkit.manager.dto.vo.channel.ChannelConfigVo;
import cc.iotkit.manager.dto.vo.channel.ChannelTemplateVo;
import cc.iotkit.model.notify.Channel; import cc.iotkit.model.notify.Channel;
import cc.iotkit.model.notify.ChannelConfig; import cc.iotkit.model.notify.ChannelConfig;
import cc.iotkit.model.notify.ChannelTemplate; import cc.iotkit.model.notify.ChannelTemplate;
@ -42,11 +45,15 @@ public class NotifyService {
return iChannelConfigData.findAll(request.to(ChannelConfig.class)).to(ChannelConfigVo.class); return iChannelConfigData.findAll(request.to(ChannelConfig.class)).to(ChannelConfigVo.class);
} }
public List<ChannelConfigVo> getChannelConfigAll() {
return MapstructUtils.convert(iChannelConfigData.findAll(),ChannelConfigVo.class);
}
public ChannelConfig addChannelConfig(ChannelConfig channelConfig) { public ChannelConfig addChannelConfig(ChannelConfig channelConfig) {
return iChannelConfigData.save(channelConfig); return iChannelConfigData.save(channelConfig);
} }
public ChannelConfig getChannelConfigById(String id) { public ChannelConfig getChannelConfigById(Long id) {
return iChannelConfigData.findById(id); return iChannelConfigData.findById(id);
} }
@ -54,21 +61,20 @@ public class NotifyService {
return iChannelConfigData.save(channelConfig); return iChannelConfigData.save(channelConfig);
} }
public Boolean delChannelConfigById(String id) { public Boolean delChannelConfigById(Long id) {
iChannelConfigData.deleteById(id); iChannelConfigData.deleteById(id);
return Boolean.TRUE; return Boolean.TRUE;
} }
public List<ChannelTemplate> getChannelTemplateList() { public Paging<ChannelTemplateVo> getChannelTemplateList(PageRequest<ChannelTemplateBo> request) {
List<ChannelTemplate> channelTemplateList = iChannelTemplateData.findAll(); return iChannelTemplateData.findAll(request.to(ChannelTemplate.class)).to(ChannelTemplateVo.class);
return channelTemplateList;
} }
public ChannelTemplate addChannelTemplate(ChannelTemplate channelTemplate) { public ChannelTemplate addChannelTemplate(ChannelTemplateBo channelTemplate) {
return iChannelTemplateData.save(channelTemplate); return iChannelTemplateData.save(channelTemplate.to(ChannelTemplate.class));
} }
public ChannelTemplate getChannelTemplateById(String id) { public ChannelTemplate getChannelTemplateById(Long id) {
return iChannelTemplateData.findById(id); return iChannelTemplateData.findById(id);
} }
@ -76,7 +82,7 @@ public class NotifyService {
return iChannelTemplateData.save(channelTemplate); return iChannelTemplateData.save(channelTemplate);
} }
public Boolean delChannelTemplateById(String id) { public Boolean delChannelTemplateById(Long id) {
iChannelTemplateData.deleteById(id); iChannelTemplateData.deleteById(id);
return Boolean.TRUE; return Boolean.TRUE;
} }