|
@@ -2,6 +2,8 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using IMCS.CCS.Entitys;
|
|
using IMCS.CCS.Entitys;
|
|
|
|
+using IMCS.CCS.Common.Redis;
|
|
|
|
+using Newtonsoft.Json;
|
|
|
|
|
|
namespace IMCS.CCS.Services
|
|
namespace IMCS.CCS.Services
|
|
{
|
|
{
|
|
@@ -9,8 +11,11 @@ namespace IMCS.CCS.Services
|
|
{
|
|
{
|
|
private IDeviceRepository _repository;
|
|
private IDeviceRepository _repository;
|
|
|
|
|
|
- public DeviceService(IDeviceRepository repository) {
|
|
|
|
|
|
+ private IRedisService _redisService;
|
|
|
|
+
|
|
|
|
+ public DeviceService(IDeviceRepository repository, IRedisService redisService) {
|
|
_repository = repository;
|
|
_repository = repository;
|
|
|
|
+ _redisService = redisService;
|
|
}
|
|
}
|
|
public List<Device> GetDeviceList()
|
|
public List<Device> GetDeviceList()
|
|
{
|
|
{
|
|
@@ -21,7 +26,10 @@ namespace IMCS.CCS.Services
|
|
{
|
|
{
|
|
return _repository.GetDeviceAllList();
|
|
return _repository.GetDeviceAllList();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ public List<Device> GetDevices()
|
|
|
|
+ {
|
|
|
|
+ return _repository.GetDevices();
|
|
|
|
+ }
|
|
|
|
|
|
//查询设备详情
|
|
//查询设备详情
|
|
public async Task<Device> GetDeviceById(int id)
|
|
public async Task<Device> GetDeviceById(int id)
|
|
@@ -40,6 +48,16 @@ namespace IMCS.CCS.Services
|
|
{
|
|
{
|
|
return await _repository.UpdateDevice(device);
|
|
return await _repository.UpdateDevice(device);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ //添加或修改,放入缓存
|
|
|
|
+ public async Task<bool> UpdateAndCache(Device vo)
|
|
|
|
+ {
|
|
|
|
+ await _repository.UpdateDevice(vo);
|
|
|
|
+
|
|
|
|
+ string callback_redis_key = "IMCS_CCS:DeviceList";
|
|
|
|
+ List<Device> devices = _repository.GetDeviceAllList();
|
|
|
|
+ await _redisService.Database.StringSetAsync(callback_redis_key, JsonConvert.SerializeObject(devices));
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|