tijiao
This commit is contained in:
parent
2d1c2d0953
commit
b1d6610be4
@ -14,7 +14,7 @@ namespace YD_YiLu.Commons.Dto.DeviceSync
|
|||||||
public string VideoSerial { get; set; }
|
public string VideoSerial { get; set; }
|
||||||
public int TrainExam { get; set; }
|
public int TrainExam { get; set; }
|
||||||
public int? QuizId { get; set; }
|
public int? QuizId { get; set; }
|
||||||
public int StandardCounts { get; set; }
|
public double StandardCounts { get; set; }
|
||||||
public int UnStandardCounts { get; set; }
|
public int UnStandardCounts { get; set; }
|
||||||
public double? TimeKeeping { get; set; }
|
public double? TimeKeeping { get; set; }
|
||||||
public int Duration { get; set; }
|
public int Duration { get; set; }
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using YD_YiLu.Api.Services.Interface;
|
using YD_YiLu.Api.Services.Interface;
|
||||||
using YD_YiLu.Commons.Dto.DeviceSync;
|
using YD_YiLu.Commons.Dto.DeviceSync;
|
||||||
|
|
||||||
@ -12,10 +13,12 @@ namespace YD_YiLu.Api.Controllers
|
|||||||
public class DeviceSyncController : ControllerBase
|
public class DeviceSyncController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IDeviceSyncService _deviceSyncService;
|
private readonly IDeviceSyncService _deviceSyncService;
|
||||||
|
private readonly ILogger<DeviceSyncController> _logger;
|
||||||
|
|
||||||
public DeviceSyncController(IDeviceSyncService deviceSyncService)
|
public DeviceSyncController(IDeviceSyncService deviceSyncService, ILogger<DeviceSyncController> logger)
|
||||||
{
|
{
|
||||||
_deviceSyncService = deviceSyncService;
|
_deviceSyncService = deviceSyncService;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -91,6 +94,13 @@ namespace YD_YiLu.Api.Controllers
|
|||||||
[Route("/device/sync/train_push")]
|
[Route("/device/sync/train_push")]
|
||||||
public async Task<object> TrainPush([FromBody] List<DeviceSyncTrainPushRequestDto> list)
|
public async Task<object> TrainPush([FromBody] List<DeviceSyncTrainPushRequestDto> list)
|
||||||
{
|
{
|
||||||
|
var rawBody = HttpContext.Items["TrainPushRawBody"] as string;
|
||||||
|
_logger.LogInformation(
|
||||||
|
"TrainPush model binding result. RawBodyLength: {RawBodyLength}, MappedCount: {MappedCount}, Body: {RawBody}",
|
||||||
|
rawBody?.Length ?? 0,
|
||||||
|
list?.Count ?? 0,
|
||||||
|
rawBody);
|
||||||
|
|
||||||
var res = await _deviceSyncService.TrainPushAsync(list);
|
var res = await _deviceSyncService.TrainPushAsync(list);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ namespace YD_YiLu.Api.Services.Impl
|
|||||||
Username = s.StudentNo,
|
Username = s.StudentNo,
|
||||||
Nickname = s.StudentName,
|
Nickname = s.StudentName,
|
||||||
GradeName = "",
|
GradeName = "",
|
||||||
OrganizationId = s.Id,
|
OrganizationId = (int)orgId,
|
||||||
OrganizationName = s.ClassName ?? "",
|
OrganizationName = s.ClassName ?? "",
|
||||||
FacePictureUrl = s.Photo ?? "",
|
FacePictureUrl = s.Photo ?? "",
|
||||||
Identity = "学生",
|
Identity = "学生",
|
||||||
@ -106,7 +106,20 @@ namespace YD_YiLu.Api.Services.Impl
|
|||||||
if (!orgId.HasValue) return new List<DeviceSyncOrganizationDto>();
|
if (!orgId.HasValue) return new List<DeviceSyncOrganizationDto>();
|
||||||
|
|
||||||
string schoolCode = await _context.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync();
|
string schoolCode = await _context.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync();
|
||||||
var grades = await _context.Grade.Where(x => x.SchoolCode == schoolCode).OrderBy(x => x.Id).ToListAsync();
|
|
||||||
|
var grades = await (
|
||||||
|
from g in _context.Grade
|
||||||
|
join sg in _context.SchoolAssocGrade
|
||||||
|
on g.Id equals sg.GradeId
|
||||||
|
where sg.SchoolCode == schoolCode
|
||||||
|
orderby g.Id
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
g.Id,
|
||||||
|
g.GradeName
|
||||||
|
}
|
||||||
|
).ToListAsync();
|
||||||
|
|
||||||
var classes = await _context.Class.Where(x => x.SchoolCode == schoolCode).ToListAsync();
|
var classes = await _context.Class.Where(x => x.SchoolCode == schoolCode).ToListAsync();
|
||||||
|
|
||||||
var result = new List<DeviceSyncOrganizationDto>();
|
var result = new List<DeviceSyncOrganizationDto>();
|
||||||
|
|||||||
@ -66,7 +66,7 @@ namespace YD_YiLu.Api.SmartSportsEntitys
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 有效个数
|
/// 有效个数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int StandardCounts { get; set; }
|
public double StandardCounts { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不合格动作数
|
/// 不合格动作数
|
||||||
|
|||||||
@ -325,6 +325,32 @@ namespace YD_YiLu.Api
|
|||||||
await next();
|
await next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.Use(async (context, next) =>
|
||||||
|
{
|
||||||
|
if (HttpMethods.IsPost(context.Request.Method) &&
|
||||||
|
context.Request.Path.Equals("/device/sync/train_push", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
context.Request.EnableBuffering();
|
||||||
|
context.Request.Body.Position = 0;
|
||||||
|
|
||||||
|
using (var reader = new StreamReader(context.Request.Body, leaveOpen: true))
|
||||||
|
{
|
||||||
|
var rawBody = await reader.ReadToEndAsync();
|
||||||
|
context.Request.Body.Position = 0;
|
||||||
|
context.Items["TrainPushRawBody"] = rawBody;
|
||||||
|
|
||||||
|
var logger = context.RequestServices.GetRequiredService<ILogger<Startup>>();
|
||||||
|
logger.LogInformation(
|
||||||
|
"TrainPush raw request received before model binding. ContentType: {ContentType}, ContentLength: {ContentLength}, Body: {RawBody}",
|
||||||
|
context.Request.ContentType,
|
||||||
|
context.Request.ContentLength,
|
||||||
|
rawBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await next();
|
||||||
|
});
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user