123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using TEAMModelOS.Models;
- using TEAMModelOS.SDK.DI;
- using System.Text.Json;
- using TEAMModelOS.SDK.Models;
- using Microsoft.AspNetCore.Http;
- using TEAMModelOS.SDK.Extension;
- using Azure.Cosmos;
- using System.Text;
- using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
- using Microsoft.Extensions.Options;
- using Azure.Messaging.ServiceBus;
- using Microsoft.Extensions.Configuration;
- using HTEXLib.COMM.Helpers;
- using TEAMModelOS.SDK;
- using System.IdentityModel.Tokens.Jwt;
- using TEAMModelOS.Services;
- using TEAMModelOS.SDK.Models.Service;
- using System.IO;
- using System.Dynamic;
- using Microsoft.AspNetCore.Authorization;
- using Azure.Storage.Blobs.Models;
- using static TEAMModelOS.SDK.Models.Teacher;
- using System.Web;
- using static TEAMModelOS.Controllers.FixDataController;
- using static TEAMModelOS.SDK.SchoolService;
- using Microsoft.AspNetCore.Hosting;
- using TEAMModelOS.Filter;
- using TEAMModelOS.Controllers.Third.Xkw;
- using Microsoft.Extensions.Primitives;
- using System.Net.Http;
- using TEAMModelOS.Controllers.Third.Xkw.Sdk;
- using TEAMModelOS.SDK.Models.Table;
- namespace TEAMModelOS.Controllers.Third.Xkw
- {
- // <summary>
- /// 标准OAuth2
- /// </summary>
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- //
- //[Route("")]
- [Route("xkw")]
- [ApiController]
- public class XkwServiceController: ControllerBase
- {
- private readonly SnowflakeId _snowflakeId;
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private readonly AzureStorageFactory _azureStorage;
- private readonly AzureServiceBusFactory _serviceBus;
- private readonly AzureRedisFactory _azureRedis;
- private readonly CoreAPIHttpService _coreAPIHttpService;
- private readonly ThirdApisService _scsApisService;
- private readonly HttpTrigger _httpTrigger;
- private readonly IWebHostEnvironment _environment;
- private readonly XkwAPIHttpService _xkwAPIHttpService;
- public IConfiguration _configuration { get; set; }
- public XkwServiceController(XkwAPIHttpService xkwAPIHttpService, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
- AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ThirdApisService scsApisService, HttpTrigger httpTrigger)
- {
- _azureCosmos = azureCosmos;
- _snowflakeId = snowflakeId;
- _dingDing = dingDing;
- _option = option?.Value;
- _azureStorage = azureStorage;
- _serviceBus = serviceBus;
- _configuration = configuration;
- _azureRedis = azureRedis;
- _coreAPIHttpService = coreAPIHttpService;
- _scsApisService = scsApisService;
- _httpTrigger = httpTrigger;
- _environment = environment;
- _xkwAPIHttpService=xkwAPIHttpService;
- }
- [HttpGet("paper-notice")]
- //[Authorize(Roles = "IES")]
- //[AuthToken(Roles = "teacher,admin,area,student")]
- public async Task<IActionResult> PaperNotice([FromQuery] OAuthCode authCode)
- {
- //var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
- //string tbScHourSql = $"PartitionKey eq 'HourLogin-ylgxxx' and RowKey le '2022052006'";
- //string tbScDaySql = $"PartitionKey eq 'DayLogin-ylgxxx' and RowKey le '20211128'";
- //await table.DeleteStringWhere<HourLogin>(rowKey: tbScHourSql); //删除学校168小时前的数据
- //await table.DeleteStringWhere<DayLogin>(rowKey: tbScDaySql); //删除学校180天前的数据
- var courses = _xkwAPIHttpService.Get<JsonElement>("/xopqbm/courses/all", null);
- //await _dingDing.SendBotMsg($"学科网推送消息:{authCode.ToJsonString()}", GroupNames.成都开发測試群組);
- List<XkwQuestionType> questionTypes = new List<XkwQuestionType>();
- XkwConstant.xkwCourses.ForEach(x =>
- {
- Dictionary<string, string> dict = new Dictionary<string, string>() { { "course_id",$"{x.id}" } };
- var question_types = _xkwAPIHttpService.Get<JsonElement>($"/xopqbm/question-types", dict);
- if (question_types.TryGetProperty("code", out JsonElement code) && $"{code}".Equals("2000000"))
- {
- questionTypes.AddRange(question_types.GetProperty("data").ToObject<List<XkwQuestionType>>());
- }
- });
- return Ok(questionTypes);
- }
- }
- }
|