diff --git a/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs b/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs
index d1c393a..cdb385d 100644
--- a/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs
+++ b/YD_AllHeartRates.Api/Services/Impl/DeviceService.cs
@@ -143,6 +143,11 @@ namespace YD_AllHeartRates.Api.Services.Impl
///
public async Task AddDevice([FromBody] AddDeviceDto dto)
{
+ var student = await _sportsContext.Student.Where(x => x.StudentNo == dto.StudentNo).FirstOrDefaultAsync();
+
+ if (student == null)
+ throw new Exception($"学号:{dto.StudentNo}的学生不存在!");
+
var entity = new S_Device()
{
Code = dto.Code,
@@ -169,6 +174,11 @@ namespace YD_AllHeartRates.Api.Services.Impl
if (device == null)
throw new Exception("更新的设备不存在");
+ var student = await _sportsContext.Student.Where(x => x.StudentNo == dto.StudentNo).FirstOrDefaultAsync();
+
+ if (student == null)
+ throw new Exception($"学号:{dto.StudentNo}的学生不存在!");
+
device.StudentNo = dto.StudentNo;
device.DeviceType = dto.DeviceType;
device.Name = dto.DeviceType == 1 ? "心率" : "跳绳";