试试
This commit is contained in:
parent
4777604596
commit
4179f88893
@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using YD_WeChatApplet.Api.Services.Interface;
|
||||
using YD_WeChatApplet.Api.SmartSportsEntitys;
|
||||
using YD_WeChatApplet.Api.Utilities;
|
||||
@ -25,11 +26,22 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ScanCodeLogin(string code)
|
||||
{
|
||||
var entity = new Ai_ScanCodeLogin()
|
||||
var schoolCode = UserLoginContext.Current.SchoolCode;
|
||||
var teacherId = UserLoginContext.Current.UserId;
|
||||
|
||||
// 先检查是否已存在相同的记录
|
||||
var exist = await _sportsContext.Ai_ScanCodeLogin
|
||||
.AnyAsync(x => x.Code == code && x.SchoolCode == schoolCode && x.TeacherId == teacherId);
|
||||
|
||||
if (exist)
|
||||
return true; // 已存在,认为成功
|
||||
|
||||
// 不存在则添加
|
||||
var entity = new Ai_ScanCodeLogin
|
||||
{
|
||||
Code = code,
|
||||
SchoolCode = UserLoginContext.Current.SchoolCode,
|
||||
TeacherId = UserLoginContext.Current.UserId,
|
||||
SchoolCode = schoolCode,
|
||||
TeacherId = teacherId,
|
||||
TeacherPhoneNo = UserLoginContext.Current.PhoneNo,
|
||||
CreateDate = DateTime.Now
|
||||
};
|
||||
@ -37,5 +49,6 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
||||
await _sportsContext.AddAsync(entity);
|
||||
return await _sportsContext.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user