diff --git a/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs b/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs index 220ef81..93b2c3a 100644 --- a/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs +++ b/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs @@ -174,7 +174,8 @@ namespace YD_AllHeartRates.Api.Services.Impl await _sportsContext.AddAsync(entity); var res = await _sportsContext.SaveChangesAsync() > 0; - _caching.Remove(AppSettings.DeviceListCacheKey); + _caching.Remove($"{AppSettings.StudentListCacheKey}_{schoolCode}"); + _caching.Remove($"{AppSettings.DeviceListCacheKey}_{schoolCode}"); return res; } @@ -206,7 +207,8 @@ namespace YD_AllHeartRates.Api.Services.Impl _sportsContext.Update(device); var res = await _sportsContext.SaveChangesAsync() > 0; - _caching.Remove(AppSettings.DeviceListCacheKey); + _caching.Remove($"{AppSettings.StudentListCacheKey}_{schoolCode}"); + _caching.Remove($"{AppSettings.DeviceListCacheKey}_{schoolCode}"); return res; } @@ -225,7 +227,8 @@ namespace YD_AllHeartRates.Api.Services.Impl _sportsContext.Device.Remove(device); var res = await _sportsContext.SaveChangesAsync() > 0; - _caching.Remove(AppSettings.DeviceListCacheKey); + _caching.Remove($"{AppSettings.StudentListCacheKey}_{schoolCode}"); + _caching.Remove($"{AppSettings.DeviceListCacheKey}_{schoolCode}"); return res; } @@ -278,8 +281,13 @@ namespace YD_AllHeartRates.Api.Services.Impl Name = data.DeviceType == 1 ? "心率设备" : "跳绳设备" }); } + await _sportsContext.AddRangeAsync(deviceList); - return await _sportsContext.SaveChangesAsync() > 0; + var res = await _sportsContext.SaveChangesAsync() > 0; + + _caching.Remove($"{AppSettings.StudentListCacheKey}_{schoolCode}"); + _caching.Remove($"{AppSettings.DeviceListCacheKey}_{schoolCode}"); + return res; } } }