218 lines
6.8 KiB
C#
218 lines
6.8 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Reflection.Emit;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using VOL.Business.IServices;
|
|
using VOL.Business.IServices.School;
|
|
using VOL.Business.Services;
|
|
using VOL.Business.Services.Norm;
|
|
using VOL.Business.Services.School;
|
|
using VOL.Core.Filters;
|
|
using VOL.Core.ManageUser;
|
|
using VOL.Core.Utilities;
|
|
using VOL.Core.Utilities.Response;
|
|
using VOL.Entity.DomainModels;
|
|
using VOL.IOT.IServices;
|
|
using VOL.Model;
|
|
using VOL.Model.IOT;
|
|
using VOL.Model.IOT.Request;
|
|
using VOL.Model.IOT.Response;
|
|
using VOL.Model.Norm.Request;
|
|
using VOL.System.IRepositories;
|
|
using VOL.System.IServices;
|
|
|
|
namespace VOL.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 物联网接口
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v4")]
|
|
//[TypeFilter(typeof(CustomApiResponseFilter))]
|
|
//[ServiceFilter(typeof(IOTSignatureValidationFilter))]
|
|
[AllowAnonymous]
|
|
public class IOTController : ControllerBase
|
|
{
|
|
#region 初始化
|
|
private readonly HttpClient _httpClient;
|
|
private readonly IIOTUserService _iIOTUserService;
|
|
public IOTController(HttpClient httpClient, IIOTUserService iIOTUserService)
|
|
{
|
|
_httpClient = httpClient;
|
|
_iIOTUserService = iIOTUserService;
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 登录
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Login))]
|
|
public async Task<IOT_LoginInfoModel> Login([FromBody] LoginInfo loginInfo)
|
|
{
|
|
//long timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
|
|
|
//var requestBody = new { SchoolCode = "S_BS_001" };
|
|
|
|
//var json = JsonSerializer.Serialize(requestBody);
|
|
|
|
//var signature = IOTSignatureHelper.GenerateSignature(json, timestamp);
|
|
|
|
//_httpClient.DefaultRequestHeaders.Add("X-Timestamp", timestamp.ToString());
|
|
//_httpClient.DefaultRequestHeaders.Add("X-Signature", signature);
|
|
|
|
//HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
|
|
|
|
//var response = await _httpClient.PostAsync("http://localhost:9991/api/IOT/Test", content);
|
|
|
|
//response.EnsureSuccessStatusCode();
|
|
|
|
//var responseBody = await response.Content.ReadAsStringAsync();
|
|
//Console.WriteLine($"Response: {responseBody}");
|
|
|
|
var res = await _iIOTUserService.Login(loginInfo);
|
|
return res;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Test
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Test))]
|
|
public async Task<ActionResult> Test([FromBody] IOT_GradeListParam paramDto)
|
|
{
|
|
var res = await _iIOTUserService.GradePageList(paramDto);
|
|
return Ok(res);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 年级列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(GradePageList))]
|
|
public async Task<List<IOT_GradeListModel>> GradePageList([FromBody] IOT_GradeListParam paramDto)
|
|
{
|
|
var res = await _iIOTUserService.GradePageList(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 班级列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ClassPageList))]
|
|
public async Task<List<IOT_ClassListModel>> ClassPageList([FromBody] IOT_ClassListParam paramDto)
|
|
{
|
|
var res = await _iIOTUserService.ClassPageList(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 学生列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(StudentPageList))]
|
|
public async Task<List<IOT_StudentListModel>> StudentPageList([FromBody] IOT_StudentListParam paramDto)
|
|
{
|
|
var res = await _iIOTUserService.StudentPageList(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 老师列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(TeacherPageList))]
|
|
public async Task<List<IOT_TeacherListModel>> TeacherPageList([FromBody] IOT_SchoolParam paramDto)
|
|
{
|
|
var res = await _iIOTUserService.TeacherPageList(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 老师详情
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(TeacherDetails))]
|
|
public async Task<IOT_TeacherDetailsModel> TeacherDetails()
|
|
{
|
|
var res = await _iIOTUserService.TeacherDetails();
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 训练类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(TrainTypeList))]
|
|
public async Task<List<IOT_TrainTypeListModel>> TrainTypeList()
|
|
{
|
|
return await _iIOTUserService.TrainTypeList();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 训练项目类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ItemTypeList))]
|
|
public async Task<List<IOT_ItemTypeModel>> ItemTypeList()
|
|
{
|
|
return await _iIOTUserService.ItemTypeList();
|
|
}
|
|
/// <summary>
|
|
/// 体测项目类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(CategoryList))]
|
|
public async Task<List<IOT_CategoryListtModel>> CategoryList()
|
|
{
|
|
return await _iIOTUserService.CategoryList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传课堂训练信息
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(TankingLData))]
|
|
public async Task<ActionResult> TankingLData([FromBody] TankingDataParam paramDto)
|
|
{
|
|
await _iIOTUserService.TankingLData(paramDto);
|
|
return Ok("上传课堂训练信息成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传体测成绩信息
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(SportsTestData))]
|
|
public async Task<ActionResult> SportsTestData([FromBody] SportsTestDataParam paramDto)
|
|
{
|
|
await _iIOTUserService.SportsTestData(paramDto);
|
|
return Ok("上传体测成绩信息");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同步数据回调函数
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(DataSyncCallBack))]
|
|
public async Task<ActionResult> DataSyncCallBack([FromBody] DataSyncCallBackParam paramDto)
|
|
{
|
|
return Ok();
|
|
}
|
|
}
|
|
}
|