feat:添加渠道
parent
16ead18c65
commit
bb94a47c7e
|
@ -1,14 +1,21 @@
|
|||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.api.Request;
|
||||
import cc.iotkit.manager.service.NotifyService;
|
||||
import cc.iotkit.model.notify.Channel;
|
||||
import cc.iotkit.model.notify.ChannelConfig;
|
||||
import cc.iotkit.model.notify.ChannelTemplate;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* author: 石恒
|
||||
|
@ -26,57 +33,68 @@ public class NotifyController {
|
|||
|
||||
@ApiOperation("获取通道类型列表")
|
||||
@PostMapping("/channel/getList")
|
||||
public void getChannelList() {
|
||||
public List<Channel> getChannelList() {
|
||||
return notifyService.getChannelList();
|
||||
}
|
||||
|
||||
@ApiOperation("获取通道配置列表")
|
||||
@PostMapping("/channel/config/getList")
|
||||
public void getChannelConfigList() {
|
||||
public List<ChannelConfig> getChannelConfigList() {
|
||||
return notifyService.getChannelConfigList();
|
||||
}
|
||||
|
||||
@ApiOperation("新增通道配置")
|
||||
@PostMapping("/channel/config/add")
|
||||
public void addChannelConfig() {
|
||||
public ChannelConfig addChannelConfig(@RequestBody @Valid Request<ChannelConfig> request) {
|
||||
return notifyService.addChannelConfig(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("根据ID获取通道配置")
|
||||
@PostMapping("/channel/config/getById")
|
||||
public void getChannelConfigById() {
|
||||
public ChannelConfig getChannelConfigById(@RequestBody @Valid Request<String> request) {
|
||||
return notifyService.getChannelConfigById(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("修改通道配置")
|
||||
@PostMapping("/channel/config/updateById")
|
||||
public void updateChannelConfigById() {
|
||||
public ChannelConfig updateChannelConfigById(@RequestBody @Valid Request<ChannelConfig> request) {
|
||||
return notifyService.updateChannelConfigById(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("删除通道配置")
|
||||
@PostMapping("/channel/config/delById")
|
||||
public void delChannelConfigById() {
|
||||
public Boolean delChannelConfigById(@RequestBody @Valid Request<String> request) {
|
||||
return notifyService.delChannelConfigById(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("获取通道模板列表")
|
||||
@PostMapping("/channel/template/getList")
|
||||
public void getChannelTemplateList() {
|
||||
public List<ChannelTemplate> getChannelTemplateList() {
|
||||
return notifyService.getChannelTemplateList();
|
||||
}
|
||||
|
||||
@ApiOperation("新增通道模板")
|
||||
@PostMapping("/channel/template/add")
|
||||
public void addChannelTemplate() {
|
||||
public ChannelTemplate addChannelTemplate(@RequestBody @Valid Request<ChannelTemplate> request) {
|
||||
return notifyService.addChannelTemplate(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("根据ID获取通道模板")
|
||||
@PostMapping("/channel/template/getById")
|
||||
public void getChannelTemplateById() {
|
||||
public ChannelTemplate getChannelTemplateById(@RequestBody @Valid Request<String> request) {
|
||||
return notifyService.getChannelTemplateById(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("修改通道模板")
|
||||
@PostMapping("/channel/template/updateById")
|
||||
public void updateChannelTemplateById() {
|
||||
public ChannelTemplate updateChannelTemplateById(@RequestBody @Valid Request<ChannelTemplate> request) {
|
||||
return notifyService.updateChannelTemplateById(request.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("删除通道模板")
|
||||
@PostMapping("/channel/template/delById")
|
||||
public void delChannelTemplateById() {
|
||||
public Boolean delChannelTemplateById(@RequestBody @Valid Request<String> request) {
|
||||
return notifyService.delChannelTemplateById(request.getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import cc.iotkit.model.UserInfo;
|
|||
import cc.iotkit.model.device.DeviceGroup;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.device.VirtualDevice;
|
||||
import cc.iotkit.model.notify.Channel;
|
||||
import cc.iotkit.model.product.Category;
|
||||
import cc.iotkit.model.product.Product;
|
||||
import cc.iotkit.model.product.ProductModel;
|
||||
|
@ -83,6 +84,8 @@ public class ExampleDataInit implements SmartInitializingSingleton {
|
|||
private IVirtualDeviceData virtualDeviceData;
|
||||
@Autowired
|
||||
private IDbStructureData dbStructureData;
|
||||
@Autowired
|
||||
private IChannelData iChannelData;
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
|
@ -134,6 +137,8 @@ public class ExampleDataInit implements SmartInitializingSingleton {
|
|||
});
|
||||
initData("virtualDevice", virtualDeviceData, new TypeReference<List<VirtualDevice>>() {
|
||||
});
|
||||
initData("channel", iChannelData, new TypeReference<List<Channel>>() {
|
||||
});
|
||||
|
||||
log.info("init data finished.");
|
||||
|
||||
|
|
|
@ -38,10 +38,8 @@ public class NotifyService {
|
|||
return iChannelConfigData.findAll();
|
||||
}
|
||||
|
||||
public void addChannelConfig() {
|
||||
ChannelConfig channelConfig = ChannelConfig.builder()
|
||||
.build();
|
||||
iChannelConfigData.add(channelConfig);
|
||||
public ChannelConfig addChannelConfig(ChannelConfig channelConfig) {
|
||||
return iChannelConfigData.add(channelConfig);
|
||||
}
|
||||
|
||||
public ChannelConfig getChannelConfigById(String id) {
|
||||
|
@ -52,27 +50,30 @@ public class NotifyService {
|
|||
return iChannelConfigData.save(channelConfig);
|
||||
}
|
||||
|
||||
public void delChannelConfigById(String id) {
|
||||
public Boolean delChannelConfigById(String id) {
|
||||
iChannelConfigData.deleteById(id);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public void getChannelTemplateList() {
|
||||
|
||||
public List<ChannelTemplate> getChannelTemplateList() {
|
||||
List<ChannelTemplate> channelTemplateList = iChannelTemplateData.findAll();
|
||||
return channelTemplateList;
|
||||
}
|
||||
|
||||
public void addChannelTemplate() {
|
||||
|
||||
public ChannelTemplate addChannelTemplate(ChannelTemplate channelTemplate) {
|
||||
return iChannelTemplateData.add(channelTemplate);
|
||||
}
|
||||
|
||||
public ChannelTemplate getChannelTemplateById(String id) {
|
||||
return iChannelTemplateData.findById(id);
|
||||
}
|
||||
|
||||
public void updateChannelTemplateById(ChannelTemplate channelTemplate) {
|
||||
iChannelTemplateData.save(channelTemplate);
|
||||
public ChannelTemplate updateChannelTemplateById(ChannelTemplate channelTemplate) {
|
||||
return iChannelTemplateData.save(channelTemplate);
|
||||
}
|
||||
|
||||
public void delChannelTemplateById(String id) {
|
||||
public Boolean delChannelTemplateById(String id) {
|
||||
iChannelTemplateData.deleteById(id);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue