扫码登陆
This commit is contained in:
parent
195c1d6d72
commit
2d5dcdcf83
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using YD_WeChatApplet.Api.Services.Interface;
|
using YD_WeChatApplet.Api.Services.Interface;
|
||||||
using YD_WeChatApplet.Commons.Dto.HomeWork;
|
using YD_WeChatApplet.Commons.Dto.HomeWork;
|
||||||
|
using YD_WeChatApplet.Commons.Dto.JingShiTiJiao;
|
||||||
using YD_WeChatApplet.Commons.Dto.Patriarch;
|
using YD_WeChatApplet.Commons.Dto.Patriarch;
|
||||||
using YD_WeChatApplet.Services;
|
using YD_WeChatApplet.Services;
|
||||||
|
|
||||||
@ -25,14 +26,29 @@ namespace YD_WeChatApplet.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ai一体机扫描登录
|
/// Ai一体机扫描登录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="schoolCode"></param>
|
|
||||||
/// <param name="teacherNo"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("ScanCodeLogin")]
|
[HttpPost("ScanCodeLogin")]
|
||||||
public async Task<bool> ScanCodeLogin(string code, string? schoolCode = null, string? teacherNo = null)
|
public async Task<bool> ScanCodeLogin(ScanCodeLoginRequest request)
|
||||||
{
|
{
|
||||||
return await _frameworkService.ScanCodeLogin(code, schoolCode, teacherNo);
|
if (request==null)
|
||||||
|
{
|
||||||
|
throw new Exception("参数为空!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(request.Code))
|
||||||
|
{
|
||||||
|
throw new Exception("设备编号为空!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(request.SchoolCode))
|
||||||
|
{
|
||||||
|
throw new Exception("学校编号为空!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(request.TeacherNo))
|
||||||
|
{
|
||||||
|
throw new Exception("老师编号为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _frameworkService.ScanCodeLogin(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using YD_WeChatApplet.Api.Services.Interface;
|
using YD_WeChatApplet.Api.Services.Interface;
|
||||||
using YD_WeChatApplet.Api.SmartSportsEntitys;
|
using YD_WeChatApplet.Api.SmartSportsEntitys;
|
||||||
using YD_WeChatApplet.Api.Utilities;
|
using YD_WeChatApplet.Api.Utilities;
|
||||||
|
using YD_WeChatApplet.Commons.Dto.JingShiTiJiao;
|
||||||
using YD_WeChatApplet.Context;
|
using YD_WeChatApplet.Context;
|
||||||
|
|
||||||
namespace YD_WeChatApplet.Api.Services.Impl
|
namespace YD_WeChatApplet.Api.Services.Impl
|
||||||
@ -21,27 +22,13 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ai一体机扫描登录
|
/// Ai一体机扫描登录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="schoolCode"></param>
|
|
||||||
/// <param name="teacherNo"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> ScanCodeLogin(string code, string? schoolCode = null, string? teacherNo = null)
|
public async Task<bool> ScanCodeLogin(ScanCodeLoginRequest request)
|
||||||
{
|
{
|
||||||
// 如果 schoolCode 为空,则取当前登录用户的 SchoolCode
|
|
||||||
if (string.IsNullOrWhiteSpace(schoolCode))
|
|
||||||
{
|
|
||||||
schoolCode = UserLoginContext.Current.SchoolCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果 teacherNo 为空,则取当前登录用户的 UserNo
|
|
||||||
if (string.IsNullOrWhiteSpace(teacherNo))
|
|
||||||
{
|
|
||||||
teacherNo = UserLoginContext.Current.UserNo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 先检查是否已存在相同的记录
|
// 先检查是否已存在相同的记录
|
||||||
var exist = await _sportsContext.Ai_ScanCodeLogin
|
var exist = await _sportsContext.Ai_ScanCodeLogin
|
||||||
.AnyAsync(x => x.Code == code && x.SchoolCode == schoolCode);
|
.AnyAsync(x => x.Code == request.Code && x.SchoolCode == request.SchoolCode);
|
||||||
|
|
||||||
if (exist)
|
if (exist)
|
||||||
return true; // 已存在,认为成功
|
return true; // 已存在,认为成功
|
||||||
@ -49,10 +36,10 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
|||||||
// 不存在则添加
|
// 不存在则添加
|
||||||
var entity = new Ai_ScanCodeLogin
|
var entity = new Ai_ScanCodeLogin
|
||||||
{
|
{
|
||||||
Code = code,
|
Code = request.Code,
|
||||||
SchoolCode = schoolCode,
|
SchoolCode = request.SchoolCode,
|
||||||
TeacherId = 0,
|
TeacherId = 0,
|
||||||
TeacherPhoneNo = teacherNo,
|
TeacherPhoneNo = request.TeacherNo,
|
||||||
CreateDate = DateTime.Now
|
CreateDate = DateTime.Now
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace YD_WeChatApplet.Api.Services.Interface
|
using YD_WeChatApplet.Commons.Dto.JingShiTiJiao;
|
||||||
|
|
||||||
|
namespace YD_WeChatApplet.Api.Services.Interface
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 公共接口
|
/// 公共接口
|
||||||
@ -8,10 +10,8 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ai一体机扫描登录
|
/// Ai一体机扫描登录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="schoolCode"></param>
|
|
||||||
/// <param name="teacherNo"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> ScanCodeLogin(string code, string? schoolCode = null, string? teacherNo = null);
|
Task<bool> ScanCodeLogin(ScanCodeLoginRequest request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YD_WeChatApplet.Commons.Dto.JingShiTiJiao
|
||||||
|
{
|
||||||
|
public class ScanCodeLoginRequest
|
||||||
|
{
|
||||||
|
public string Code { get; set; } = null!;
|
||||||
|
public string SchoolCode { get; set; } = null!;
|
||||||
|
public string TeacherNo { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user