using Admin.NET.Core;
using Flurl.Http;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.NET.Application.Service
{
///
/// 学生报告服务
///
[ApiDescriptionSettings("测评服务", Name = "BusStudentsReportsService", Order = 100)]
public class BusStudentsReportsService : IDynamicApiController, ITransient
{
private readonly IConfiguration _configuration;
private readonly SqlSugarRepository _busFramilyMapStudentsRep;
private readonly SqlSugarRepository _busStudentsRep;
private readonly static string SeKey = "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a8e70006ae6b35eb3962ad057f41a1690";
///
///
///
public BusStudentsReportsService(IConfiguration configuration, SqlSugarRepository framilyMapStudentsRep, SqlSugarRepository busStudentsRep)
{
_configuration = configuration;
_busFramilyMapStudentsRep = framilyMapStudentsRep;
_busStudentsRep = busStudentsRep;
}
///
/// 获取报告列表
///
///
///
[HttpGet("list")]
public async Task> List([FromQuery] BusStudentsReportsInputDto input)
{
var res = new List();
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetMobileResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == input.UuId);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == input.StudentId);
if (framilysingle == null)
{
return new List()
{
};
}
string guid = input.StudentId.ToString().ToUpper();
var flurlresponse = await ulrs.PostJsonAsync(new MobileStudentsReportsRequestDto { Key = SeKey, Type = input.Type, StudentId = guid });
var response = await flurlresponse.GetJsonAsync>();
return response;
}
///
/// 获取生涯报告
///
///
///
[HttpGet("GetCarrerReport")]
public async Task GetCarrerReport([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetCarrerResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new BusCarrerReports()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flurlResponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId, CycName = inputDto.CycName });
var response = await flurlResponse.GetJsonAsync();
return response;
}
///
/// 专业定位报告
///
///
///
[HttpGet("GetMajorPostionResult")]
public async Task GetMajorPostionResult([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetMajorPostionResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new HollandReportDTO()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flUrlResponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId });
var response = await flUrlResponse.GetJsonAsync();
return response;
}
///
/// 学生发展报告
///
///
///
[HttpGet("GetStudentDevelopMentResult")]
public async Task GetStudentDevelopMentResult([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetStudentDevelopMentResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new DevelopMentReportDto()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flUrlresponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId, CycName = inputDto.CycName });
var response = await flUrlresponse.GetJsonAsync();
return response;
}
///
/// 心理健康报告
///
///
///
[HttpGet("GetMentalHealthResult")]
public async Task GetMentalHealthResult([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetMentalHealthResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new DevelopMentReportDto()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flurResponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId, CycName = inputDto.CycName });
var response = await flurResponse.GetJsonAsync();
return response;
}
}
}