|
@@ -33,6 +33,10 @@ using TEAMModelOS.SDK.Models.Service;
|
|
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
using TEAMModelOS.Services;
|
|
|
using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
|
|
|
+using Azure.Storage.Sas;
|
|
|
+using DocumentFormat.OpenXml.Bibliography;
|
|
|
+using System.Runtime.Intrinsics.X86;
|
|
|
+using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -543,6 +547,10 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
string sql = $"select value c from c where c.owner='{_areaId}' {yearSql} ";
|
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
|
|
|
+ result.list.ForEach(z => {
|
|
|
+ var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
+ z.sas=blob_sas;
|
|
|
+ });
|
|
|
return Ok(new { activities = result.list.OrderByDescending(z => z.stime) });
|
|
|
}
|
|
|
//校级活动列表
|
|
@@ -628,6 +636,10 @@ namespace TEAMModelOS.Controllers
|
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
activities.AddRange(resultSchool.list);
|
|
|
}
|
|
|
+ activities.ForEach(z => {
|
|
|
+ var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
+ z.sas=blob_sas;
|
|
|
+ });
|
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
|
}
|
|
|
break;
|
|
@@ -670,7 +682,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(schoolIdIn))
|
|
|
{ //部分学校
|
|
|
- string sqlSchool = $"select value c from c join i in c.confirmedSchools where c.scope='public' and c.joinMode='enroll' and (c.publish=1 or c.publish=2 ) and s.status=1 {yearSql} {schoolIdIn} ";
|
|
|
+ string sqlSchool = $"select value c from c join i in c.confirmedSchools where c.scope='public' and c.joinMode='enroll' and (c.publish=1 or c.publish=2 ) and i.status=1 {yearSql} {schoolIdIn} ";
|
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
activities.AddRange(resultSchool.list);
|
|
|
}
|
|
@@ -686,7 +698,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//获取所有区级的
|
|
|
if (!string.IsNullOrWhiteSpace(areaOwnerIn) && !string.IsNullOrEmpty(schoolIdIn)) {
|
|
|
|
|
|
- string sqlOpen = $"select value c from c join i in c.confirmedSchools where c.scope='area' and c.joinMode='enroll' and (c.publish=1 or c.publish=2 ) and s.status=1 {yearSql} {areaOwnerIn} {schoolIdIn} ";
|
|
|
+ string sqlOpen = $"select value c from c join i in c.confirmedSchools where c.scope='area' and c.joinMode='enroll' and (c.publish=1 or c.publish=2 ) and i.status=1 {yearSql} {areaOwnerIn} {schoolIdIn} ";
|
|
|
var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
activities.AddRange(resultOpen.list);
|
|
|
}
|
|
@@ -698,6 +710,11 @@ namespace TEAMModelOS.Controllers
|
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
activities.AddRange(resultSchool.list);
|
|
|
}
|
|
|
+
|
|
|
+ activities.ForEach(z => {
|
|
|
+ var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
+ z.sas=blob_sas;
|
|
|
+ });
|
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
|
}
|
|
|
//读取优课评选模块及评审规则
|
|
@@ -1028,9 +1045,7 @@ namespace TEAMModelOS.Controllers
|
|
|
jwt.Payload.TryGetValue("lang", out object _jwtlang);
|
|
|
head_lang = !string.IsNullOrWhiteSpace($"{_jwtlang}") ? $"{_jwtlang}" : head_lang;
|
|
|
}
|
|
|
- Teacher teacher = null;
|
|
|
- teacherInfo = await TeacherService.TeacherInfo(_azureCosmos, teacher, $"{name}", $"{picture}", tmdid, _azureStorage, _option, _azureRedis, ip, _httpTrigger, head_lang);
|
|
|
-
|
|
|
+ teacherInfo = await TeacherService.TeacherInfoLite(_azureCosmos, $"{name}", $"{picture}", tmdid, _azureStorage, _option, _azureRedis, ip, _httpTrigger, head_lang);
|
|
|
string sql = $"select value c from c where c.route='{_route}'";
|
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ActivityWebsite>(sql, "ActivityWebsite");
|
|
|
ActivityWebsite website = null;
|
|
@@ -1046,10 +1061,79 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ List<string > roles= new List<string>() { "teacher" };
|
|
|
+
|
|
|
+ CoreUser coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", teacherInfo.teacher.id } }, _option.Location, _configuration);
|
|
|
+ string sqlExpert = $"select value c from c join e in c.experts where e.id='{teacherInfo.teacher.id}'";
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mobile)) {
|
|
|
+ sqlExpert=$" or e.mobile='{coreUser.mobile}' ";
|
|
|
+
|
|
|
+ }
|
|
|
+ var resultActivityExpert = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ActivityExpert>(sqlExpert, "ActivityExpert",pageSize:1);
|
|
|
|
|
|
- return Ok(new { website, code =200, teacher});
|
|
|
+ if (resultActivityExpert.list.IsNotEmpty()) {
|
|
|
+ roles.Add("expert");
|
|
|
+ }
|
|
|
+ var payload = new JwtPayload {
|
|
|
+ { JwtRegisteredClaimNames.Iss, _option.HostName }, //發行者
|
|
|
+ { JwtRegisteredClaimNames.Sub, teacherInfo.teacher.id }, // 用戶ID
|
|
|
+ { JwtRegisteredClaimNames.Exp,DateTimeOffset.UtcNow.AddHours(2).ToUnixTimeSeconds()}, // 到期的時間,必須為數字
|
|
|
+ { "name",name}, // 用戶的顯示名稱
|
|
|
+ { "picture",picture}, // 用戶頭像
|
|
|
+ { "roles", roles}, // 登入者的角色,角色類型 (Admin、Teacher、Student)
|
|
|
+ { JwtRegisteredClaimNames.Website,website.route},
|
|
|
+ };
|
|
|
+ var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_option.JwtSecretKey));
|
|
|
+ var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
|
|
|
+ var header = new JwtHeader(signingCredentials);
|
|
|
+ var secToken = new JwtSecurityToken(header, payload);
|
|
|
+ // 產出所需要的 JWT securityToken 物件,並取得序列化後的 Token 結果(字串格式)
|
|
|
+ var tokenHandler = new JwtSecurityTokenHandler();
|
|
|
+ var serializeToken = tokenHandler.WriteToken(secToken);
|
|
|
+ return Ok(new { website, code =200,token =serializeToken, schools= teacherInfo.teacher.schools.Where(z=>z.status.Equals("join"))});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-website")]
|
|
|
+ public async Task<IActionResult> GetWebsite(JsonElement request) {
|
|
|
+ if (!request.TryGetProperty("route", out JsonElement _route)) return BadRequest();
|
|
|
+ string sql = $"select value c from c where c.route='{_route}'";
|
|
|
+ var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ActivityWebsite>(sql, "ActivityWebsite");
|
|
|
+ ActivityWebsite website = null;
|
|
|
+ if (result.list.Count>1)
|
|
|
+ {
|
|
|
+ return Ok(new { code = 1, msg = "路由匹配多个区校" });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (result.list.Count==1)
|
|
|
+ {
|
|
|
+ website= result.list[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (website!= null)
|
|
|
+ {
|
|
|
+ List<ActivityWebsite> websites = new List<ActivityWebsite>();
|
|
|
+ if (website.route.Equals("teammodel") )
|
|
|
+ {
|
|
|
+ string sqlAll = $"select value c from c where IS_DEFINED(c.route) = true and c.route<> null and c.route<>'' ";
|
|
|
+ var resultAll = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ActivityWebsite>(sqlAll, "ActivityWebsite");
|
|
|
+ websites=resultAll.list;
|
|
|
+ }
|
|
|
+ return Ok(new { code = 200, website ,websites });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return Ok(new { code = 2, msg = "未匹配分站" }) ;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// portal站的
|
|
|
/// </summary>
|