首次提交
This commit is contained in:
commit
ea0361038f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.vs/
|
||||
13
YD_AllHeartRates.Api/.config/dotnet-tools.json
Normal file
13
YD_AllHeartRates.Api/.config/dotnet-tools.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "8.0.8",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
28
YD_AllHeartRates.Api/AutoMappers/MappingProfile.cs
Normal file
28
YD_AllHeartRates.Api/AutoMappers/MappingProfile.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace YD_AllHeartRates.Api.AutoMappers
|
||||
{
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
public MappingProfile()
|
||||
{
|
||||
// 建立对象之间的映射规则
|
||||
// 如果有需要,您可以定义其他的映射规则
|
||||
// CreateMap<SourceClass2, DestinationClass2>();
|
||||
// ...
|
||||
|
||||
//CreateMap<AddHomeWorkDto, S_HomeWork>();
|
||||
|
||||
//CreateMap<XW_Device, DeviceInfoDto>();
|
||||
//CreateMap<AddTrainDto, XW_SportsTestData>();
|
||||
//CreateMap<TrainStudentsDto, XW_TrainStudents>();
|
||||
//CreateMap<TrainSettingDto, XW_TrainSetting>();
|
||||
//CreateMap<TrainViolationsBODto, XW_TrainViolationsBO>();
|
||||
|
||||
//CreateMap<XW_SportsTestData, TrainDto>();
|
||||
//CreateMap<XW_TrainStudents, TrainStudentsDto>();
|
||||
//CreateMap<XW_TrainSetting, TrainSettingDto>();
|
||||
//CreateMap<XW_TrainViolationsBO, TrainViolationsBODto>();
|
||||
}
|
||||
}
|
||||
}
|
||||
31
YD_AllHeartRates.Api/Context/SmartSportsContext.cs
Normal file
31
YD_AllHeartRates.Api/Context/SmartSportsContext.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Context
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户服务上下文
|
||||
/// </summary>
|
||||
public class SmartSportsContext : DbContext
|
||||
{
|
||||
public SmartSportsContext(DbContextOptions<SmartSportsContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
//public DbSet<S_Class> Class { get; set; }
|
||||
//public DbSet<S_Grade> Grade { get; set; }
|
||||
//public DbSet<S_SchoolAssocGrade> SchoolAssocGrade { get; set; }
|
||||
//public DbSet<S_Student> Student { get; set; }
|
||||
//public DbSet<S_School> School { get; set; }
|
||||
//public DbSet<Sys_User> Sys_User { get; set; }
|
||||
//public DbSet<N_HealthStandards> HealthStandards { get; set; }
|
||||
//public DbSet<N_SportsTestCategory> SportsTestCategory { get; set; }
|
||||
//public DbSet<N_SportsTestValue> SportsTestValue { get; set; }
|
||||
|
||||
//public DbSet<XW_ProjectMode> XW_ProjectMode { get; set; }
|
||||
//public DbSet<XW_TestingProject> XW_TestingProject { get; set; }
|
||||
//public DbSet<XW_Device> XW_Device { get; set; }
|
||||
//public DbSet<XW_SportsTestData> XW_SportsTestData { get; set; }
|
||||
//public DbSet<XW_TrainStudents> XW_TrainStudents { get; set; }
|
||||
//public DbSet<XW_TrainSetting> XW_TrainSetting { get; set; }
|
||||
//public DbSet<XW_TrainViolationsBO> XW_TrainViolationsBO { get; set; }
|
||||
}
|
||||
}
|
||||
18
YD_AllHeartRates.Api/Context/UserContext.cs
Normal file
18
YD_AllHeartRates.Api/Context/UserContext.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using YD_AllHeartRates.Api.Entitys;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Context
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户服务上下文
|
||||
/// </summary>
|
||||
public class UserContext : DbContext
|
||||
{
|
||||
public UserContext(DbContextOptions<UserContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
public DbSet<TestTable> TestTable { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
}
|
||||
}
|
||||
215
YD_AllHeartRates.Api/Controllers/XinWeiController.cs
Normal file
215
YD_AllHeartRates.Api/Controllers/XinWeiController.cs
Normal file
@ -0,0 +1,215 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using YD_AllHeartRates.Api.Services.Impl;
|
||||
using YD_AllHeartRates.Api.Services.Interface;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 芯未
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[AllowAnonymous]
|
||||
public class XinWeiController : ControllerBase
|
||||
{
|
||||
//private readonly IXinWeiService _xinWeiService;
|
||||
//public XinWeiController(IXinWeiService xinWeiService)
|
||||
//{
|
||||
// _xinWeiService = xinWeiService;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取设备信息
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/basic/{apiVersion}/device/open/getDeviceInfo")]
|
||||
//public async Task<DeviceInfoDto> GetDeviceInfo(string deviceSerial)
|
||||
//{
|
||||
// var res = await _xinWeiService.DeviceInfo(deviceSerial);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取项目模式列表
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/common/getSportsModelTypeList")]
|
||||
//public async Task<List<ProjectModeDto>> GetSportsModelTypeList()
|
||||
//{
|
||||
// var res = await _xinWeiService.SportsModelTypeList();
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取体育项目列表
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/common/getOrgSportsProjectList")]
|
||||
//public async Task<List<TestingProjectDto>> GetOrgSportsProjectList(int orgId)
|
||||
//{
|
||||
// var res = await _xinWeiService.OrgSportsProjectList(orgId);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取学生信息
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/roster/getMinimumOfStudentInfoList")]
|
||||
//public async Task<List<StudentInfoDto>> GetMinimumOfStudentInfoList(int orgId)
|
||||
//{
|
||||
// var res = await _xinWeiService.MinimumOfStudentInfoList(orgId);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取名单列表
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/roster/getSportsRosterList")]
|
||||
//public async Task<List<SportsRosterDto>> GetSportsRosterList(int orgId, int userId)
|
||||
//{
|
||||
// var res = await _xinWeiService.SportsRosterList(orgId, userId);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取人脸信息
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/basic/{apiVersion}/open/getFaceListOfDevicePage")]
|
||||
//public async Task<FaceListOfDevicePageDto> GetFaceListOfDevicePage([FromQuery] FaceListOfDeviceDto dto)
|
||||
//{
|
||||
// var res = await _xinWeiService.FaceListOfDevicePage(dto);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 查询训练评分规则
|
||||
///// </summary>
|
||||
///// <param name="orgId"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/project/getScoreRules")]
|
||||
//public async Task<List<ScoreRuleDto>> GetScoreRules(int orgId)
|
||||
//{
|
||||
// var res = await _xinWeiService.ScoreRules(orgId);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 新增训练
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpPost]
|
||||
//[Route("/sports/{apiVersion}/train/addTrain")]
|
||||
//public async Task<TrainDto> AddTrain([FromBody] AddTrainDto dto)
|
||||
//{
|
||||
// Console.WriteLine("开始上传");
|
||||
// var res = await _xinWeiService.AddTrain(dto);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 年级排名
|
||||
///// </summary>
|
||||
///// <param name="studentId"></param>
|
||||
///// <param name="trainId"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/trainAnalysis/gradeRankingGet")]
|
||||
//public async Task<GradeRankingVo> GradeRankingGet(int studentId, int trainId)
|
||||
//{
|
||||
// var res = await _xinWeiService.GradeRankingGet(studentId, trainId);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 全部历史记录
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/trainAnalysis/history/get")]
|
||||
//public async Task<TrainHistoryResponseDto> HistoryGet(HistoryGetDto dto)
|
||||
//{
|
||||
// var res = await _xinWeiService.HistoryGet(dto);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 历史记录详细
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/trainAnalysis/history/detail")]
|
||||
//public async Task<TrainAnalusisVo> TrainAnalysisHistoryDetail(HistoryDetailRequestDto dto)
|
||||
//{
|
||||
// var res = await _xinWeiService.TrainAnalysisHistoryDetail(dto);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-历史成绩
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/trainAnalysis/history/person/get")]
|
||||
//public async Task<TrainHistoryPersonVo> HistoryPersonGet(HistoryPersonGetDto dto)
|
||||
//{
|
||||
// var res = await _xinWeiService.HistoryPersonGet(dto);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-记录列表
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/trainAnalysis/history/person/list")]
|
||||
//public async Task<TableDataPersonAnalysisVo> HistoryPersonListGet(HistoryPersonListDto dto)
|
||||
//{
|
||||
// var res = await _xinWeiService.HistoryPersonListGet(dto);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 成绩榜-年级列表
|
||||
///// </summary>
|
||||
///// <param name="orgId"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/basic/{apiVersion}/open/getGradeListByOrg")]
|
||||
//public async Task<List<GradeVo>> GetGradeListByOrg(int orgId)
|
||||
//{
|
||||
// var res = await _xinWeiService.GetGradeListByOrg(orgId);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-榜单列表
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route("/sports/{apiVersion}/trainAnalysis/scoreRanking/list")]
|
||||
//public async Task<ScoreRankingVo> ScoreRanking(ScoreRankingDto dto)
|
||||
//{
|
||||
// var res = await _xinWeiService.ScoreRanking(dto);
|
||||
// return res;
|
||||
//}
|
||||
}
|
||||
}
|
||||
53
YD_AllHeartRates.Api/Entitys/EntityBase.cs
Normal file
53
YD_AllHeartRates.Api/Entitys/EntityBase.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库实体父类
|
||||
/// </summary>
|
||||
public class EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
///备注
|
||||
/// </summary>
|
||||
[Display(Name = "备注")]
|
||||
[Comment("备注")]
|
||||
[Column(TypeName = "text")]
|
||||
public string? Remarks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///创建人
|
||||
/// </summary>
|
||||
[Display(Name = "创建人")]
|
||||
[Comment("创建人")]
|
||||
[Column(TypeName = "int)")]
|
||||
public int? Creator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///创建时间
|
||||
/// </summary>
|
||||
[Display(Name = "创建时间")]
|
||||
[Comment("创建时间")]
|
||||
[Column(TypeName = "datetime")]
|
||||
[Editable(true)]
|
||||
public DateTime? CreateDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///修改人
|
||||
/// </summary>
|
||||
[Display(Name = "修改人")]
|
||||
[Comment("修改人")]
|
||||
[Column(TypeName = "int)")]
|
||||
public int? Modifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///修改时间
|
||||
/// </summary>
|
||||
[Display(Name = "修改时间")]
|
||||
[Comment("修改时间")]
|
||||
[Column(TypeName = "datetime")]
|
||||
public DateTime? ModifyDate { get; set; }
|
||||
}
|
||||
}
|
||||
46
YD_AllHeartRates.Api/Entitys/TestTable.cs
Normal file
46
YD_AllHeartRates.Api/Entitys/TestTable.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Entitys
|
||||
{
|
||||
[Table("TestTable")]
|
||||
public class TestTable
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Description = "主键Id")]
|
||||
[Comment("Id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///Name
|
||||
/// </summary>
|
||||
[Display(Name = "Name")]
|
||||
[Comment("Name")]
|
||||
[Column(TypeName = "nvarchar(100)")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///Json
|
||||
/// </summary>
|
||||
[Display(Name = "Json")]
|
||||
[Comment("Json")]
|
||||
[Column(TypeName = "nvarchar(100)")]
|
||||
public string Json { get; set; }
|
||||
}
|
||||
|
||||
public class JsonDeta
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string CreateTime { get; set; }
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public double Value1 { get; set; }
|
||||
public double Value2 { get; set; }
|
||||
public double Value3 { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
208
YD_AllHeartRates.Api/Entitys/User.cs
Normal file
208
YD_AllHeartRates.Api/Entitys/User.cs
Normal file
@ -0,0 +1,208 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Entitys
|
||||
{
|
||||
|
||||
[Table("User")]
|
||||
public class User : EntityBase
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Description = "主键Id")]
|
||||
[Comment("Id")]
|
||||
public int User_Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///学校编号
|
||||
/// </summary>
|
||||
[Display(Name = "学校编号")]
|
||||
[Comment("学校编号")]
|
||||
[Column(TypeName = "nvarchar(100)")]
|
||||
public string SchoolCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///帐号
|
||||
/// </summary>
|
||||
[Display(Name = "帐号")]
|
||||
[Comment("帐号")]
|
||||
[MaxLength(100)]
|
||||
[Column(TypeName = "nvarchar(100)")]
|
||||
[Editable(true)]
|
||||
[Required(AllowEmptyStrings = false)]
|
||||
public string? UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///性别
|
||||
/// </summary>
|
||||
[Display(Name = "性别")]
|
||||
[Comment("性别")]
|
||||
[Column(TypeName = "int")]
|
||||
[Editable(true)]
|
||||
public int? Gender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///头像
|
||||
/// </summary>
|
||||
[Display(Name = "头像")]
|
||||
[Comment("头像")]
|
||||
[MaxLength(500)]
|
||||
[Column(TypeName = "nvarchar(500)")]
|
||||
[Editable(true)]
|
||||
public string? HeadImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///角色
|
||||
/// </summary>
|
||||
[Display(Name = "角色Id")]
|
||||
[Comment("角色Id")]
|
||||
[Column(TypeName = "int")]
|
||||
[Editable(true)]
|
||||
[Required(AllowEmptyStrings = false)]
|
||||
public int Role_Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///角色
|
||||
/// </summary>
|
||||
[Display(Name = "角色")]
|
||||
[Comment("角色")]
|
||||
[MaxLength(200)]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
[Editable(true)]
|
||||
public string? RoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///姓名
|
||||
/// </summary>
|
||||
[Display(Name = "姓名")]
|
||||
[Comment("姓名")]
|
||||
[MaxLength(200)]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
[Editable(true)]
|
||||
//[Required(AllowEmptyStrings=false)]
|
||||
public string? UserTrueName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///密码
|
||||
/// </summary>
|
||||
[Display(Name = "密码")]
|
||||
[Comment("密码")]
|
||||
[MaxLength(200)]
|
||||
[JsonIgnore]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
public string? UserPwd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///手机号
|
||||
/// </summary>
|
||||
[Display(Name = "手机号")]
|
||||
[Comment("手机号")]
|
||||
[MaxLength(11)]
|
||||
[Column(TypeName = "nvarchar(11)")]
|
||||
public string? PhoneNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///是否可用
|
||||
/// </summary>
|
||||
[Display(Name = "是否可用")]
|
||||
[Comment("是否可用")]
|
||||
[Column(TypeName = "tinyint")]
|
||||
[Editable(true)]
|
||||
[Required(AllowEmptyStrings = false)]
|
||||
public bool Enable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信OpenId
|
||||
/// </summary>
|
||||
[Display(Name = "微信OpenId")]
|
||||
[Comment("微信OpenId")]
|
||||
[MaxLength(200)]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
[Editable(true)]
|
||||
public string? wx_OpenID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信UnionId
|
||||
/// </summary>
|
||||
[Display(Name = "微信UnionId")]
|
||||
[Comment("微信UnionId")]
|
||||
[MaxLength(200)]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
[Editable(true)]
|
||||
public string? wx_UnionID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信头像
|
||||
/// </summary>
|
||||
[Display(Name = "微信头像")]
|
||||
[Comment("微信头像")]
|
||||
[MaxLength(2000)]
|
||||
[Column(TypeName = "nvarchar(2000)")]
|
||||
[Editable(true)]
|
||||
public string? wx_HeadImgUrl { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信昵称
|
||||
/// </summary>
|
||||
[Display(Name = "微信昵称")]
|
||||
[Comment("微信昵称")]
|
||||
[MaxLength(200)]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
[Editable(true)]
|
||||
public string? wx_NickName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
///地址
|
||||
/// </summary>
|
||||
[Display(Name = "地址")]
|
||||
[Comment("地址")]
|
||||
[MaxLength(200)]
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
[Editable(true)]
|
||||
public string? Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///Email
|
||||
/// </summary>
|
||||
[Display(Name = "Email")]
|
||||
[Comment("Email")]
|
||||
[MaxLength(100)]
|
||||
[Column(TypeName = "nvarchar(100)")]
|
||||
[Editable(true)]
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账号关联Id
|
||||
/// </summary>
|
||||
public Guid RelevanceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///出生日期
|
||||
/// </summary>
|
||||
[Display(Name = "出生日期")]
|
||||
[Comment("出生日期")]
|
||||
[Column(TypeName = "datetime")]
|
||||
[Editable(true)]
|
||||
public DateTime? BirthDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 身高
|
||||
/// </summary>
|
||||
[Display(Name = "身高")]
|
||||
[Comment("身高")]
|
||||
[Column(TypeName = "float")]
|
||||
[Editable(true)]
|
||||
public float? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 体重
|
||||
/// </summary>
|
||||
[Display(Name = "体重")]
|
||||
[Comment("体重")]
|
||||
[Column(TypeName = "float")]
|
||||
[Editable(true)]
|
||||
public float? Weight { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
namespace YD_AllHeartRates.Api.Extensions
|
||||
{
|
||||
public static class StaticHttpContextExtensions
|
||||
{
|
||||
//public static void AddHttpContextAccessor(this IServiceCollection services)
|
||||
//{
|
||||
// services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
//}
|
||||
|
||||
public static IApplicationBuilder UseStaticHttpContext(this IApplicationBuilder app)
|
||||
{
|
||||
var httpContextAccessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
|
||||
Utilities.HttpContext.Configure(httpContextAccessor);
|
||||
return app;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
YD_AllHeartRates.Api/Fakes/YD_AllHeartRates.Commons.fakes
Normal file
BIN
YD_AllHeartRates.Api/Fakes/YD_AllHeartRates.Commons.fakes
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
C:\Users\tangl\Desktop\YD_XinWei\YD_AllHeartRates\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.Dto.ResponseMsg 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
|
||||
C:\Users\tangl\Desktop\YD_XinWei\YD_AllHeartRates\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.MemoryCaches.MemoryCacheSetup 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
|
||||
C:\Users\tangl\Desktop\YD_XinWei\YD_AllHeartRates\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.Middlewares.SystemExceptionApplicationBuilderExtensions 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
|
||||
C:\Users\tangl\Desktop\YD_XinWei\YD_AllHeartRates\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.Utils.Util 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
|
||||
C:\Users\tangl\Desktop\YD_XinWei\YD_AllHeartRates\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 正在跳过 method System.Int32 YD_AllHeartRates.Commons.Utils.Util.GetRank(!!0 score),method System.Int32 YD_AllHeartRates.Commons.Utils.Util.GetRank(!!0 score) unstubbable: 无法同时指定类约束和 "class" 或 "struct" 约束
|
||||
C:\Users\tangl\Desktop\YD_XinWei\YD_AllHeartRates\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 正在跳过 method System.String YD_AllHeartRates.Commons.Utils.Util.GetRankStr(!!0 score),method System.String YD_AllHeartRates.Commons.Utils.Util.GetRankStr(!!0 score) unstubbable: 无法同时指定类约束和 "class" 或 "struct" 约束
|
||||
File diff suppressed because it is too large
Load Diff
27
YD_AllHeartRates.Api/Program.cs
Normal file
27
YD_AllHeartRates.Api/Program.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace YD_AllHeartRates.Api
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
host.Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.ConfigureKestrel(serverOptions =>
|
||||
{
|
||||
serverOptions.Limits.MaxRequestBodySize = 10485760;
|
||||
});
|
||||
webBuilder.UseKestrel().UseUrls("http://*:9994");
|
||||
webBuilder.UseIIS();
|
||||
webBuilder.UseStartup<Startup>();
|
||||
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>C:\Users\tangl\Desktop\web</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ProjectGuid>9afb29dd-781b-44b2-a88c-562a0ffdaac3</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>C:\Users\tangl\Desktop\web</_PublishTargetUrl>
|
||||
<History>True|2025-04-03T07:07:55.2812036Z||;True|2025-03-18T10:41:46.9539024+08:00||;True|2025-03-18T09:03:55.5838708+08:00||;True|2025-03-17T12:30:21.5399192+08:00||;True|2025-03-17T11:54:27.3261861+08:00||;True|2025-03-17T11:20:23.7942104+08:00||;True|2025-03-11T17:48:55.2957005+08:00||;False|2025-03-11T17:48:38.1452073+08:00||;True|2025-03-07T16:31:26.6256757+08:00||;True|2025-03-07T15:14:30.2549136+08:00||;True|2025-03-07T14:57:41.5400532+08:00||;True|2025-03-07T14:53:16.1364435+08:00||;False|2025-03-07T14:52:47.3342548+08:00||;False|2025-03-07T14:52:10.7452463+08:00||;False|2025-03-07T14:51:33.5424415+08:00||;True|2025-03-07T14:46:55.5807563+08:00||;True|2025-03-07T14:33:04.1266862+08:00||;True|2025-03-07T14:13:22.6999976+08:00||;True|2025-03-07T14:05:09.5133651+08:00||;False|2025-03-07T14:02:23.5093029+08:00||;False|2025-03-07T13:58:37.4496383+08:00||;True|2025-03-07T11:52:20.4578386+08:00||;True|2025-03-07T11:31:43.1972462+08:00||;True|2025-03-07T10:11:26.1562979+08:00||;True|2025-03-07T10:10:59.9440630+08:00||;True|2025-03-07T09:24:15.8595227+08:00||;True|2025-03-06T17:52:31.4924325+08:00||;True|2025-03-06T17:52:19.1631772+08:00||;True|2025-03-06T17:32:57.7195879+08:00||;True|2025-03-06T17:09:15.6877706+08:00||;True|2025-03-06T16:59:48.0866771+08:00||;True|2025-03-06T16:49:15.3348344+08:00||;True|2025-03-06T15:51:10.7923322+08:00||;True|2025-03-06T15:46:02.5442595+08:00||;True|2025-03-06T14:32:36.1899505+08:00||;True|2025-03-06T14:04:43.6692503+08:00||;True|2025-03-06T10:00:58.4898730+08:00||;True|2025-03-06T09:59:50.3712985+08:00||;True|2025-03-06T09:03:59.1856247+08:00||;True|2025-03-04T17:35:37.1204893+08:00||;True|2025-03-04T17:18:56.4230027+08:00||;True|2025-03-04T16:59:02.6637491+08:00||;True|2025-03-04T15:21:05.4912749+08:00||;True|2025-03-04T15:08:42.5490957+08:00||;True|2025-03-04T15:01:08.8651148+08:00||;True|2025-03-03T17:31:47.5325183+08:00||;True|2025-03-03T17:09:05.8362354+08:00||;True|2025-03-03T16:41:37.7278763+08:00||;True|2025-03-03T16:34:04.0026009+08:00||;True|2025-03-03T16:24:01.4887542+08:00||;True|2025-03-03T15:24:09.5376627+08:00||;True|2025-03-03T14:32:46.5288364+08:00||;True|2025-03-03T14:18:41.8795454+08:00||;True|2025-03-03T13:39:33.1620349+08:00||;True|2025-03-03T13:13:48.7851364+08:00||;True|2025-03-03T09:48:28.0446948+08:00||;True|2025-03-03T09:47:48.0506237+08:00||;True|2025-03-03T00:03:13.7940731+08:00||;True|2025-03-03T00:00:20.5217808+08:00||;True|2025-02-28T11:24:13.9529058+08:00||;True|2025-02-28T09:52:09.1224260+08:00||;True|2025-02-28T09:09:07.6159508+08:00||;True|2025-02-28T09:03:19.5987556+08:00||;True|2025-02-27T17:59:35.8321576+08:00||;True|2025-02-27T16:51:44.0193039+08:00||;True|2025-02-27T15:48:03.7178463+08:00||;True|2025-02-27T15:39:09.5704225+08:00||;True|2025-02-27T15:39:01.0906094+08:00||;True|2025-02-27T15:35:52.5141530+08:00||;True|2025-02-27T15:22:55.6480561+08:00||;True|2025-02-25T15:05:56.3704383+08:00||;True|2025-02-25T13:21:45.5812878+08:00||;True|2025-02-25T13:13:06.3991346+08:00||;True|2025-02-25T11:07:59.4322341+08:00||;True|2025-02-24T17:36:36.0385118+08:00||;True|2025-02-24T17:35:30.9660778+08:00||;True|2025-02-20T19:00:03.7732903+08:00||;True|2025-02-20T15:23:37.7886196+08:00||;False|2025-02-20T15:22:58.3942454+08:00||;True|2025-02-14T15:16:29.2049523+08:00||;True|2025-02-14T15:16:20.2358210+08:00||;True|2025-02-14T13:35:25.1397559+08:00||;True|2025-02-14T09:28:15.0882633+08:00||;True|2025-02-13T14:51:00.7069070+08:00||;True|2025-02-13T13:14:19.5524368+08:00||;True|2025-02-12T15:43:03.6376536+08:00||;True|2025-02-12T15:30:37.0534250+08:00||;True|2025-02-12T15:19:48.3629666+08:00||;True|2025-02-12T15:15:46.5702121+08:00||;True|2025-02-12T10:25:29.9566462+08:00||;True|2025-02-12T10:25:23.6583245+08:00||;False|2025-02-12T10:24:25.4235783+08:00||;True|2024-10-08T10:27:01.3672443+08:00||;True|2024-10-08T10:16:00.0834614+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
31
YD_AllHeartRates.Api/Properties/launchSettings.json
Normal file
31
YD_AllHeartRates.Api/Properties/launchSettings.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:26689",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"YD_AllHeartRates": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5255",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
871
YD_AllHeartRates.Api/Services/Impl/XinWeiService.cs
Normal file
871
YD_AllHeartRates.Api/Services/Impl/XinWeiService.cs
Normal file
@ -0,0 +1,871 @@
|
||||
|
||||
namespace YD_AllHeartRates.Api.Services.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务实现
|
||||
/// </summary>
|
||||
//public class XinWeiService : IXinWeiService
|
||||
//{
|
||||
//public SmartSportsContext _sportsContext;
|
||||
//private readonly IMapper _mapper;
|
||||
|
||||
///// <summary>
|
||||
///// 构造
|
||||
///// </summary>
|
||||
///// <param name="sportsContext"></param>
|
||||
///// <param name="mapper"></param>
|
||||
//public XinWeiService(SmartSportsContext sportsContext, IMapper mapper)
|
||||
//{
|
||||
// _sportsContext = sportsContext;
|
||||
// _mapper = mapper;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取设备信息
|
||||
///// </summary>
|
||||
///// <param name="deviceSerial"></param>
|
||||
///// <returns></returns>
|
||||
///// <exception cref="NotImplementedException"></exception>
|
||||
//public async Task<DeviceInfoDto> DeviceInfo(string deviceSerial)
|
||||
//{
|
||||
// var deviceInfo = await _sportsContext.XW_Device.FirstOrDefaultAsync(x => x.DeviceSerial == deviceSerial);
|
||||
// var res = _mapper.Map<DeviceInfoDto>(deviceInfo);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 项目模式
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public async Task<List<ProjectModeDto>> SportsModelTypeList()
|
||||
//{
|
||||
// var res = await _sportsContext.XW_ProjectMode.Select(x => new ProjectModeDto()
|
||||
// {
|
||||
// Id = x.Id,
|
||||
// ProjectKind = x.ProjectKind,
|
||||
// Name = x.Name
|
||||
// }).ToListAsync();
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 体育项目
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <returns></returns>
|
||||
|
||||
//public async Task<List<TestingProjectDto>> OrgSportsProjectList(int orgId)
|
||||
//{
|
||||
// //var res = await _sportsContext.XW_TestingProject.Where(x => x.OrgId == orgId).Select(x => new TestingProjectDto()
|
||||
// var res = await _sportsContext.XW_TestingProject.Select(x => new TestingProjectDto()
|
||||
// {
|
||||
// ProjectId = x.ProjectId,
|
||||
// IsOpen = x.IsOpen,
|
||||
// IsShow = x.IsShow,
|
||||
// ProjectName = x.ProjectName
|
||||
// }).ToListAsync();
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取学生信息
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <returns></returns>
|
||||
//public async Task<List<StudentInfoDto>> MinimumOfStudentInfoList(int orgId)
|
||||
//{
|
||||
// string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync();
|
||||
|
||||
// var res = await (from s in _sportsContext.Student
|
||||
// join c in _sportsContext.Class on s.ClassId equals c.Id
|
||||
// join g in _sportsContext.Grade on c.GradeId equals g.Id
|
||||
// where s.SchoolCode == schoolCode
|
||||
// select new StudentInfoDto()
|
||||
// {
|
||||
// Id = s.Id,
|
||||
// OrgId = orgId,
|
||||
// UserId = s.Id,
|
||||
// StudentNo = s.StudentNo,
|
||||
// Name = s.StudentName,
|
||||
// Sex = s.Sex == 1 ? "男" : "女",
|
||||
// ClassId = c.Id,
|
||||
// GradeId = g.Id,
|
||||
// RuleGradeId = g.Id,
|
||||
// ClassName = c.ClassName,
|
||||
// GradeName = g.GradeName,
|
||||
// CardNo = new List<string>()
|
||||
// }).ToListAsync();
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取名单列表
|
||||
///// </summary>
|
||||
///// <param name="orgId"></param>
|
||||
///// <param name="userId"></param>
|
||||
///// <returns></returns>
|
||||
///// <exception cref="NotImplementedException"></exception>
|
||||
//public async Task<List<SportsRosterDto>> SportsRosterList(int orgId, int userId = 0)
|
||||
//{
|
||||
// string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync();
|
||||
// var studentList = await _sportsContext.Student.Where(x => x.SchoolCode == schoolCode).ToListAsync();
|
||||
|
||||
// var list = await (from c in _sportsContext.Class
|
||||
// join g in _sportsContext.Grade on c.GradeId equals g.Id
|
||||
// where c.SchoolCode == schoolCode
|
||||
// select new SportsRosterDto()
|
||||
// {
|
||||
// Id = c.Id,
|
||||
// OrgId = orgId,
|
||||
// Name = c.ClassName,
|
||||
// GradeId = g.Id,
|
||||
// RuleGradeId = g.Id,
|
||||
// GradeName = g.GradeName,
|
||||
// Status = 1,
|
||||
// Type = 1
|
||||
// }).ToListAsync();
|
||||
|
||||
|
||||
// foreach (var item in list)
|
||||
// {
|
||||
// var stuList = studentList.Where(x => x.ClassId == item.Id).ToList();
|
||||
// List<SportsRosterStudentDto> sportList1 = new List<SportsRosterStudentDto>();
|
||||
|
||||
// foreach (var sport in stuList)
|
||||
// {
|
||||
// sportList1.Add(new SportsRosterStudentDto()
|
||||
// {
|
||||
// Id = sport.Id,
|
||||
// GroupName = item.Name,
|
||||
// ClassId = item.Id,
|
||||
// ClassName = item.Name,
|
||||
// GradeId = item.GradeId,
|
||||
// GradeName = item.GradeName,
|
||||
// OrgId = orgId,
|
||||
// Sex = sport.Sex,
|
||||
// UserName = sport.StudentName,
|
||||
// StudentNo = sport.StudentNo,
|
||||
// UserId = sport.Id,
|
||||
// GroupOrder = sport.Id,
|
||||
// RosterId = 1,
|
||||
// });
|
||||
// }
|
||||
|
||||
// item.RosterGroupList.Add(new SportsRosterGroupDto()
|
||||
// {
|
||||
// GroupName = item.Name,
|
||||
// RosterStudentList = sportList1
|
||||
// });
|
||||
// }
|
||||
|
||||
// //var list1 = list.Select(x => new SportsRosterDto
|
||||
// //{
|
||||
// // Type = 2
|
||||
// //}).ToList();
|
||||
|
||||
|
||||
// //var mergedList = list.Concat(list1).ToList();
|
||||
|
||||
// return list;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取人脸信息
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<FaceListOfDevicePageDto> FaceListOfDevicePage(FaceListOfDeviceDto dto)
|
||||
//{
|
||||
// string schoolCode = await _sportsContext.School.Where(x => x.Id == dto.OrgId).Select(x => x.SchoolCode).FirstAsync();
|
||||
|
||||
// var total = await _sportsContext.Student.CountAsync(x => x.SchoolCode == schoolCode && !string.IsNullOrWhiteSpace(x.Photo));
|
||||
|
||||
// var list = await _sportsContext.Student
|
||||
// .Where(x => x.SchoolCode == schoolCode && !string.IsNullOrWhiteSpace(x.Photo))
|
||||
// .Select(s => new DeviceUserFaceVo()
|
||||
// {
|
||||
// FaceId = s.StudentNo,
|
||||
// FaceType = 1,
|
||||
// FaceUrl = s.Photo,
|
||||
// PersonId = s.StudentNo,
|
||||
// UserId = s.Id
|
||||
// })
|
||||
// .Skip((dto.PageNo - 1) * dto.PageSize)
|
||||
// .Take(dto.PageSize)
|
||||
// .ToListAsync();
|
||||
|
||||
// return new FaceListOfDevicePageDto()
|
||||
// {
|
||||
// Total = total,
|
||||
// PageNum = dto.PageNo,
|
||||
// PageSize = dto.PageSize,
|
||||
// Pages = (int)Math.Ceiling((double)total / dto.PageSize),
|
||||
// List = list
|
||||
// };
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取训练评分规则
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <returns></returns>
|
||||
//public async Task<List<ScoreRuleDto>> ScoreRules(int orgId)
|
||||
//{
|
||||
// var scoreRules = await _sportsContext.HealthStandards.ToListAsync();
|
||||
// var projects = await _sportsContext.XW_TestingProject.ToListAsync();
|
||||
// var projectModels = await _sportsContext.XW_ProjectMode.ToListAsync();
|
||||
|
||||
// var scoreRuleItemsByType = scoreRules
|
||||
// .GroupBy(x => x.CategoryEnum)
|
||||
// .ToDictionary(g => g.Key, g => g.ToList());
|
||||
|
||||
// List<ScoreRuleDto> res = new List<ScoreRuleDto>();
|
||||
|
||||
// foreach (var projectModel in projectModels)
|
||||
// {
|
||||
// var project = projects.FirstOrDefault(x => x.ProjectId == projectModel.ProjectKind);
|
||||
// if (project == null) continue; // Skip if project doesn't exist
|
||||
|
||||
// var scoreRuleTypes = projectModel.CategoryEnum.Split(',');
|
||||
// var scoreRuleItems = scoreRuleTypes.SelectMany(type => scoreRuleItemsByType.GetValueOrDefault(type, new List<N_HealthStandards>())).ToList();
|
||||
|
||||
// var groupedItemsData = scoreRuleItems.GroupBy(x => x.GradeId).ToList();
|
||||
|
||||
// foreach (var grouped in groupedItemsData)
|
||||
// {
|
||||
// var maleItems = grouped.Where(x => x.Sex == 1).ToList();
|
||||
// var femaleItems = grouped.Where(x => x.Sex == 2).ToList();
|
||||
|
||||
// var maleMax = maleItems.DefaultIfEmpty().Max(x => x?.MaxValue ?? 0);
|
||||
// var maleMin = maleItems.DefaultIfEmpty().Max(x => x?.MinValue ?? 0);
|
||||
// var maleMaxScore = maleItems.DefaultIfEmpty().Max(x => x?.Score ?? 0);
|
||||
|
||||
// var femaleMax = femaleItems.DefaultIfEmpty().Max(x => x?.MaxValue ?? 0);
|
||||
// var femaleMin = femaleItems.DefaultIfEmpty().Max(x => x?.MinValue ?? 0);
|
||||
// var femaleMaxScore = femaleItems.DefaultIfEmpty().Max(x => x?.Score ?? 0);
|
||||
|
||||
// ScoreRuleDto scoreRuleDto = new ScoreRuleDto
|
||||
// {
|
||||
// GradeId = grouped.Key,
|
||||
// OrgId = orgId,
|
||||
// ProjectKind = project.ProjectId,
|
||||
// ProjectName = project.ProjectName,
|
||||
// ModelType = projectModel.Id,
|
||||
// RuleType = 1,
|
||||
// ProjectId = project.ProjectId,
|
||||
// Items = grouped.Select(item => new ScoreRuleItemDto
|
||||
// {
|
||||
// Id = item.Id,
|
||||
// Sex = item.Sex,
|
||||
// Name = item.Score.GetRank().ToString(),
|
||||
// Score = item.Score,
|
||||
// Max = item.MaxValue,
|
||||
// Min = item.MinValue
|
||||
// }).OrderByDescending(x => x.Min).ToList()
|
||||
// };
|
||||
|
||||
// scoreRuleDto.Pluses = new List<ScoreRulePlusDto>
|
||||
// {
|
||||
// //new ScoreRulePlusDto()
|
||||
// //{
|
||||
// // Id = grouped.FirstOrDefault()?.Id ?? 0,
|
||||
// // Sex = 1,
|
||||
// // Max = maleMax,
|
||||
// // Min = maleMin,
|
||||
// // MaxScore = maleMaxScore,
|
||||
// // Score = maleMaxScore
|
||||
// //},
|
||||
// //new ScoreRulePlusDto()
|
||||
// //{
|
||||
// // Id = grouped.FirstOrDefault()?.Id ?? 0,
|
||||
// // Sex = 2,
|
||||
// // Max = femaleMax,
|
||||
// // Min = femaleMin,
|
||||
// // MaxScore = femaleMaxScore,
|
||||
// // Score = femaleMaxScore
|
||||
// //}
|
||||
// };
|
||||
|
||||
// scoreRuleDto.ScoreScopes = new List<ScoreScope>
|
||||
// {
|
||||
// //new ScoreScope()
|
||||
// //{
|
||||
// // Gender = 1,
|
||||
// // MaxScore = maleMaxScore,
|
||||
// // MaxCount = maleMax
|
||||
// //},
|
||||
// //new ScoreScope()
|
||||
// //{
|
||||
// // Gender = 2,
|
||||
// // MaxScore = femaleMaxScore,
|
||||
// // MaxCount = femaleMax
|
||||
// //}
|
||||
// };
|
||||
|
||||
// res.Add(scoreRuleDto);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 新增训练
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<TrainDto> AddTrain(AddTrainDto dto)
|
||||
//{
|
||||
// var xwProject = await _sportsContext.XW_TestingProject.ToListAsync();
|
||||
// var healthStandards = await _sportsContext.HealthStandards.ToListAsync();
|
||||
|
||||
// try
|
||||
// {
|
||||
// dto.StudentList.ForEach(stu =>
|
||||
// {
|
||||
// var project = xwProject.Where(x => x.ProjectId == dto.ProjectId).FirstOrDefault();
|
||||
// string categoryEnum = project?.CategoryEnum ?? "";
|
||||
|
||||
// if (dto.ProjectId == 4 || dto.ProjectId == 11)
|
||||
// {
|
||||
// stu.Achievement = stu.Achievement / 10;
|
||||
// stu.Achievement2 = stu.Achievement2 / 10;
|
||||
// }
|
||||
|
||||
// if (dto.ProjectId == 21)
|
||||
// {
|
||||
// var value = stu.Achievement2;
|
||||
|
||||
// var standard = healthStandards.Where(x =>
|
||||
// x.CategoryEnum.Equals(categoryEnum) &&
|
||||
// x.GradeId == x.GradeId &&
|
||||
// x.Sex == x.Sex &&
|
||||
// value >= x.MinValue &&
|
||||
// value < x.MaxValue
|
||||
// ).FirstOrDefault();
|
||||
|
||||
// if (standard != null)
|
||||
// {
|
||||
// stu.Score = standard.Score;
|
||||
// stu.Rating = standard.Score.GetRank();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var standard = healthStandards.Where(x =>
|
||||
// x.CategoryEnum.Equals(categoryEnum) &&
|
||||
// x.GradeId == x.GradeId &&
|
||||
// x.Sex == x.Sex &&
|
||||
// stu.Achievement >= x.MinValue &&
|
||||
// stu.Achievement < x.MaxValue
|
||||
// ).FirstOrDefault();
|
||||
|
||||
// if (standard != null)
|
||||
// {
|
||||
// stu.Score = standard.Score;
|
||||
// stu.Rating = standard.Score.GetRank();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
// dto.StudentList.ForEach(x => { x.OrgId = dto.OrgId; });
|
||||
|
||||
// var entity = _mapper.Map<XW_SportsTestData>(dto);
|
||||
// await _sportsContext.XW_SportsTestData.AddAsync(entity);
|
||||
|
||||
// var sportsTestValueEntinys = await AddSportsTestValueEntity(dto, healthStandards, xwProject);
|
||||
// await _sportsContext.SportsTestValue.AddRangeAsync(sportsTestValueEntinys);
|
||||
|
||||
// await _sportsContext.SaveChangesAsync();
|
||||
|
||||
// var res = _mapper.Map<TrainDto>(entity);
|
||||
|
||||
// Console.WriteLine("新增成功");
|
||||
|
||||
// return res;
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// Console.WriteLine(e.Message + "/n" + e.InnerException);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//private async Task<List<N_SportsTestValue>> AddSportsTestValueEntity(AddTrainDto dto, List<N_HealthStandards> healthStandards, List<XW_TestingProject> xwProject)
|
||||
//{
|
||||
// var sportsTestValueEntinys = new List<N_SportsTestValue>();
|
||||
|
||||
// string schoolCode = await _sportsContext.School.Where(x => x.Id == dto.OrgId).Select(x => x.SchoolCode).FirstAsync();
|
||||
|
||||
// var nowTime = DateTime.Now;
|
||||
|
||||
// foreach (var data in dto.StudentList)
|
||||
// {
|
||||
// if (data.Achievement == 0)
|
||||
// continue;
|
||||
|
||||
// var sportsTestValueEntity = new N_SportsTestValue();
|
||||
|
||||
// var project = xwProject.Where(x => x.ProjectId == dto.ProjectId).FirstOrDefault();
|
||||
|
||||
// string categoryEnum = project?.CategoryEnum ?? "";
|
||||
|
||||
// float value = 0;
|
||||
|
||||
// if (categoryEnum == "BMI")
|
||||
// {
|
||||
// value = data.Achievement2 ?? 0 / 10;
|
||||
// sportsTestValueEntity.Height = data.Achievement ?? 0 / 10;
|
||||
// sportsTestValueEntity.Weight = data.OriginalAchievement ?? 0 / 100;
|
||||
// }
|
||||
// else
|
||||
// value = data.Achievement ?? 0;
|
||||
|
||||
// var standard = healthStandards.Where(x =>
|
||||
// x.CategoryEnum.Equals(categoryEnum) &&
|
||||
// x.GradeId == data.GradeId &&
|
||||
// x.Sex == data.Sex &&
|
||||
// value >= x.MinValue &&
|
||||
// value < x.MaxValue
|
||||
// ).FirstOrDefault();
|
||||
|
||||
// if (standard != null)
|
||||
// {
|
||||
// sportsTestValueEntity.Score = standard.Score;
|
||||
// sportsTestValueEntity.Rank = standard.Rank;
|
||||
// }
|
||||
|
||||
|
||||
// sportsTestValueEntity.SchoolCode = schoolCode;
|
||||
// sportsTestValueEntity.Sex = (int)data.Sex;
|
||||
// sportsTestValueEntity.DataSource = DataSource.XW;
|
||||
// sportsTestValueEntity.CategoryValue = project?.CategoryValue ?? 0;
|
||||
// sportsTestValueEntity.CategoryEnum = categoryEnum;
|
||||
// sportsTestValueEntity.GradeId = data.GradeId;
|
||||
// sportsTestValueEntity.GradeName = data.GradeName;
|
||||
// sportsTestValueEntity.ClassId = data.ClassId;
|
||||
// sportsTestValueEntity.ClassName = data.ClassName;
|
||||
// sportsTestValueEntity.TeacherId = data.TeacherId ?? 0;
|
||||
// sportsTestValueEntity.TeacherName = data.Teacher;
|
||||
// sportsTestValueEntity.StudentNo = data.StudentNo;
|
||||
// sportsTestValueEntity.StudentName = data.StudentName;
|
||||
// sportsTestValueEntity.Value = value;
|
||||
// sportsTestValueEntity.Creator = dto.OrgId ?? 0;
|
||||
// sportsTestValueEntity.CreateDate = nowTime;
|
||||
// sportsTestValueEntity.ScoreTime = Convert.ToDateTime(dto.StartTime);
|
||||
// sportsTestValueEntity.AdditionalScore = (float)(data.PlusesScore ?? 0);
|
||||
|
||||
// SemesterDto semesterDto = new SemesterDto();
|
||||
// sportsTestValueEntity.Year = semesterDto.Year;
|
||||
// sportsTestValueEntity.Semester = semesterDto.Semester;
|
||||
// sportsTestValueEntity.IsDisplay = true;
|
||||
|
||||
// sportsTestValueEntinys.Add(sportsTestValueEntity);
|
||||
// }
|
||||
|
||||
// return sportsTestValueEntinys;
|
||||
//}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 年级排名
|
||||
///// </summary>
|
||||
///// <param name="studentId"></param>
|
||||
///// <param name="trainId"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<GradeRankingVo> GradeRankingGet(int studentId, int trainId)
|
||||
//{
|
||||
// var res = new GradeRankingVo();
|
||||
|
||||
// var now = DateTime.UtcNow;
|
||||
// var firstDayOfMonth = new DateTime(now.Year, now.Month, 1);
|
||||
// var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
|
||||
|
||||
// var studentResults = await _sportsContext.XW_TrainStudents.Where(x => x.XW_SportsTestDataId == trainId)
|
||||
// .Select(x => new
|
||||
// {
|
||||
// x.GradeId,
|
||||
// x.StudentId,
|
||||
// x.StudentName,
|
||||
// x.Rating,
|
||||
// x.CreateTime,
|
||||
// x.Score
|
||||
// }).ToListAsync();
|
||||
|
||||
// var student = studentResults.FirstOrDefault(x => x.StudentId == studentId);
|
||||
|
||||
// if (student == null)
|
||||
// {
|
||||
// return res;
|
||||
// }
|
||||
|
||||
|
||||
// var rankedResults = studentResults
|
||||
// .Where(x => x.GradeId == student.GradeId &&
|
||||
// DateTime.TryParse(x.CreateTime, out var createTime) &&
|
||||
// createTime >= firstDayOfMonth && createTime <= lastDayOfMonth)
|
||||
// .OrderByDescending(x => x.Score)
|
||||
// .Select((x, index) => new { x.StudentId, Rank = index + 1 })
|
||||
// .ToList();
|
||||
|
||||
// var studentRank = rankedResults.FirstOrDefault(x => x.StudentId == student.StudentId)?.Rank.ToString() ?? "无数据";
|
||||
|
||||
// res.Rating = student.Score.GetRankStr();
|
||||
// res.MonthRanking = studentRank;
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 全部历史记录
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<TrainHistoryResponseDto> HistoryGet(HistoryGetDto dto)
|
||||
//{
|
||||
// var res = new TrainHistoryResponseDto();
|
||||
|
||||
// var trainList = await _sportsContext.XW_SportsTestData
|
||||
// .Where(x =>
|
||||
// x.OrgId == dto.OrgId &&
|
||||
// x.ProjectKind == Convert.ToInt32(dto.ProjectKind) &&
|
||||
// x.ModelType == dto.ModelType)
|
||||
// .ToListAsync();
|
||||
|
||||
// if (trainList == null || !trainList.Any())
|
||||
// return res;
|
||||
|
||||
// var trainIds = trainList.Select(t => t.Id).ToList();
|
||||
|
||||
// var query = _sportsContext.XW_TrainStudents
|
||||
// .Where(x => trainIds.Contains(x.XW_SportsTestDataId))
|
||||
// .AsQueryable();
|
||||
|
||||
// // 动态排序
|
||||
// if (!string.IsNullOrEmpty(dto.OrderByColumn))
|
||||
// {
|
||||
// bool isAsc = dto.IsAsc?.ToLower() == "asc";
|
||||
// query = isAsc
|
||||
// ? query.OrderBy(x => EF.Property<object>(x, dto.OrderByColumn))
|
||||
// : query.OrderByDescending(x => EF.Property<object>(x, dto.OrderByColumn));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// query = query.OrderByDescending(x => x.Id); // 默认排序
|
||||
// }
|
||||
|
||||
// var total = await query.CountAsync();
|
||||
|
||||
// var list = await query
|
||||
// .Skip((dto.PageNo - 1) * dto.PageSize)
|
||||
// .Take(dto.PageSize)
|
||||
// .Select(x => new TrainHistoryVo()
|
||||
// {
|
||||
// TrainStudentId = x.Id,
|
||||
// ClassName = x.ClassName,
|
||||
// CreateTime = x.CreateTime ?? "无数据",
|
||||
// Achievement = x.Achievement.ToString() ?? "无数据",
|
||||
// Rating = x.Score.GetRankStr(),
|
||||
// Score = x.Score.ToString() ?? "无数据",
|
||||
// Sex = x.Sex == 1 ? "男" : "女",
|
||||
// StudentName = x.StudentName,
|
||||
// TouristFlag = false,
|
||||
// DoubleFlag = false,
|
||||
// }).OrderByDescending(x => x.CreateTime)
|
||||
// .ToListAsync();
|
||||
|
||||
// res.Total = total;
|
||||
// res.Rows = list;
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 历史记录详细
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<TrainAnalusisVo> TrainAnalysisHistoryDetail(HistoryDetailRequestDto dto)
|
||||
//{
|
||||
// var trainModel = await _sportsContext.XW_TrainStudents.Where(x => x.Id == dto.TrainStudentId).Select(x => new { x.XW_SportsTestDataId, x.StudentId, x.GradeId }).FirstAsync();
|
||||
|
||||
// var stuHeadUrl = await _sportsContext.Student.Where(x => x.Id == trainModel.StudentId).Select(x => x.Photo).FirstOrDefaultAsync();
|
||||
|
||||
// var train = await _sportsContext.XW_SportsTestData.Where(x => x.Id == trainModel.XW_SportsTestDataId).Select(x => new { x.ProjectName, x.ProjectId }).FirstOrDefaultAsync();
|
||||
|
||||
// var now = DateTime.UtcNow;
|
||||
// var firstDayOfMonth = new DateTime(now.Year, now.Month, 1);
|
||||
// var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
|
||||
// var trainIds = await _sportsContext.XW_SportsTestData.Where(x => x.ProjectId == train.ProjectId).Select(x => x.Id).ToListAsync();
|
||||
|
||||
// var studentResults = await _sportsContext.XW_TrainStudents.Where(x => trainIds.Contains(x.XW_SportsTestDataId))
|
||||
// .Select(x => new
|
||||
// {
|
||||
// x.Id,
|
||||
// x.GradeId,
|
||||
// x.StudentId,
|
||||
// x.StudentName,
|
||||
// x.Rating,
|
||||
// x.CreateTime,
|
||||
// x.Score,
|
||||
// x.Achievement
|
||||
// }).ToListAsync();
|
||||
|
||||
// var student = studentResults.Where(x => x.Id == dto.TrainStudentId).OrderByDescending(x => x.Achievement).FirstOrDefault();
|
||||
|
||||
// if (student == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// var rankedResults = studentResults
|
||||
// .Where(x => x.GradeId == student.GradeId &&
|
||||
// DateTime.TryParse(x.CreateTime, out var createTime) &&
|
||||
// createTime >= firstDayOfMonth && createTime <= lastDayOfMonth)
|
||||
// .OrderByDescending(x => x.Achievement)
|
||||
// .Select((x, index) => new { x.Id, Rank = index + 1 })
|
||||
// .ToList();
|
||||
|
||||
// var studentRank = rankedResults.FirstOrDefault(x => x.Id == dto.TrainStudentId)?.Rank.ToString() ?? "无数据";
|
||||
|
||||
// var res = await _sportsContext.XW_TrainStudents.Where(x => x.Id == dto.TrainStudentId).Include(x => x.TrainViolationsBO).Select(x => new TrainAnalusisVo()
|
||||
// {
|
||||
// Achievement = x.Achievement.ToString() ?? "无数据",
|
||||
// ClassName = x.ClassName,
|
||||
// GradeRanking = studentRank,
|
||||
// HeadImgUrl = stuHeadUrl,
|
||||
// ProjectName = train.ProjectName,
|
||||
// Rating = x.Score.GetRankStr(),
|
||||
// Score = x.Score.ToString() ?? "无数据",
|
||||
// Sex = x.Sex == 1 ? "男" : "女",
|
||||
// StudentName = x.StudentName,
|
||||
// Times = x.Times.ToString(),
|
||||
// VideoRecord = x.VideoRecord,
|
||||
// ViolationsNumber = x.TrainViolationsBO.Count(),
|
||||
// TrainViolationsVo = x.TrainViolationsBO.Select(x => new TrainViolationsVo()
|
||||
// {
|
||||
// CreateTime = x.TrainTime,
|
||||
// TrainTime = x.TrainTime,
|
||||
// PicUrl = x.PicUrl,
|
||||
// ViolationId = x.ViolationId,
|
||||
// ViolationName = "",
|
||||
// }).ToList(),
|
||||
|
||||
// }).FirstOrDefaultAsync();
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-历史成绩
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<TrainHistoryPersonVo> HistoryPersonGet(HistoryPersonGetDto dto)
|
||||
//{
|
||||
// var trainList = await _sportsContext.XW_SportsTestData
|
||||
// .Where(x =>
|
||||
// x.OrgId == dto.OrgId &&
|
||||
// x.ProjectKind == Convert.ToInt32(dto.ProjectKind) &&
|
||||
// x.ModelType == dto.ModelType)
|
||||
// .ToListAsync();
|
||||
|
||||
// var trainIds = trainList.Select(t => t.Id).ToList();
|
||||
|
||||
// var studentResults = await _sportsContext.XW_TrainStudents.Where(x => trainIds.Contains(x.XW_SportsTestDataId))
|
||||
// .Select(x => new
|
||||
// {
|
||||
// x.Id,
|
||||
// x.ClassName,
|
||||
// x.StudentId,
|
||||
// x.StudentName,
|
||||
// x.GradeId,
|
||||
// x.Sex,
|
||||
// x.Score,
|
||||
// x.Achievement,
|
||||
// x.CreateTime
|
||||
// }).ToListAsync();
|
||||
|
||||
// var student = studentResults.Where(x => x.StudentId == dto.StudentId).OrderByDescending(x => x.Achievement).FirstOrDefault();
|
||||
|
||||
// if (student == null)
|
||||
// {
|
||||
// return new TrainHistoryPersonVo();
|
||||
// }
|
||||
|
||||
// var rankedResults = studentResults.Where(x => x.GradeId == student.GradeId)
|
||||
// .OrderByDescending(x => x.Achievement)
|
||||
// .Select((x, index) => new { x, Rank = index + 1 })
|
||||
// .ToList();
|
||||
|
||||
// var monthList = studentResults.Where(x => DateTime.TryParse(x.CreateTime, out var date) && date.Year == DateTime.Now.Year && date.Month == DateTime.Now.Month).ToList();
|
||||
// var monthRankedResults = studentResults.Where(x => x.GradeId == student.GradeId)
|
||||
// .OrderByDescending(x => x.Achievement)
|
||||
// .Select((x, index) => new { x, Rank = index + 1 })
|
||||
// .ToList();
|
||||
|
||||
// var stuHeadUrl = await _sportsContext.Student.Where(x => x.Id == student.StudentId).Select(x => x.Photo).FirstOrDefaultAsync();
|
||||
|
||||
// var res = new TrainHistoryPersonVo()
|
||||
// {
|
||||
// ClassName = student.ClassName,
|
||||
// HeadImgUrl = stuHeadUrl,
|
||||
// Sex = student.Sex == 1 ? "男" : "女",
|
||||
// StudentName = student.StudentName,
|
||||
// HistoryBestScore = studentResults.Max(x => x.Achievement).ToString() ?? "无数据",
|
||||
// HistoryRanking = rankedResults.FirstOrDefault(x => x.x.Achievement == student.Achievement)?.Rank.ToString() ?? "-1",
|
||||
// MonthBestScore = monthList.Max(x => x.Achievement).ToString() ?? "无数据",
|
||||
// MonthRanking = monthRankedResults.FirstOrDefault(x => x.x.Achievement == student.Achievement)?.Rank.ToString() ?? "-1"
|
||||
// };
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-记录列表
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<TableDataPersonAnalysisVo> HistoryPersonListGet(HistoryPersonListDto dto)
|
||||
//{
|
||||
// var res = new TableDataPersonAnalysisVo();
|
||||
|
||||
// var trainList = await _sportsContext.XW_SportsTestData
|
||||
// .Where(x =>
|
||||
// x.OrgId == dto.OrgId &&
|
||||
// x.ProjectKind == Convert.ToInt32(dto.ProjectKind) &&
|
||||
// x.ModelType == dto.ModelType)
|
||||
// .ToListAsync();
|
||||
|
||||
// if (trainList == null || !trainList.Any())
|
||||
// return res;
|
||||
|
||||
// var trainIds = trainList.Select(t => t.Id).ToList();
|
||||
|
||||
// var query = _sportsContext.XW_TrainStudents
|
||||
// .Where(x => trainIds.Contains(x.XW_SportsTestDataId) && x.StudentId == dto.StudentId)
|
||||
// .AsQueryable();
|
||||
|
||||
// // 动态排序
|
||||
// if (!string.IsNullOrEmpty(dto.OrderByColumn))
|
||||
// {
|
||||
// bool isAsc = dto.IsAsc?.ToLower() == "asc";
|
||||
// query = isAsc
|
||||
// ? query.OrderBy(x => EF.Property<object>(x, dto.OrderByColumn))
|
||||
// : query.OrderByDescending(x => EF.Property<object>(x, dto.OrderByColumn));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// query = query.OrderByDescending(x => x.Id); // 默认排序
|
||||
// }
|
||||
|
||||
// var total = await query.CountAsync();
|
||||
|
||||
// var list = await query
|
||||
// .Skip((dto.PageNo - 1) * dto.PageSize)
|
||||
// .Take(dto.PageSize)
|
||||
// .Select(x => new PersonAnalysisVo()
|
||||
// {
|
||||
// TrainStudentId = x.Id,
|
||||
// ClassName = x.ClassName,
|
||||
// CreateTime = x.CreateTime ?? "无数据",
|
||||
// Achievement = x.Achievement.ToString() ?? "无数据",
|
||||
// Rating = x.Score.GetRankStr(),
|
||||
// Score = x.Score.ToString() ?? "无数据",
|
||||
// Sex = x.Sex == 1 ? "男" : "女",
|
||||
// StudentName = x.StudentName,
|
||||
// DoubleFlag = false,
|
||||
// }).OrderByDescending(x => x.CreateTime)
|
||||
// .ToListAsync();
|
||||
|
||||
// res.Total = total;
|
||||
// res.Rows = list;
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 成绩榜-年级列表
|
||||
///// </summary>
|
||||
///// <param name="orgId"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<List<GradeVo>> GetGradeListByOrg(int orgId)
|
||||
//{
|
||||
// string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync();
|
||||
|
||||
// var res = await (from s in _sportsContext.SchoolAssocGrade
|
||||
// join g in _sportsContext.Grade on s.GradeId equals g.Id
|
||||
// where s.SchoolCode == schoolCode
|
||||
// select new GradeVo()
|
||||
// {
|
||||
// GradeId = g.Id,
|
||||
// GradeName = g.GradeName
|
||||
// }).ToListAsync();
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 成绩榜-年级列表
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<ScoreRankingVo> ScoreRanking(ScoreRankingDto dto)
|
||||
//{
|
||||
// var res = new ScoreRankingVo();
|
||||
|
||||
// var trainList = await _sportsContext.XW_SportsTestData
|
||||
// .Where(x =>
|
||||
// x.OrgId == dto.OrgId &&
|
||||
// x.ProjectKind == Convert.ToInt32(dto.ProjectKind) &&
|
||||
// x.ModelType == Convert.ToInt32(dto.ModelType))
|
||||
// .ToListAsync();
|
||||
|
||||
// var trainIds = trainList.Select(t => t.Id).ToList();
|
||||
|
||||
// var today = DateTime.UtcNow.Date;
|
||||
// var (startDate, endDate) = dto.Times switch
|
||||
// {
|
||||
// "1" => (today.AddDays(-(int)today.DayOfWeek + 1), today.AddDays(7 - (int)today.DayOfWeek)), // 本周(从周一到周日)
|
||||
// "2" => (new DateTime(today.Year, today.Month, 1), new DateTime(today.Year, today.Month, 1).AddMonths(1).AddDays(-1)), // 本月(从1号到最后一天)
|
||||
// "3" => (new DateTime(today.Year, 9, 1), new DateTime(today.Year, 9, 1).AddMonths(6).AddDays(-1)), // 本学期(9月1日到次年2月最后一天)
|
||||
// _ => (DateTime.MinValue, DateTime.MaxValue)
|
||||
// };
|
||||
|
||||
// // 先从数据库查询基本数据(不带时间过滤)
|
||||
// var rawResults = await _sportsContext.XW_TrainStudents
|
||||
// .Where(x => trainIds.Contains(x.XW_SportsTestDataId) && x.GradeId == dto.GradeId)
|
||||
// .Select(x => new
|
||||
// {
|
||||
// x.StudentName,
|
||||
// x.ClassName,
|
||||
// x.Achievement,
|
||||
// x.CreateTime,
|
||||
// x.Sex
|
||||
// }).OrderByDescending(x => x.Achievement)
|
||||
// .ToListAsync(); // 先加载到内存
|
||||
|
||||
// // 在内存中进行时间和性别过滤
|
||||
// var studentResults = rawResults
|
||||
// .Where(x => DateTime.TryParse(x.CreateTime, out var date) && date >= startDate && date <= endDate) // 过滤时间
|
||||
// .Where(x => dto.Sex == "1" ? x.Sex == 1 : dto.Sex == "2" ? x.Sex == 2 : true) // 过滤性别
|
||||
// .Select(x => new RankingVo()
|
||||
// {
|
||||
// Name = x.StudentName,
|
||||
// ClassName = x.ClassName,
|
||||
// Achievement = x.Achievement.ToString() ?? "无数据"
|
||||
// })
|
||||
// .ToList();
|
||||
|
||||
// res.Times = dto.Times;
|
||||
// res.Lists = studentResults;
|
||||
|
||||
// return res;
|
||||
//}
|
||||
//}
|
||||
}
|
||||
120
YD_AllHeartRates.Api/Services/Interface/IXinWeiService.cs
Normal file
120
YD_AllHeartRates.Api/Services/Interface/IXinWeiService.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Services.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务接口
|
||||
/// </summary>
|
||||
public interface IXinWeiService
|
||||
{
|
||||
///// <summary>
|
||||
///// 获取设备信息
|
||||
///// </summary>
|
||||
///// <param name="deviceSerial"></param>
|
||||
///// <returns></returns>
|
||||
//Task<DeviceInfoDto> DeviceInfo(string deviceSerial);
|
||||
|
||||
///// <summary>
|
||||
///// 项目模式
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//Task<List<ProjectModeDto>> SportsModelTypeList();
|
||||
|
||||
///// <summary>
|
||||
///// 体育项目
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <returns></returns>
|
||||
//Task<List<TestingProjectDto>> OrgSportsProjectList(int orgId);
|
||||
|
||||
///// <summary>
|
||||
///// 获取学生信息
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <returns></returns>
|
||||
//Task<List<StudentInfoDto>> MinimumOfStudentInfoList(int orgId);
|
||||
|
||||
///// <summary>
|
||||
///// 获取名单列表
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <param name="userId">用户Id</param>
|
||||
///// <returns></returns>
|
||||
//Task<List<SportsRosterDto>> SportsRosterList(int orgId, int userId = 0);
|
||||
|
||||
///// <summary>
|
||||
///// 获取人脸信息
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<FaceListOfDevicePageDto> FaceListOfDevicePage(FaceListOfDeviceDto dto);
|
||||
|
||||
///// <summary>
|
||||
///// 获取训练评分规则
|
||||
///// </summary>
|
||||
///// <param name="orgId">学校Id</param>
|
||||
///// <returns></returns>
|
||||
//Task<List<ScoreRuleDto>> ScoreRules(int orgId);
|
||||
|
||||
///// <summary>
|
||||
///// 新增训练
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<TrainDto> AddTrain(AddTrainDto dto);
|
||||
|
||||
///// <summary>
|
||||
///// 年级排名
|
||||
///// </summary>
|
||||
///// <param name="studentId"></param>
|
||||
///// <param name="trainId"></param>
|
||||
///// <returns></returns>
|
||||
//Task<GradeRankingVo> GradeRankingGet(int studentId, int trainId);
|
||||
|
||||
///// <summary>
|
||||
///// 全部历史记录
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<TrainHistoryResponseDto> HistoryGet(HistoryGetDto dto);
|
||||
|
||||
///// <summary>
|
||||
///// 历史记录详细
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<TrainAnalusisVo> TrainAnalysisHistoryDetail(HistoryDetailRequestDto dto);
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-历史成绩
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<TrainHistoryPersonVo> HistoryPersonGet(HistoryPersonGetDto dto);
|
||||
|
||||
///// <summary>
|
||||
///// 个人历史记录-记录列表
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<TableDataPersonAnalysisVo> HistoryPersonListGet(HistoryPersonListDto dto);
|
||||
|
||||
///// <summary>
|
||||
///// 成绩榜-年级列表
|
||||
///// </summary>
|
||||
///// <param name="orgId"></param>
|
||||
///// <returns></returns>
|
||||
//Task<List<GradeVo>> GetGradeListByOrg(int orgId);
|
||||
|
||||
///// <summary>
|
||||
///// 成绩榜-榜单列表
|
||||
///// </summary>
|
||||
///// <param name="dto"></param>
|
||||
///// <returns></returns>
|
||||
//Task<ScoreRankingVo> ScoreRanking(ScoreRankingDto dto);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
336
YD_AllHeartRates.Api/Startup.cs
Normal file
336
YD_AllHeartRates.Api/Startup.cs
Normal file
@ -0,0 +1,336 @@
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||
using Autofac;
|
||||
using YD_AllHeartRates.Api.Services.Impl;
|
||||
using YD_AllHeartRates.Api.AutoMappers;
|
||||
using YD_AllHeartRates.Api.Services.Interface;
|
||||
using YD_AllHeartRates.Api.Context;
|
||||
using YD_AllHeartRates.Api.Extensions;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc.Versioning;
|
||||
using YD_AllHeartRates.Api.Utilities;
|
||||
using VYD_AllHeartRates.Commons.Filters;
|
||||
using YD_AllHeartRates.Commons.Users;
|
||||
using YD_AllHeartRates.Commons.Utils;
|
||||
|
||||
namespace YD_AllHeartRates.Api
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
private IServiceCollection Services { get; set; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
Services = services;
|
||||
|
||||
AppSettings.Init(Configuration);
|
||||
|
||||
string dbConnectionString = AppSettings.DbConnectionString;
|
||||
string smartSportsString = AppSettings.SmartSportsString;
|
||||
|
||||
// 使用 dbConnectionString 配置数据库上下文
|
||||
services.AddDbContextPool<UserContext>(optionsBuilder =>
|
||||
{
|
||||
optionsBuilder.UseSqlServer(dbConnectionString);
|
||||
});
|
||||
|
||||
// 配置智慧体育后台数据库上下文
|
||||
services.AddDbContextPool<SmartSportsContext>(optionsBuilder =>
|
||||
{
|
||||
optionsBuilder.UseSqlServer(smartSportsString);
|
||||
});
|
||||
|
||||
services.AddSingleton<JwtHelper>();
|
||||
|
||||
//services.AddScoped<IXinWeiService, XinWeiService>();
|
||||
//services.AddScoped<ICaching, MemoryCaching>();
|
||||
|
||||
services.AddSession();
|
||||
services.AddMemoryCache();
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
SaveSigninToken = true,//保存token,后台验证token是否生效(重要)
|
||||
ValidateIssuer = true,//是否验证Issuer
|
||||
ValidateAudience = true,//是否验证Audience
|
||||
ValidateLifetime = true,//是否验证失效时间
|
||||
ValidateIssuerSigningKey = true,//是否验证SecurityKey
|
||||
ValidAudience = AppSettings.Secret.Audience,//Audience
|
||||
ValidIssuer = AppSettings.Secret.Issuer,//Issuer,这两项和前面签发jwt的设置一致
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(AppSettings.Secret.JWT))
|
||||
};
|
||||
options.Events = new JwtBearerEvents()
|
||||
{
|
||||
OnChallenge = context =>
|
||||
{
|
||||
context.HandleResponse();
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "application/json";
|
||||
context.Response.StatusCode = 401;
|
||||
Task task = context.Response.WriteAsync(new { message = "授权未通过", status = false, code = 401 }.Serialize());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
services.AddApiVersioning(options =>
|
||||
{
|
||||
// 默认情况下,API 版本是必需的,通过 URL 进行版本控制
|
||||
options.ApiVersionReader = new UrlSegmentApiVersionReader();
|
||||
options.ReportApiVersions = true;
|
||||
});
|
||||
|
||||
// 全局应用认证策略
|
||||
services.AddControllers(options =>
|
||||
{
|
||||
var policy = new AuthorizationPolicyBuilder()
|
||||
.RequireAuthenticatedUser()
|
||||
.Build();
|
||||
options.Filters.Add(new AuthorizeFilter(policy)); // 全局应用 [Authorize]
|
||||
}).AddNewtonsoftJson(options =>
|
||||
{
|
||||
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||
});
|
||||
|
||||
//必须appsettings.json中配置
|
||||
string corsUrls = Configuration["CorsUrls"];
|
||||
if (string.IsNullOrEmpty(corsUrls))
|
||||
{
|
||||
throw new Exception("请配置跨请求的前端Url");
|
||||
}
|
||||
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(
|
||||
builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.SetPreflightMaxAge(TimeSpan.FromSeconds(2520))
|
||||
.AllowAnyHeader().AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddControllers(options =>
|
||||
{
|
||||
options.Filters.Add<CustomApiResponseFilter>(); // 1、通用结果
|
||||
options.Filters.Add<ExceptionFilter>();// 2、通用异常
|
||||
options.ModelBinderProviders.Insert(0, new SysUserModelBinderProvider());// 3、自定义模型绑定
|
||||
options.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = true;
|
||||
}).AddNewtonsoftJson(op =>
|
||||
{
|
||||
op.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
op.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||
});
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
//分为2份接口文档
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "YD_AllHeartRates.Api", Version = "v1", Description = "心率Api" });
|
||||
|
||||
string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||
c.IncludeXmlComments(xmlPath, true);
|
||||
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "YD_AllHeartRates.xml"));
|
||||
//c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "YD_AllHeartRates.Model.xml"));
|
||||
|
||||
c.DocInclusionPredicate((docName, apiDes) =>
|
||||
{
|
||||
if (!apiDes.TryGetMethodInfo(out MethodInfo method))
|
||||
return false;
|
||||
/*使用ApiExplorerSettingsAttribute里面的GroupName进行特性标识
|
||||
* DeclaringType只能获取controller上的特性
|
||||
* 我们这里是想以action的特性为主
|
||||
* */
|
||||
var version = method.DeclaringType.GetCustomAttributes(true).OfType<ApiExplorerSettingsAttribute>().Select(m => m.GroupName);
|
||||
if (docName == "v1" && !version.Any())
|
||||
return true;
|
||||
//这里获取action的特性
|
||||
var actionVersion = method.GetCustomAttributes(true).OfType<ApiExplorerSettingsAttribute>().Select(m => m.GroupName);
|
||||
if (actionVersion.Any())
|
||||
return actionVersion.Any(v => v == docName);
|
||||
return version.Any(v => v == docName);
|
||||
});
|
||||
|
||||
var security = new Dictionary<string, IEnumerable<string>> { { AppSettings.Secret.Issuer, new string[] { } } };
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
||||
{
|
||||
Description = "JWT授权token前面需要加上字段Bearer与一个空格,如Bearer token",
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
BearerFormat = "JWT",
|
||||
Scheme = "Bearer"
|
||||
});
|
||||
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference {
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
new string[] { }
|
||||
}
|
||||
});
|
||||
})
|
||||
.AddControllers()
|
||||
.ConfigureApiBehaviorOptions(options =>
|
||||
{
|
||||
options.SuppressConsumesConstraintForFormFileParameters = true;
|
||||
options.SuppressInferBindingSourcesForParameters = true;
|
||||
options.SuppressModelStateInvalidFilter = true;
|
||||
options.SuppressMapClientErrors = true;
|
||||
options.ClientErrorMapping[404].Link =
|
||||
"https://*/404";
|
||||
});
|
||||
services.AddSignalR();
|
||||
services.AddHttpClient();
|
||||
|
||||
services.AddAutoMapper(typeof(MappingProfile));
|
||||
|
||||
services.AddLogging();
|
||||
|
||||
//设置文件上传大小限制
|
||||
//设置文件上传大小限制
|
||||
services.Configure<FormOptions>(x =>
|
||||
{
|
||||
x.MultipartBodyLengthLimit = 1024 * 1024 * 100;//100M
|
||||
});
|
||||
services.Configure<KestrelServerOptions>(options =>
|
||||
{
|
||||
options.Limits.MaxRequestBodySize = 1024 * 1024 * 100;//100M
|
||||
});
|
||||
services.Configure<IISServerOptions>(options =>
|
||||
{
|
||||
options.MaxRequestBodySize = 1024 * 1024 * 100;//100M
|
||||
});
|
||||
}
|
||||
|
||||
public void ConfigureContainer(ContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterType<UserLoginContext>().InstancePerLifetimeScope();
|
||||
}
|
||||
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// app.UseQuartz(env);
|
||||
//}
|
||||
//app.UseMiddleware<ExceptionHandlerMiddleWare>();
|
||||
app.UseStaticFiles().UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
ServeUnknownFileTypes = true
|
||||
});
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
//app.Use(HttpRequestMiddleware.Context);
|
||||
|
||||
//2021.06.27增加创建默认upload文件夹
|
||||
//string _uploadPath = (env.ContentRootPath + "/Upload").ReplacePath();
|
||||
|
||||
//if (!Directory.Exists(_uploadPath))
|
||||
//{
|
||||
// Directory.CreateDirectory(_uploadPath);
|
||||
//}
|
||||
|
||||
//app.UseStaticFiles(new StaticFileOptions()
|
||||
//{
|
||||
// FileProvider = new PhysicalFileProvider(
|
||||
// Path.Combine(Directory.GetCurrentDirectory(), @"Upload")),
|
||||
// //配置访问虚拟目录时文件夹别名
|
||||
// RequestPath = "/Upload",
|
||||
// OnPrepareResponse = (Microsoft.AspNetCore.StaticFiles.StaticFileResponseContext staticFile) =>
|
||||
// {
|
||||
// //可以在此处读取请求的信息进行权限认证
|
||||
// // staticFile.File
|
||||
// // staticFile.Context.Response.StatusCode;
|
||||
// }
|
||||
//});
|
||||
//配置HttpContext
|
||||
app.UseStaticHttpContext();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
//2个下拉框选项 选择对应的文档
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_AllHeartRates.Api");
|
||||
c.RoutePrefix = "";
|
||||
});
|
||||
app.UseRouting();
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
//配置SignalR
|
||||
//if (AppSetting.UseSignalR)
|
||||
//{
|
||||
// string corsUrls = Configuration["CorsUrls"];
|
||||
|
||||
// endpoints.MapHub<HomePageMessageHub>("/message")
|
||||
// .RequireCors(t =>
|
||||
// t.WithOrigins(corsUrls.Split(',')).
|
||||
// AllowAnyMethod().
|
||||
// AllowAnyHeader().
|
||||
// AllowCredentials());
|
||||
//}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swagger注释帮助类
|
||||
/// </summary>
|
||||
public class SwaggerDocTag : IDocumentFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加附加注释
|
||||
/// </summary>
|
||||
/// <param name="swaggerDoc"></param>
|
||||
/// <param name="context"></param>
|
||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||
{
|
||||
//添加对应的控制器描述
|
||||
swaggerDoc.Tags = new List<OpenApiTag>
|
||||
{
|
||||
new OpenApiTag { Name = "Test", Description = "这是描述" },
|
||||
//new OpenApiTag { Name = "你的控制器名字,不带Controller", Description = "控制器描述" },
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
62
YD_AllHeartRates.Api/Utilities/AppSettings.cs
Normal file
62
YD_AllHeartRates.Api/Utilities/AppSettings.cs
Normal file
@ -0,0 +1,62 @@
|
||||
namespace YD_AllHeartRates.Api.Utilities
|
||||
{
|
||||
public static class AppSettings
|
||||
{
|
||||
public static LoggingConfig Logging { get; set; }
|
||||
public static VirtualPathConfig VirtualPath { get; set; }
|
||||
public static SecretConfig Secret { get; set; }
|
||||
public static string ExpMinutes { get; set; }
|
||||
|
||||
public static string DbConnectionString { get; set; }
|
||||
public static string SmartSportsString { get; set; }
|
||||
public static string[] CorsUrls { get; set; }
|
||||
public static WeChatConfig WeChat { get; set; }
|
||||
|
||||
public static void Init(IConfiguration configuration)
|
||||
{
|
||||
Logging = configuration.GetSection("Logging").Get<LoggingConfig>();
|
||||
VirtualPath = configuration.GetSection("VirtualPath").Get<VirtualPathConfig>();
|
||||
Secret = configuration.GetSection("Secret").Get<SecretConfig>();
|
||||
ExpMinutes = configuration["ExpMinutes"];
|
||||
DbConnectionString = configuration["DbConnectionString"];
|
||||
SmartSportsString = configuration["SmartSportsString"];
|
||||
CorsUrls = configuration["CorsUrls"].Split(',');
|
||||
WeChat = configuration.GetSection("WeChat").Get<WeChatConfig>();
|
||||
}
|
||||
|
||||
public class LoggingConfig
|
||||
{
|
||||
public LogLevelConfig LogLevel { get; set; }
|
||||
}
|
||||
|
||||
public class LogLevelConfig
|
||||
{
|
||||
public string Default { get; set; }
|
||||
public string Microsoft { get; set; }
|
||||
public string MicrosoftHostingLifetime { get; set; }
|
||||
}
|
||||
|
||||
public class VirtualPathConfig
|
||||
{
|
||||
public string StaticFile { get; set; }
|
||||
public string FolderName { get; set; }
|
||||
}
|
||||
|
||||
public class SecretConfig
|
||||
{
|
||||
public string JWT { get; set; }
|
||||
public string Audience { get; set; }
|
||||
public string Issuer { get; set; }
|
||||
public string User { get; set; }
|
||||
public string DB { get; set; }
|
||||
public string Redis { get; set; }
|
||||
}
|
||||
|
||||
public class WeChatConfig
|
||||
{
|
||||
public string Appid { get; set; }
|
||||
public string Secret { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
YD_AllHeartRates.Api/Utilities/HttpContext.cs
Normal file
15
YD_AllHeartRates.Api/Utilities/HttpContext.cs
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
namespace YD_AllHeartRates.Api.Utilities
|
||||
{
|
||||
public static class HttpContext
|
||||
{
|
||||
private static IHttpContextAccessor _accessor;
|
||||
|
||||
public static Microsoft.AspNetCore.Http.HttpContext Current => _accessor.HttpContext;
|
||||
|
||||
internal static void Configure(IHttpContextAccessor accessor)
|
||||
{
|
||||
_accessor = accessor;
|
||||
}
|
||||
}
|
||||
}
|
||||
103
YD_AllHeartRates.Api/Utilities/JwtHelper.cs
Normal file
103
YD_AllHeartRates.Api/Utilities/JwtHelper.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using YD_AllHeartRates.Commons;
|
||||
using YD_AllHeartRates.Commons.Utils;
|
||||
|
||||
namespace YD_AllHeartRates.Api.Utilities
|
||||
{
|
||||
public class JwtHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成JWT
|
||||
/// </summary>
|
||||
/// <param name="serInfo"></param>
|
||||
/// <returns></returns>
|
||||
public static string IssueJwt(UserInfoDto userInfo)
|
||||
{
|
||||
string exp = $"{new DateTimeOffset(DateTime.Now.AddMinutes(Convert.ToInt32(AppSettings.ExpMinutes))).ToUnixTimeSeconds()}";
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
//new Claim(ClaimTypes.Role,userInfo.Role_Id ),
|
||||
new Claim(JwtRegisteredClaimNames.Sid,userInfo.SchoolCode.ToString() ),
|
||||
new Claim(JwtRegisteredClaimNames.Typ,userInfo.Role_Id.ToString() ),
|
||||
new Claim(JwtRegisteredClaimNames.Jti,userInfo.User_Id.ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Nickname,userInfo.UserTrueName),
|
||||
new Claim(JwtRegisteredClaimNames.Name,userInfo.UserName),
|
||||
new Claim(JwtRegisteredClaimNames.PhoneNumber,userInfo.PhoneNo),
|
||||
new Claim(JwtRegisteredClaimNames.Iat, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"),
|
||||
new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
|
||||
//JWT过期时间
|
||||
//验证是否过期 从User读取过期 时间,再将时间戳转换成日期,如果时间在半个小时内即将过期,通知前台刷新JWT
|
||||
//int val= HttpContext.User.Claims.Where(x => x.Type == JwtRegisteredClaimNames.Exp).FirstOrDefault().Value;
|
||||
//new DateTime(621355968000000000 + (long)val* (long)10000000, DateTimeKind.Utc).ToLocalTime()
|
||||
//默认设置jwt过期时间120分钟
|
||||
new Claim (JwtRegisteredClaimNames.Exp,exp),
|
||||
new Claim(JwtRegisteredClaimNames.Iss,AppSettings.Secret.Issuer),
|
||||
new Claim(JwtRegisteredClaimNames.Aud,AppSettings.Secret.Audience),
|
||||
};
|
||||
|
||||
//秘钥16位
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(AppSettings.Secret.JWT));
|
||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||
JwtSecurityToken securityToken = new JwtSecurityToken(issuer: AppSettings.Secret.Issuer, claims: claims, signingCredentials: creds);
|
||||
string jwt = new JwtSecurityTokenHandler().WriteToken(securityToken);
|
||||
return jwt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析
|
||||
/// </summary>
|
||||
/// <param name="jwtStr"></param>
|
||||
/// <returns></returns>
|
||||
public static UserInfoDto SerializeJwt(string jwtStr)
|
||||
{
|
||||
var jwtHandler = new JwtSecurityTokenHandler();
|
||||
JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(jwtStr);
|
||||
UserInfoDto userInfo = new UserInfoDto
|
||||
{
|
||||
User_Id = Convert.ToInt32(jwtToken.Id),
|
||||
Role_Id = (jwtToken.Payload[ClaimTypes.Role] ?? 0).GetInt(),
|
||||
UserName = jwtToken.Payload[ClaimTypes.Name]?.ToString()
|
||||
};
|
||||
return userInfo;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取过期时间
|
||||
/// </summary>
|
||||
/// <param name="jwtStr"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetExp(string jwtStr)
|
||||
{
|
||||
var jwtHandler = new JwtSecurityTokenHandler();
|
||||
JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(jwtStr);
|
||||
|
||||
DateTime expDate = (jwtToken.Payload[JwtRegisteredClaimNames.Exp] ?? 0).GetInt().GetTimeSpmpToDate();
|
||||
return expDate;
|
||||
}
|
||||
public static bool IsExp(string jwtStr)
|
||||
{
|
||||
return GetExp(jwtStr) < DateTime.Now;
|
||||
}
|
||||
|
||||
public static int GetUserId(string jwtStr)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (jwtStr.IsNullOrEmpty()) return 0;
|
||||
jwtStr = jwtStr.Replace("Bearer ", "");
|
||||
return new JwtSecurityTokenHandler().ReadJwtToken(jwtStr).Id.GetInt();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
80
YD_AllHeartRates.Api/Utilities/UserLoginContext.cs
Normal file
80
YD_AllHeartRates.Api/Utilities/UserLoginContext.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using YD_AllHeartRates.Commons;
|
||||
using YD_AllHeartRates.Commons.Utils;
|
||||
|
||||
|
||||
namespace YD_AllHeartRates.Api.Utilities
|
||||
{
|
||||
public class UserLoginContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 为了尽量减少redis或Memory读取,保证执行效率,将UserContext注入到DI,
|
||||
/// 每个UserContext的属性至多读取一次redis或Memory缓存从而提高查询效率
|
||||
/// </summary>
|
||||
public static UserLoginContext Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.RequestServices.GetService(typeof(UserLoginContext)) as UserLoginContext;
|
||||
}
|
||||
}
|
||||
|
||||
private static Microsoft.AspNetCore.Http.HttpContext Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return HttpContext.Current;
|
||||
}
|
||||
}
|
||||
|
||||
public int UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.User.FindFirstValue(JwtRegisteredClaimNames.Jti).GetInt();
|
||||
}
|
||||
}
|
||||
|
||||
public string SchoolCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.User.FindFirstValue(JwtRegisteredClaimNames.Sid);
|
||||
}
|
||||
}
|
||||
public int RoleId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.User.FindFirstValue(JwtRegisteredClaimNames.Typ).GetInt();
|
||||
}
|
||||
}
|
||||
public string UserTrueName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.User.FindFirstValue(JwtRegisteredClaimNames.Nickname);
|
||||
}
|
||||
}
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.User.FindFirstValue(JwtRegisteredClaimNames.Name);
|
||||
}
|
||||
}
|
||||
public string PhoneNo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.User.FindFirstValue(JwtRegisteredClaimNames.PhoneNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
165
YD_AllHeartRates.Api/WeChat/Lib/HttpService.cs
Normal file
165
YD_AllHeartRates.Api/WeChat/Lib/HttpService.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using YD_AllHeartRates.Commons.Exceptions;
|
||||
|
||||
namespace YD_AllHeartRates.Api.WeChat.Lib
|
||||
{
|
||||
/// <summary>
|
||||
/// http连接基础类,负责底层的http通信
|
||||
/// </summary>
|
||||
public class HttpService
|
||||
{
|
||||
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
|
||||
{
|
||||
//直接确认,否则打不开
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string Post(string xml, string url, bool isUseCert, int timeout)
|
||||
{
|
||||
GC.Collect();//垃圾回收,回收没有正常关闭的http连接
|
||||
|
||||
string result = "";//返回结果
|
||||
|
||||
HttpWebRequest request = null;
|
||||
HttpWebResponse response = null;
|
||||
Stream reqStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
//设置最大连接数
|
||||
ServicePointManager.DefaultConnectionLimit = 200;
|
||||
//设置https验证方式
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback =
|
||||
new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 下面设置HttpWebRequest的相关属性
|
||||
* ************************************************************/
|
||||
request = (HttpWebRequest)WebRequest.Create(url);
|
||||
//request.UserAgent = USER_AGENT;
|
||||
request.Method = "POST";
|
||||
request.Timeout = timeout * 1000;
|
||||
|
||||
//设置代理服务器
|
||||
//WebProxy proxy = new WebProxy(); //定义一个网关对象
|
||||
//proxy.Address = new Uri(WxPayConfig.PROXY_URL); //网关服务器端口:端口
|
||||
//request.Proxy = proxy;
|
||||
|
||||
//设置POST的数据类型和长度
|
||||
request.ContentType = "text/xml";
|
||||
byte[] data = Encoding.UTF8.GetBytes(xml);
|
||||
request.ContentLength = data.Length;
|
||||
|
||||
//是否使用证书
|
||||
//if (isUseCert)
|
||||
//{
|
||||
// string path = HttpContext.Current.Request.PhysicalApplicationPath;
|
||||
// X509Certificate2 cert = new X509Certificate2(path + WxPayConfig.Config.SSLCERT_PATH, WxPayConfig.Config.SSLCERT_PASSWORD);
|
||||
// request.ClientCertificates.Add(cert);
|
||||
// Log.Debug("TGJ.Bussiness", "PostXml used cert");
|
||||
//}
|
||||
|
||||
//往服务器写入数据
|
||||
reqStream = request.GetRequestStream();
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
reqStream.Close();
|
||||
|
||||
//获取服务端返回
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
//获取服务端返回数据
|
||||
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
|
||||
result = sr.ReadToEnd().Trim();
|
||||
sr.Close();
|
||||
}
|
||||
catch (ThreadAbortException e)
|
||||
{
|
||||
throw new BizException(e.Message);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
//关闭连接和流
|
||||
if (response != null)
|
||||
{
|
||||
response.Close();
|
||||
}
|
||||
if (request != null)
|
||||
{
|
||||
request.Abort();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理http GET请求,返回数据
|
||||
/// </summary>
|
||||
/// <param name="url">请求的url地址</param>
|
||||
/// <returns>http GET成功后返回的数据,失败抛WebException异常</returns>
|
||||
public static string Get(string url)
|
||||
{
|
||||
GC.Collect();
|
||||
string result = "";
|
||||
|
||||
HttpWebRequest request = null;
|
||||
HttpWebResponse response = null;
|
||||
|
||||
//请求url以获取数据
|
||||
try
|
||||
{
|
||||
//设置最大连接数
|
||||
ServicePointManager.DefaultConnectionLimit = 200;
|
||||
//设置https验证方式
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback =
|
||||
new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 下面设置HttpWebRequest的相关属性
|
||||
* ************************************************************/
|
||||
request = (HttpWebRequest)WebRequest.Create(url);
|
||||
//request.UserAgent = USER_AGENT;
|
||||
request.Method = "GET";
|
||||
|
||||
//获取服务器返回
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
//获取HTTP返回数据
|
||||
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
|
||||
result = sr.ReadToEnd().Trim();
|
||||
sr.Close();
|
||||
}
|
||||
catch (ThreadAbortException e)
|
||||
{
|
||||
throw new BizException(e.Message);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
//关闭连接和流
|
||||
if (response != null)
|
||||
{
|
||||
response.Close();
|
||||
}
|
||||
if (request != null)
|
||||
{
|
||||
request.Abort();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
YD_AllHeartRates.Api/WeChat/Lib/OpenIdAndSessionKey.cs
Normal file
19
YD_AllHeartRates.Api/WeChat/Lib/OpenIdAndSessionKey.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YD_AllHeartRates.Api.WeChat.Lib
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信小程序从服务端获取的OpenId和SessionKey信息结构
|
||||
/// </summary>
|
||||
public class OpenIdAndSessionKey
|
||||
{
|
||||
public string openid { get; set; }
|
||||
public string unionId { get; set; }
|
||||
public string session_key { get; set; }
|
||||
public string errcode { get; set; }
|
||||
public string errmsg { get; set; }
|
||||
}
|
||||
}
|
||||
21
YD_AllHeartRates.Api/WeChat/Lib/WechatLoginInfo.cs
Normal file
21
YD_AllHeartRates.Api/WeChat/Lib/WechatLoginInfo.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YD_AllHeartRates.Api.WeChat.Lib
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信小程序登录信息结构
|
||||
/// </summary>
|
||||
public class WechatLoginInfo
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string encryptedData { get; set; }
|
||||
public string iv { get; set; }
|
||||
public string rawData { get; set; }
|
||||
public string signature { get; set; }
|
||||
public string appid { get; set; }
|
||||
public string secret { get; set; }
|
||||
}
|
||||
}
|
||||
23
YD_AllHeartRates.Api/WeChat/Lib/WechatUserInfo.cs
Normal file
23
YD_AllHeartRates.Api/WeChat/Lib/WechatUserInfo.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YD_AllHeartRates.Api.WeChat.Lib
|
||||
{
|
||||
public class WechatUserInfo
|
||||
{
|
||||
public string openId { get; set; }
|
||||
public string phoneNumber { get; set; }
|
||||
public string nickName { get; set; }
|
||||
public string avatarUrl { get; set; }
|
||||
public string unionId { get; set; }
|
||||
public Watermark watermark { get; set; }
|
||||
|
||||
public class Watermark
|
||||
{
|
||||
public string appid { get; set; }
|
||||
public string timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
165
YD_AllHeartRates.Api/WeChat/WeChatAppDecrypt.cs
Normal file
165
YD_AllHeartRates.Api/WeChat/WeChatAppDecrypt.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using YD_AllHeartRates.Api.WeChat.Lib;
|
||||
|
||||
namespace YD_AllHeartRates.Api.WeChat
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信小程序登录接口
|
||||
/// </summary>
|
||||
public class WeChatAppDecrypt
|
||||
{
|
||||
//public IConfiguration Configuration { get; }
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
//public WeChatAppDecrypt(IConfiguration configuration)
|
||||
//{
|
||||
// Configuration = configuration;
|
||||
//}
|
||||
public WeChatAppDecrypt()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取OpenId和SessionKey的Json数据包
|
||||
/// </summary>
|
||||
/// <param name="code">客户端发来的code</param>
|
||||
/// <returns>Json数据包</returns>
|
||||
private string GetOpenIdAndSessionKeyString(string code, string appid, string secret)
|
||||
{
|
||||
//string temp = "https://api.weixin.qq.com/sns/jscode2session?" +
|
||||
// "appid=" + Configuration["Wechat:APPID"]
|
||||
// + "&secret=" + Configuration["Wechat:APPSECRET"]
|
||||
// + "&js_code=" + code
|
||||
// + "&grant_type=authorization_code";
|
||||
|
||||
string temp = "https://api.weixin.qq.com/sns/jscode2session?" +
|
||||
"appid=" + appid
|
||||
+ "&secret=" + secret
|
||||
+ "&js_code=" + code
|
||||
+ "&grant_type=authorization_code";
|
||||
|
||||
return HttpService.Get(temp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化包含OpenId和SessionKey的Json数据包
|
||||
/// </summary>
|
||||
/// <param name="loginInfo">Json数据包</param>
|
||||
/// <returns>包含OpenId和SessionKey的类</returns>
|
||||
public OpenIdAndSessionKey DecodeOpenIdAndSessionKey(WechatLoginInfo loginInfo)
|
||||
{
|
||||
var res = GetOpenIdAndSessionKeyString(loginInfo.code, loginInfo.appid, loginInfo.secret);
|
||||
OpenIdAndSessionKey oiask = JsonConvert.DeserializeObject<OpenIdAndSessionKey>(res);
|
||||
if (!string.IsNullOrEmpty(oiask.errcode))
|
||||
return null;
|
||||
return oiask;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据微信小程序平台提供的解密算法解密数据,推荐直接使用此方法
|
||||
/// </summary>
|
||||
/// <param name="loginInfo">登陆信息</param>
|
||||
/// <returns>用户信息</returns>
|
||||
public WechatUserInfo Decrypt(WechatLoginInfo loginInfo)
|
||||
{
|
||||
WechatUserInfo userInfo;
|
||||
if (loginInfo == null)
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrEmpty(loginInfo.code))
|
||||
return null;
|
||||
|
||||
OpenIdAndSessionKey oiask = DecodeOpenIdAndSessionKey(loginInfo);
|
||||
|
||||
if (oiask == null)
|
||||
return null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(oiask.openid) && !string.IsNullOrWhiteSpace(loginInfo.rawData))
|
||||
{
|
||||
userInfo = JsonConvert.DeserializeObject<WechatUserInfo>(loginInfo.rawData);
|
||||
userInfo.openId = oiask.openid;
|
||||
userInfo.unionId = oiask.unionId;
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
//if (!VaildateUserInfo(loginInfo, oiask))
|
||||
// return null;
|
||||
|
||||
userInfo = Decrypt(loginInfo.encryptedData, loginInfo.iv, oiask.session_key);
|
||||
userInfo.openId = oiask.openid;
|
||||
return userInfo;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据微信小程序平台提供的解密算法解密数据
|
||||
/// </summary>
|
||||
/// <param name="encryptedData">加密数据</param>
|
||||
/// <param name="iv">初始向量</param>
|
||||
/// <param name="sessionKey">从服务端获取的SessionKey</param>
|
||||
/// <returns></returns>
|
||||
public WechatUserInfo Decrypt(string encryptedData, string iv, string sessionKey)
|
||||
{
|
||||
WechatUserInfo userInfo;
|
||||
//创建解密器生成工具实例
|
||||
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
|
||||
//设置解密器参数
|
||||
aes.Mode = CipherMode.CBC;
|
||||
aes.BlockSize = 128;
|
||||
aes.Padding = PaddingMode.PKCS7;
|
||||
//格式化待处理字符串
|
||||
byte[] byte_encryptedData = Convert.FromBase64String(encryptedData);
|
||||
byte[] byte_iv = Convert.FromBase64String(iv);
|
||||
byte[] byte_sessionKey = Convert.FromBase64String(sessionKey);
|
||||
|
||||
aes.IV = byte_iv;
|
||||
aes.Key = byte_sessionKey;
|
||||
//根据设置好的数据生成解密器实例
|
||||
ICryptoTransform transform = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
byte[] xBuff = null;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, transform, CryptoStreamMode.Write))
|
||||
{
|
||||
// cs.Read(decryptBytes, 0, decryptBytes.Length);
|
||||
// cs.Close();
|
||||
// ms.Close();
|
||||
|
||||
byte[] xXml = Convert.FromBase64String(encryptedData);
|
||||
byte[] msg = new byte[xXml.Length + 32 - xXml.Length % 32];
|
||||
Array.Copy(xXml, msg, xXml.Length);
|
||||
cs.Write(xXml, 0, xXml.Length);
|
||||
}
|
||||
xBuff = decode2(ms.ToArray());
|
||||
}
|
||||
|
||||
//解密
|
||||
//byte[] final = transform.TransformFinalBlock(byte_encryptedData, 0, byte_encryptedData.Length);
|
||||
|
||||
//生成结果
|
||||
string result = Encoding.UTF8.GetString(xBuff);
|
||||
|
||||
//反序列化结果,生成用户信息实例
|
||||
userInfo = JsonConvert.DeserializeObject<WechatUserInfo>(result);
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
private static byte[] decode2(byte[] decrypted)
|
||||
{
|
||||
int pad = decrypted[decrypted.Length - 1];
|
||||
if (pad < 1 || pad > 32)
|
||||
{
|
||||
pad = 0;
|
||||
}
|
||||
byte[] res = new byte[decrypted.Length - pad];
|
||||
Array.Copy(decrypted, 0, res, 0, decrypted.Length - pad);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
67
YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj
Normal file
67
YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj
Normal file
@ -0,0 +1,67 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<BaseOutputPath></BaseOutputPath>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>obj\Debug\net6.0\YD_AllHeartRates.Api.xml</DocumentationFile>
|
||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="bin\**" />
|
||||
<Compile Remove="Core\**" />
|
||||
<Compile Remove="FakesAssemblies\**" />
|
||||
<Compile Remove="Upload\**" />
|
||||
<Content Remove="bin\**" />
|
||||
<Content Remove="Core\**" />
|
||||
<Content Remove="FakesAssemblies\**" />
|
||||
<Content Remove="Upload\**" />
|
||||
<EmbeddedResource Remove="bin\**" />
|
||||
<EmbeddedResource Remove="Core\**" />
|
||||
<EmbeddedResource Remove="FakesAssemblies\**" />
|
||||
<EmbeddedResource Remove="Upload\**" />
|
||||
<None Remove="bin\**" />
|
||||
<None Remove="Core\**" />
|
||||
<None Remove="FakesAssemblies\**" />
|
||||
<None Remove="Upload\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
|
||||
<PackageReference Include="AutoMapper.Collection" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.QualityTools.Testing.Fakes" Version="17.5.0-beta.23060.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="SmartSportsEntitys\" />
|
||||
<Folder Include="wwwroot\Upload\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\YD_AllHeartRates.Commons\YD_AllHeartRates.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalDesignTimeBuildInput Remove="FakesAssemblies\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
12
YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj.user
Normal file
12
YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj.user
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>SimCalibration</ActiveDebugProfile>
|
||||
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
||||
<NameOfLastUsedPublishProfile>C:\Users\tangl\Desktop\Code\YD_XinWei\Server\YD_XinWei\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
31
YD_AllHeartRates.Api/YD_AllHeartRates.sln
Normal file
31
YD_AllHeartRates.Api/YD_AllHeartRates.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34031.279
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YD_AllHeartRates.Api", "YD_AllHeartRates.Api.csproj", "{9AFB29DD-781B-44B2-A88C-562A0FFDAAC3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YD_AllHeartRates.Commons", "..\YD_AllHeartRates.Commons\YD_AllHeartRates.Commons.csproj", "{6119B091-8EC9-96B5-0240-9562C41CB9FA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9AFB29DD-781B-44B2-A88C-562A0FFDAAC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9AFB29DD-781B-44B2-A88C-562A0FFDAAC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9AFB29DD-781B-44B2-A88C-562A0FFDAAC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9AFB29DD-781B-44B2-A88C-562A0FFDAAC3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6119B091-8EC9-96B5-0240-9562C41CB9FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6119B091-8EC9-96B5-0240-9562C41CB9FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6119B091-8EC9-96B5-0240-9562C41CB9FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6119B091-8EC9-96B5-0240-9562C41CB9FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1C922CAB-751A-4412-ACE0-3F1C8EEDFD70}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
YD_AllHeartRates.Api/appsettings.Development.json
Normal file
8
YD_AllHeartRates.Api/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
40
YD_AllHeartRates.Api/appsettings.json
Normal file
40
YD_AllHeartRates.Api/appsettings.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"VirtualPath": {
|
||||
"StaticFile": "E:\\Web\\Static", //配置的虚拟目录文件所在路径
|
||||
"FolderName": "/Static" //访问时此路径时的别名
|
||||
},
|
||||
|
||||
"Secret": { //秘钥配置
|
||||
"JWT": "BB3647441FFA4B5DB4E64A29B53CE525", //JWT
|
||||
"Audience": "YD_AllHeartRates",
|
||||
"Issuer": "YD_AllHeartRates.Api",
|
||||
"User": "C5ABA9E202D94C43A3CA66002BF77FAF", //
|
||||
"DB": "3F8B7B38AD3D484A89ACA513CBD79F36",
|
||||
"Redis": "E6D90DDBC70C4F4EA3C312B6FCB473C8"
|
||||
},
|
||||
|
||||
"ExpMinutes": "120", //JWT有效期(分钟=默认120),
|
||||
|
||||
"AppUrls": {
|
||||
},
|
||||
|
||||
//"DbConnectionString": " Data Source=101.132.164.149;Database=YD_AllHeartRatesDB;User ID=sa;Password=Admin@123;Connect Timeout=500;",
|
||||
//"SmartSportsString": " Data Source=101.132.164.149;Database=SmartSportsServerDB_QA;User ID=sa;Password=Admin@123;Connect Timeout=500;",
|
||||
|
||||
"DbConnectionString": " Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=SmartSportsServerDB_QA;User ID=qa;Password=Admin@123;Connect Timeout=500;",
|
||||
"SmartSportsString": " Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=SmartSportsServerDB_QA;User ID=qa;Password=Admin@123;Connect Timeout=500;",
|
||||
"CorsUrls": "http://localhost:8081,http://localhost:8080,http://localhost:7080,http://localhost:9980,http://127.0.0.1:9994,http://localhost:9994",
|
||||
|
||||
"WeChat": {
|
||||
"Appid": "xxx",
|
||||
"Secret": "xxx"
|
||||
}
|
||||
}
|
||||
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Aliyun.OSS.Core.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Aliyun.OSS.Core.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/AutoMapper.Collection.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/AutoMapper.Collection.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/AutoMapper.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/AutoMapper.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Autofac.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Autofac.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Humanizer.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Humanizer.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Microsoft.OpenApi.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Microsoft.OpenApi.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Newtonsoft.Json.Bson.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Newtonsoft.Json.Bson.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Newtonsoft.Json.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/Newtonsoft.Json.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/System.Drawing.Common.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/System.Drawing.Common.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/System.Runtime.Caching.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/System.Runtime.Caching.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1261
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.deps.json
Normal file
1261
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.exe
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.exe
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.pdb
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.pdb
Normal file
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.AspNetCore.App",
|
||||
"version": "6.0.0"
|
||||
}
|
||||
],
|
||||
"configProperties": {
|
||||
"System.GC.Server": true,
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"ManifestType": "Build",
|
||||
"Endpoints": []
|
||||
}
|
||||
270
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.xml
Normal file
270
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.Api.xml
Normal file
@ -0,0 +1,270 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>YD_AllHeartRates.Api</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:YD_AllHeartRates.Api.Context.SmartSportsContext">
|
||||
<summary>
|
||||
用户服务上下文
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.Context.UserContext">
|
||||
<summary>
|
||||
用户服务上下文
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.Controllers.XinWeiController">
|
||||
<summary>
|
||||
芯未
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.Entitys.EntityBase">
|
||||
<summary>
|
||||
数据库实体父类
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.EntityBase.Remarks">
|
||||
<summary>
|
||||
备注
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.EntityBase.Creator">
|
||||
<summary>
|
||||
创建人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.EntityBase.CreateDate">
|
||||
<summary>
|
||||
创建时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.EntityBase.Modifier">
|
||||
<summary>
|
||||
修改人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.EntityBase.ModifyDate">
|
||||
<summary>
|
||||
修改时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.TestTable.Name">
|
||||
<summary>
|
||||
Name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.TestTable.Json">
|
||||
<summary>
|
||||
Json
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.SchoolCode">
|
||||
<summary>
|
||||
学校编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.UserName">
|
||||
<summary>
|
||||
帐号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Gender">
|
||||
<summary>
|
||||
性别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.HeadImageUrl">
|
||||
<summary>
|
||||
头像
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Role_Id">
|
||||
<summary>
|
||||
角色
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.RoleName">
|
||||
<summary>
|
||||
角色
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.UserTrueName">
|
||||
<summary>
|
||||
姓名
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.UserPwd">
|
||||
<summary>
|
||||
密码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.PhoneNo">
|
||||
<summary>
|
||||
手机号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Enable">
|
||||
<summary>
|
||||
是否可用
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.wx_OpenID">
|
||||
<summary>
|
||||
微信OpenId
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.wx_UnionID">
|
||||
<summary>
|
||||
微信UnionId
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.wx_HeadImgUrl">
|
||||
<summary>
|
||||
微信头像
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.wx_NickName">
|
||||
<summary>
|
||||
微信昵称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Address">
|
||||
<summary>
|
||||
地址
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Email">
|
||||
<summary>
|
||||
Email
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.RelevanceId">
|
||||
<summary>
|
||||
账号关联Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.BirthDate">
|
||||
<summary>
|
||||
出生日期
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Height">
|
||||
<summary>
|
||||
身高
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Entitys.User.Weight">
|
||||
<summary>
|
||||
体重
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.Services.Interface.IXinWeiService">
|
||||
<summary>
|
||||
服务接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.SwaggerDocTag">
|
||||
<summary>
|
||||
Swagger注释帮助类
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.SwaggerDocTag.Apply(Microsoft.OpenApi.Models.OpenApiDocument,Swashbuckle.AspNetCore.SwaggerGen.DocumentFilterContext)">
|
||||
<summary>
|
||||
添加附加注释
|
||||
</summary>
|
||||
<param name="swaggerDoc"></param>
|
||||
<param name="context"></param>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.Utilities.JwtHelper.IssueJwt(YD_AllHeartRates.Commons.UserInfoDto)">
|
||||
<summary>
|
||||
生成JWT
|
||||
</summary>
|
||||
<param name="serInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.Utilities.JwtHelper.SerializeJwt(System.String)">
|
||||
<summary>
|
||||
解析
|
||||
</summary>
|
||||
<param name="jwtStr"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.Utilities.JwtHelper.GetExp(System.String)">
|
||||
<summary>
|
||||
获取过期时间
|
||||
</summary>
|
||||
<param name="jwtStr"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:YD_AllHeartRates.Api.Utilities.UserLoginContext.Current">
|
||||
<summary>
|
||||
为了尽量减少redis或Memory读取,保证执行效率,将UserContext注入到DI,
|
||||
每个UserContext的属性至多读取一次redis或Memory缓存从而提高查询效率
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.WeChat.Lib.HttpService">
|
||||
<summary>
|
||||
http连接基础类,负责底层的http通信
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.WeChat.Lib.HttpService.Get(System.String)">
|
||||
<summary>
|
||||
处理http GET请求,返回数据
|
||||
</summary>
|
||||
<param name="url">请求的url地址</param>
|
||||
<returns>http GET成功后返回的数据,失败抛WebException异常</returns>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.WeChat.Lib.OpenIdAndSessionKey">
|
||||
<summary>
|
||||
微信小程序从服务端获取的OpenId和SessionKey信息结构
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.WeChat.Lib.WechatLoginInfo">
|
||||
<summary>
|
||||
微信小程序登录信息结构
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_AllHeartRates.Api.WeChat.WeChatAppDecrypt">
|
||||
<summary>
|
||||
微信小程序登录接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.WeChat.WeChatAppDecrypt.#ctor">
|
||||
<summary>
|
||||
构造函数
|
||||
</summary>
|
||||
<param name="configuration"></param>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.WeChat.WeChatAppDecrypt.GetOpenIdAndSessionKeyString(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
获取OpenId和SessionKey的Json数据包
|
||||
</summary>
|
||||
<param name="code">客户端发来的code</param>
|
||||
<returns>Json数据包</returns>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.WeChat.WeChatAppDecrypt.DecodeOpenIdAndSessionKey(YD_AllHeartRates.Api.WeChat.Lib.WechatLoginInfo)">
|
||||
<summary>
|
||||
反序列化包含OpenId和SessionKey的Json数据包
|
||||
</summary>
|
||||
<param name="loginInfo">Json数据包</param>
|
||||
<returns>包含OpenId和SessionKey的类</returns>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.WeChat.WeChatAppDecrypt.Decrypt(YD_AllHeartRates.Api.WeChat.Lib.WechatLoginInfo)">
|
||||
<summary>
|
||||
根据微信小程序平台提供的解密算法解密数据,推荐直接使用此方法
|
||||
</summary>
|
||||
<param name="loginInfo">登陆信息</param>
|
||||
<returns>用户信息</returns>
|
||||
</member>
|
||||
<member name="M:YD_AllHeartRates.Api.WeChat.WeChatAppDecrypt.Decrypt(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
根据微信小程序平台提供的解密算法解密数据
|
||||
</summary>
|
||||
<param name="encryptedData">加密数据</param>
|
||||
<param name="iv">初始向量</param>
|
||||
<param name="sessionKey">从服务端获取的SessionKey</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
40
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.xml
Normal file
40
YD_AllHeartRates.Api/bin/Debug/net6.0/YD_AllHeartRates.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>SimCalibration</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:SimCalibration.Context.UserContext">
|
||||
<summary>
|
||||
用户服务上下文
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimCalibration.Context.UserContext.TestTable">
|
||||
<summary>
|
||||
TestTable
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimCalibration.Entitys.TestTable.Name">
|
||||
<summary>
|
||||
Name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimCalibration.Entitys.TestTable.Json">
|
||||
<summary>
|
||||
Json
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:SimCalibration.SwaggerDocTag">
|
||||
<summary>
|
||||
Swagger注释帮助类
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimCalibration.SwaggerDocTag.Apply(Microsoft.OpenApi.Models.OpenApiDocument,Swashbuckle.AspNetCore.SwaggerGen.DocumentFilterContext)">
|
||||
<summary>
|
||||
添加附加注释
|
||||
</summary>
|
||||
<param name="swaggerDoc"></param>
|
||||
<param name="context"></param>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
40
YD_AllHeartRates.Api/bin/Debug/net6.0/appsettings.json
Normal file
40
YD_AllHeartRates.Api/bin/Debug/net6.0/appsettings.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"VirtualPath": {
|
||||
"StaticFile": "E:\\Web\\Static", //配置的虚拟目录文件所在路径
|
||||
"FolderName": "/Static" //访问时此路径时的别名
|
||||
},
|
||||
|
||||
"Secret": { //秘钥配置
|
||||
"JWT": "BB3647441FFA4B5DB4E64A29B53CE525", //JWT
|
||||
"Audience": "YD_AllHeartRates",
|
||||
"Issuer": "YD_AllHeartRates.Api",
|
||||
"User": "C5ABA9E202D94C43A3CA66002BF77FAF", //
|
||||
"DB": "3F8B7B38AD3D484A89ACA513CBD79F36",
|
||||
"Redis": "E6D90DDBC70C4F4EA3C312B6FCB473C8"
|
||||
},
|
||||
|
||||
"ExpMinutes": "120", //JWT有效期(分钟=默认120),
|
||||
|
||||
"AppUrls": {
|
||||
},
|
||||
|
||||
//"DbConnectionString": " Data Source=101.132.164.149;Database=YD_AllHeartRatesDB;User ID=sa;Password=Admin@123;Connect Timeout=500;",
|
||||
//"SmartSportsString": " Data Source=101.132.164.149;Database=SmartSportsServerDB_QA;User ID=sa;Password=Admin@123;Connect Timeout=500;",
|
||||
|
||||
"DbConnectionString": " Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=SmartSportsServerDB_QA;User ID=qa;Password=Admin@123;Connect Timeout=500;",
|
||||
"SmartSportsString": " Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=SmartSportsServerDB_QA;User ID=qa;Password=Admin@123;Connect Timeout=500;",
|
||||
"CorsUrls": "http://localhost:8081,http://localhost:8080,http://localhost:7080,http://localhost:9980,http://127.0.0.1:9994,http://localhost:9994",
|
||||
|
||||
"WeChat": {
|
||||
"Appid": "xxx",
|
||||
"Secret": "xxx"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1028.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1028.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1031.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1031.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1033.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1033.dll
Normal file
Binary file not shown.
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1036.dll
Normal file
BIN
YD_AllHeartRates.Api/bin/Debug/net6.0/install.res.1036.dll
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user