123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using System;
- using System.IO;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Azure.WebJobs;
- using Microsoft.Azure.WebJobs.Extensions.Http;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using TEAMModelOS.SDK.DI;
- using Azure.Cosmos;
- using System.Text.Json;
- using System.Collections.Generic;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.Models.Cosmos;
- using TEAMModelOS.SDK.Models.Cosmos.Common;
- using System.Linq;
- using TEAMModelOS.Services.Common;
- using TEAMModelOS.SDK.Models.Service;
- using HTEXLib.COMM.Helpers;
- namespace TEAMModelFunction
- {
- public class ScsApisHttpTrigger
- {
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly DingDing _dingDing;
- private readonly AzureStorageFactory _azureStorage;
- private readonly AzureRedisFactory _azureRedis;
- private readonly ThirdApisService _thirdApisService;
- public static string Code { get; set; }
- public static Dictionary<string, object> parameterMap = null;
- public ScsApisHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, ThirdApisService thirdApisService
- , AzureRedisFactory azureRedis)
- {
- _azureCosmos = azureCosmos;
- _dingDing = dingDing;
- _azureStorage = azureStorage;
- _azureRedis = azureRedis;
- _thirdApisService = thirdApisService;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="req"></param>
- /// <param name="log"></param>
- /// <returns></returns>
- [FunctionName("GetDiagnosisListByProject_V2")]
- public async Task<IActionResult> GetDiagnosisListByProject_V2([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log) {
- List<string> abilityNos = null;
- string data = await new StreamReader(req.Body).ReadToEndAsync();
- JsonElement accessConfig= data.ToObject<JsonElement>().GetProperty("accessConfig");
- JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
- ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
- Code = "GetDiagnosisListByProject_V2";
- parameterMap = new Dictionary<string, object>();
- parameterMap.Add("TrainComID", config.trainComID);
- //parameterMap.Add("ProjectID", "22");
- //parameterMap.Add("ProjectItemID", "22");
- parameterMap.Add("PXID", pxid);
- ScsResult result = new ScsResult { code = Code, title = "5.3.1.3通过项目编号获取学员测评能力项V2" };
- try
- {
- result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
- if (result.result)
- {
- List<ScDiagnosis> diagnoses = result.content.ToObject<List<ScDiagnosis>>();
- if (diagnoses != null)
- {
- abilityNos = diagnoses.Select(x => x.DiagnosisDicNum).ToList();
- }
- }
- return new OkObjectResult(new { data= abilityNos .ToJsonString()});
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
- return new OkObjectResult(abilityNos);
- }
- }
- /// <summary>
- /// 5.3.1.11获取跳转学员信息,用于sso单点,后端验证。
- /// </summary>
- /// <param name="req"></param>
- /// <param name="log"></param>
- /// <returns></returns>
- [FunctionName("GetSingleTeacherByProject")]
- public async Task<IActionResult> GetSingleTeacherByProject([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log)
- {
- string teacher=null;
- string data = await new StreamReader(req.Body).ReadToEndAsync();
- JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
- JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
- JsonElement tid = data.ToObject<JsonElement>().GetProperty("tid");
- ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
- Code = "GetSingleTeacherByProject";
- parameterMap = new Dictionary<string, object>();
- parameterMap.Add("TrainComID", config.trainComID);
- parameterMap.Add("Pxid", $"{pxid}");
- parameterMap.Add("Tid", $"{tid}");
- ScsResult result = new ScsResult { code = Code, title = "5.3.1.11获取跳转学员信息,用于sso单点,后端验证。" };
- try
- {
- ///{“result”:true,”reason”:null,”content”:”{“PXID”:””,”TID”:””,”TeacherName”:””,”ProjectTitle”:””,”ProjectItemTitle”:””,”CityName”:””,
- ///”DisName”:””,”SchoolName”:””,”Sex”:””,”PXXK”:””,”PXXD”:””,”TeacherXK”:””,”TeacherXD”:””,”Email”:””}”,”pagecount”:1}
- result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
- if (result.result)
- {
- teacher = result.content;
- }
- return new OkObjectResult(new {data= teacher });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
- return new OkObjectResult(teacher);
- }
- }
- }
- }
|