This commit is contained in:
tanglong 2025-07-01 13:35:38 +08:00
parent 317cf4e81e
commit ca4f50d69b

View File

@ -143,6 +143,11 @@ namespace YD_AllHeartRates.Api.Services.Impl
/// <returns></returns>
public async Task<bool> 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 ? "心率" : "跳绳";