|
@@ -22,10 +22,12 @@ using StackExchange.Redis;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using OpenXmlPowerTools;
|
|
using OpenXmlPowerTools;
|
|
|
|
+using System.IdentityModel.Tokens.Jwt;
|
|
|
|
+using Microsoft.AspNetCore.Routing;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
@@ -50,7 +52,7 @@ namespace TEAMModelOS.Controllers
|
|
_serviceBus = serviceBus;
|
|
_serviceBus = serviceBus;
|
|
_configuration = configuration;
|
|
_configuration = configuration;
|
|
_azureStorage = azureStorage;
|
|
_azureStorage = azureStorage;
|
|
- _azureRedis = azureRedis;
|
|
|
|
|
|
+ _azureRedis = azureRedis;
|
|
_coreAPIHttpService = coreAPIHttpService;
|
|
_coreAPIHttpService = coreAPIHttpService;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -64,8 +66,82 @@ namespace TEAMModelOS.Controllers
|
|
[HttpPost("website-manage")]
|
|
[HttpPost("website-manage")]
|
|
[Authorize(Roles = "IES")]
|
|
[Authorize(Roles = "IES")]
|
|
|
|
|
|
- public async Task<IActionResult> RouteManage(JsonElement request) {
|
|
|
|
|
|
+ public async Task<IActionResult> WebsiteManage(JsonElement request) {
|
|
|
|
+ (string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
+ if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
|
|
+ {
|
|
|
|
+ switch (true)
|
|
|
|
+ {
|
|
|
|
+ case bool when $"{grant_type}".Equals("list", StringComparison.OrdinalIgnoreCase):
|
|
|
|
+ {
|
|
|
|
+ List<ActivityWebsite> websites = new List<ActivityWebsite>();
|
|
|
|
+ if (!request.TryGetProperty("websiteId", out JsonElement _websiteId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
|
|
+ string websiteId = _websiteId.GetString();
|
|
|
|
+ if (websiteId.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase) )
|
|
|
|
+ {
|
|
|
|
+ Azure.Response teammodelResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync("teammodel", new PartitionKey("ActivityWebsite"));
|
|
|
|
+ if (teammodelResponse.Status == 200)
|
|
|
|
+ {
|
|
|
|
+ ActivityWebsite activityWebsite = JsonDocument.Parse(teammodelResponse.Content).RootElement.ToObject<ActivityWebsite>();
|
|
|
|
+ websites.Add(activityWebsite);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ ActivityWebsite website = new ActivityWebsite
|
|
|
|
+ {
|
|
|
|
+ id="teammodel",
|
|
|
|
+ pk="ActivityWebsite",
|
|
|
|
+ code="ActivityWebsite",
|
|
|
|
+ route="teammodel",
|
|
|
|
+ scope="public",
|
|
|
|
+ };
|
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
|
|
|
|
+ websites.Add(website);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Azure.Response activityWebsiteResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(websiteId, new PartitionKey("ActivityWebsite"));
|
|
|
|
+ if (activityWebsiteResponse.Status == 200)
|
|
|
|
+ {
|
|
|
|
+ ActivityWebsite activityWebsite = JsonDocument.Parse(activityWebsiteResponse.Content).RootElement.ToObject<ActivityWebsite>();
|
|
|
|
+ websites.Add(activityWebsite);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ string route = string.Empty;
|
|
|
|
+ if (_scope.GetString().Equals("area", StringComparison.OrdinalIgnoreCase))
|
|
|
|
+ {
|
|
|
|
+ Area area = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>(websiteId, new PartitionKey("Base-Area"));
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(area.shortCode))
|
|
|
|
+ {
|
|
|
|
+ route=area.shortCode;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (_scope.GetString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
|
+ {
|
|
|
|
+ route=websiteId;
|
|
|
|
+ }
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(route))
|
|
|
|
+ {
|
|
|
|
+ ActivityWebsite website = new ActivityWebsite
|
|
|
|
+ {
|
|
|
|
+ id=websiteId,
|
|
|
|
+ pk="ActivityWebsite",
|
|
|
|
+ code="ActivityWebsite",
|
|
|
|
+ route=route,
|
|
|
|
+ scope=_scope.GetString(),
|
|
|
|
+ };
|
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
|
|
|
|
+ websites.Add(website);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return Ok(new { code = 1, msg = "区级简码未设置" });
|
|
|
|
+ }
|
|
|
|
+ return Ok(new { code = 200, websites });
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
return Ok();
|
|
return Ok();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -79,7 +155,7 @@ namespace TEAMModelOS.Controllers
|
|
[HttpPost("invite-target")]
|
|
[HttpPost("invite-target")]
|
|
[Authorize(Roles = "IES")]
|
|
[Authorize(Roles = "IES")]
|
|
|
|
|
|
- public async Task<IActionResult> InviteTarget (JsonElement request)
|
|
|
|
|
|
+ public async Task<IActionResult> InviteTarget(JsonElement request)
|
|
{
|
|
{
|
|
(string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
(string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
@@ -87,7 +163,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
case bool when $"{grant_type}".Equals("schools", StringComparison.OrdinalIgnoreCase):
|
|
case bool when $"{grant_type}".Equals("schools", StringComparison.OrdinalIgnoreCase):
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
string sql = string.Empty;
|
|
string sql = string.Empty;
|
|
if (_scope.GetString().Equals("public", StringComparison.OrdinalIgnoreCase))
|
|
if (_scope.GetString().Equals("public", StringComparison.OrdinalIgnoreCase))
|
|
@@ -99,12 +175,12 @@ namespace TEAMModelOS.Controllers
|
|
sql = $"select c.id,c.name ,c.picture,c.region,c.province,c.city,c.areaId from c where c.code='Base' and c.areaId='{_areaId}' ";
|
|
sql = $"select c.id,c.name ,c.picture,c.region,c.province,c.city,c.areaId from c where c.code='Base' and c.areaId='{_areaId}' ";
|
|
}
|
|
}
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<School>(sql, "Base");
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<School>(sql, "Base");
|
|
- var sc= result.list.FindAll(z => !string.IsNullOrWhiteSpace(z.areaId));
|
|
|
|
|
|
+ var sc = result.list.FindAll(z => !string.IsNullOrWhiteSpace(z.areaId));
|
|
if (sc.IsNotEmpty()) {
|
|
if (sc.IsNotEmpty()) {
|
|
- string areaSql = $"select value c from c where c.id in ({string.Join(",",sc.Select(z=>$"'{z.areaId}'").ToHashSet())})";
|
|
|
|
- var areaResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<Area>(sql, "Base-Area");
|
|
|
|
|
|
+ string areaSql = $"select value c from c where c.id in ({string.Join(",", sc.Select(z => $"'{z.areaId}'").ToHashSet())})";
|
|
|
|
+ var areaResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<Area>(sql, "Base-Area");
|
|
if (areaResult.list.IsNotEmpty()) {
|
|
if (areaResult.list.IsNotEmpty()) {
|
|
- List<dynamic> schools= new List<dynamic>();
|
|
|
|
|
|
+ List<dynamic> schools = new List<dynamic>();
|
|
foreach (var item in result.list) {
|
|
foreach (var item in result.list) {
|
|
if (!string.IsNullOrWhiteSpace(item.areaId))
|
|
if (!string.IsNullOrWhiteSpace(item.areaId))
|
|
{
|
|
{
|
|
@@ -117,15 +193,15 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return Ok(new {code=200, schools = result.list.Select(z=>new { z.id,z.name,z.picture,z.region,z.province,z.city,z.areaId, areaName = string.Empty }) });
|
|
|
|
|
|
+ return Ok(new { code = 200, schools = result.list.Select(z => new { z.id, z.name, z.picture, z.region, z.province, z.city, z.areaId, areaName = string.Empty }) });
|
|
}
|
|
}
|
|
case bool when $"{grant_type}".Equals("teachers", StringComparison.OrdinalIgnoreCase):
|
|
case bool when $"{grant_type}".Equals("teachers", StringComparison.OrdinalIgnoreCase):
|
|
{
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(school)) {
|
|
if (!string.IsNullOrWhiteSpace(school)) {
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
- string sql = $"select c.id,c.name ,c.picture from c where c.code='Teacher-{school}' ";
|
|
|
|
|
|
+ string sql = $"select c.id,c.name ,c.picture from c where c.code='Teacher-{school}' ";
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<SchoolTeacher>(sql, $"Teacher-{school}");
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<SchoolTeacher>(sql, $"Teacher-{school}");
|
|
- return Ok(new { code = 200, teachers = result.list.Select(z=>new { z.id,z.name,z.picture,school,schooName = schoolbase.name}) });
|
|
|
|
|
|
+ return Ok(new { code = 200, teachers = result.list.Select(z => new { z.id, z.name, z.picture, school, schooName = schoolbase.name }) });
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -149,7 +225,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
(string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
(string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
-
|
|
|
|
|
|
+
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
switch (true)
|
|
switch (true)
|
|
{
|
|
{
|
|
@@ -157,7 +233,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
if (!request.TryGetProperty("Activity", out JsonElement _activity)) return Ok(new { error = ResponseCode._400ParamsError, msg = "活动信息参数错误" });
|
|
if (!request.TryGetProperty("Activity", out JsonElement _activity)) return Ok(new { error = ResponseCode._400ParamsError, msg = "活动信息参数错误" });
|
|
Activity activity = _activity.ToObject<Activity>();
|
|
Activity activity = _activity.ToObject<Activity>();
|
|
- activity.id=!string.IsNullOrWhiteSpace(activity.id)?activity.id: Guid.NewGuid().ToString();
|
|
|
|
|
|
+ activity.id=!string.IsNullOrWhiteSpace(activity.id) ? activity.id : Guid.NewGuid().ToString();
|
|
activity.code="Activity";
|
|
activity.code="Activity";
|
|
activity.pk="Activity";
|
|
activity.pk="Activity";
|
|
//如果是区级活动,enroll报名制,则学校的确认状态默认为1 。
|
|
//如果是区级活动,enroll报名制,则学校的确认状态默认为1 。
|
|
@@ -168,7 +244,41 @@ namespace TEAMModelOS.Controllers
|
|
//醍摩豆智慧学区
|
|
//醍摩豆智慧学区
|
|
if (!activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase) && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase))
|
|
if (!activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase) && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
- return Ok(new { error = ResponseCode._400ParamsError, msg = "公开的活动只能由醍摩豆智慧学区发布!" });
|
|
|
|
|
|
+ return Ok(new { error = ResponseCode._400ParamsError, msg = "公开的活动只能由醍摩豆智慧学区发布!" });
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ string websiteId = activity.owner;
|
|
|
|
+ string route = string.Empty;
|
|
|
|
+ if (activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase) && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase)) {
|
|
|
|
+ websiteId="teammodel";
|
|
|
|
+ route="teammodel";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Azure.Response activityWebsiteResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(websiteId, new PartitionKey("ActivityWebsite"));
|
|
|
|
+ if (activityWebsiteResponse.Status!=200) {
|
|
|
|
+ if (activity.scope.Equals("area", StringComparison.OrdinalIgnoreCase)) {
|
|
|
|
+ Area area = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>(activity.owner, new PartitionKey("Base-Area"));
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(area.shortCode)) {
|
|
|
|
+ route=area.shortCode;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (activity.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
|
+ {
|
|
|
|
+ route=activity.owner;
|
|
|
|
+ }
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(route))
|
|
|
|
+ {
|
|
|
|
+ ActivityWebsite website = new ActivityWebsite
|
|
|
|
+ {
|
|
|
|
+ id=websiteId,
|
|
|
|
+ pk="ActivityWebsite",
|
|
|
|
+ code="ActivityWebsite",
|
|
|
|
+ route=route,
|
|
|
|
+ scope=activity.scope,
|
|
|
|
+ };
|
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
ValidResult validResult = activity.Valid();
|
|
ValidResult validResult = activity.Valid();
|
|
if (validResult.isVaild)
|
|
if (validResult.isVaild)
|
|
@@ -177,7 +287,7 @@ namespace TEAMModelOS.Controllers
|
|
activity.createTime= DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
activity.createTime= DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
activity.year=DateTimeOffset.Now.Year;
|
|
activity.year=DateTimeOffset.Now.Year;
|
|
foreach (var module in activity.modules) {
|
|
foreach (var module in activity.modules) {
|
|
- switch (true)
|
|
|
|
|
|
+ switch (true)
|
|
{
|
|
{
|
|
//赛课
|
|
//赛课
|
|
case bool when module.Equals("Contest"):
|
|
case bool when module.Equals("Contest"):
|
|
@@ -204,7 +314,7 @@ namespace TEAMModelOS.Controllers
|
|
return Ok(new { error = ResponseCode._400ParamsError, msg = "评审未配置" });
|
|
return Ok(new { error = ResponseCode._400ParamsError, msg = "评审未配置" });
|
|
}
|
|
}
|
|
ReviewRuleTree ruleTree = _reviewConfig.ToObject<ReviewRuleTree>();
|
|
ReviewRuleTree ruleTree = _reviewConfig.ToObject<ReviewRuleTree>();
|
|
- var reviewRule = await ActivityService.UpsertReviewRule(ruleTree, activity, _azureCosmos);
|
|
|
|
|
|
+ var reviewRule = await ActivityService.UpsertReviewRule(ruleTree, activity, _azureCosmos);
|
|
contest.review.ruleId = reviewRule.id;
|
|
contest.review.ruleId = reviewRule.id;
|
|
contest.review.ruleName = reviewRule.name;
|
|
contest.review.ruleName = reviewRule.name;
|
|
}
|
|
}
|
|
@@ -241,23 +351,23 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
if (!request.TryGetProperty("areaId", out JsonElement _areaId)) return BadRequest();
|
|
if (!request.TryGetProperty("areaId", out JsonElement _areaId)) return BadRequest();
|
|
string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
|
|
string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
|
|
-
|
|
|
|
|
|
+
|
|
if (request.TryGetProperty("year", out JsonElement _year)) {
|
|
if (request.TryGetProperty("year", out JsonElement _year)) {
|
|
yearSql = $" and c.year={_year}";
|
|
yearSql = $" and c.year={_year}";
|
|
}
|
|
}
|
|
string sql = $"select value c from c where c.scope='area' and c.owner='{_areaId}' {yearSql} ";
|
|
string sql = $"select value c from c where c.scope='area' and c.owner='{_areaId}' {yearSql} ";
|
|
//醍摩豆智慧学区
|
|
//醍摩豆智慧学区
|
|
if (_areaId.GetString().Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)) {
|
|
if (_areaId.GetString().Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)) {
|
|
- sql = $"select value c from c where c.owner='{_areaId}' {yearSql } and ( c.scope='area' or c.scope='public' ) ";
|
|
|
|
|
|
+ sql = $"select value c from c where c.owner='{_areaId}' {yearSql} and ( c.scope='area' or c.scope='public' ) ";
|
|
}
|
|
}
|
|
- var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
|
|
|
|
- return Ok(new { activities = result.list.OrderByDescending(z=>z.stime) });
|
|
|
|
|
|
+ var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
|
|
|
|
+ return Ok(new { activities = result.list.OrderByDescending(z => z.stime) });
|
|
}
|
|
}
|
|
case bool when $"{grant_type}".Equals("list-school", StringComparison.OrdinalIgnoreCase):
|
|
case bool when $"{grant_type}".Equals("list-school", StringComparison.OrdinalIgnoreCase):
|
|
{
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(school)) {
|
|
if (!string.IsNullOrWhiteSpace(school)) {
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
- List<Activity> activities = new List<Activity>();
|
|
|
|
|
|
+ List<Activity> activities = new List<Activity>();
|
|
string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
|
|
string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
|
|
|
|
|
|
if (request.TryGetProperty("year", out JsonElement _year))
|
|
if (request.TryGetProperty("year", out JsonElement _year))
|
|
@@ -269,7 +379,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
//完全开放 所有的学校
|
|
//完全开放 所有的学校
|
|
string sqlOpen = $"select value c from c where c.scope='public'{yearSql} and (c.publish=1 or c.publish=2 ) and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false ) ";
|
|
string sqlOpen = $"select value c from c where c.scope='public'{yearSql} and (c.publish=1 or c.publish=2 ) and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false ) ";
|
|
- var resultOpen= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
|
|
|
+ var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
activities.AddRange(resultOpen.list);
|
|
activities.AddRange(resultOpen.list);
|
|
//部分学校
|
|
//部分学校
|
|
string sqlSchool = $"select value c from c join s in c.invitedSchools where c.scope='public'{yearSql} and (c.publish=1 or c.publish=2 ) and s.id='{school}' ";
|
|
string sqlSchool = $"select value c from c join s in c.invitedSchools where c.scope='public'{yearSql} and (c.publish=1 or c.publish=2 ) and s.id='{school}' ";
|
|
@@ -291,7 +401,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
//获取区级下放的
|
|
//获取区级下放的
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
if (!string.IsNullOrWhiteSpace(schoolbase.areaId)) {
|
|
if (!string.IsNullOrWhiteSpace(schoolbase.areaId)) {
|
|
//区级所有学校
|
|
//区级所有学校
|
|
string sqlOpen = $"select value c from c where c.scope='area'{yearSql} and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false) ";
|
|
string sqlOpen = $"select value c from c where c.scope='area'{yearSql} and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false) ";
|
|
@@ -312,7 +422,7 @@ namespace TEAMModelOS.Controllers
|
|
activities.AddRange(resultOpen.list);
|
|
activities.AddRange(resultOpen.list);
|
|
//区级部分学校
|
|
//区级部分学校
|
|
string sqlSchool = $"select value c from c join s in c.invitedSchools where c.scope='area'{yearSql} and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and s.id='{school}' ";
|
|
string sqlSchool = $"select value c from c join s in c.invitedSchools where c.scope='area'{yearSql} and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and s.id='{school}' ";
|
|
- var resultSchool= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
resultSchool.list.ForEach(z => {
|
|
resultSchool.list.ForEach(z => {
|
|
var confirmedSchool = z.confirmedSchools.Find(z => z.id.Equals(school));
|
|
var confirmedSchool = z.confirmedSchools.Find(z => z.id.Equals(school));
|
|
if (confirmedSchool==null)
|
|
if (confirmedSchool==null)
|
|
@@ -334,13 +444,12 @@ namespace TEAMModelOS.Controllers
|
|
string sqlSchool = $"select value c from c where c.scope='school'{yearSql} and c.owner='{school}' ";
|
|
string sqlSchool = $"select value c from c where c.scope='school'{yearSql} and c.owner='{school}' ";
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
activities.AddRange(resultSchool.list);
|
|
activities.AddRange(resultSchool.list);
|
|
- }
|
|
|
|
|
|
+ }
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
case bool when $"{grant_type}".Equals("list-teacher", StringComparison.OrdinalIgnoreCase):
|
|
case bool when $"{grant_type}".Equals("list-teacher", StringComparison.OrdinalIgnoreCase):
|
|
{
|
|
{
|
|
List<Activity> activities = new List<Activity>();
|
|
List<Activity> activities = new List<Activity>();
|
|
@@ -354,7 +463,7 @@ namespace TEAMModelOS.Controllers
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
//获取区级下放的
|
|
//获取区级下放的
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
if (!string.IsNullOrWhiteSpace(schoolbase.areaId))
|
|
if (!string.IsNullOrWhiteSpace(schoolbase.areaId))
|
|
{
|
|
{
|
|
//区级所有学校
|
|
//区级所有学校
|
|
@@ -362,7 +471,7 @@ namespace TEAMModelOS.Controllers
|
|
var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
resultOpen.list.ForEach(z => {
|
|
resultOpen.list.ForEach(z => {
|
|
//处理是否是邀请制
|
|
//处理是否是邀请制
|
|
- if (z.joinMode.Equals("invite"))
|
|
|
|
|
|
+ if (z.joinMode.Equals("invite"))
|
|
{
|
|
{
|
|
var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
|
|
var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
|
|
if (inviteTeacher!=null) {
|
|
if (inviteTeacher!=null) {
|
|
@@ -442,19 +551,88 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
}
|
|
}
|
|
- case bool when $"{grant_type}".Equals("list-portal", StringComparison.OrdinalIgnoreCase):
|
|
|
|
- {
|
|
|
|
- if (!request.TryGetProperty("route", out JsonElement _route)) return BadRequest();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- }catch (Exception ex)
|
|
|
|
|
|
+ } catch (Exception ex)
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
return Ok();
|
|
return Ok();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// portal站的
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [HttpPost("list-portal")]
|
|
|
|
+ public async Task<IActionResult> ListPortal(JsonElement request) {
|
|
|
|
+ //var authtoken = HttpContext.GetXAuth("AuthToken");
|
|
|
|
+ //string userid = string.Empty;
|
|
|
|
+ //object schoolid = null;
|
|
|
|
+ //if (!string.IsNullOrWhiteSpace(authtoken)) {
|
|
|
|
+ // var jwt = new JwtSecurityToken(authtoken);
|
|
|
|
+ // //TODO 此驗證IdToken先簡單檢查,後面需向Core ID新API,驗證Token
|
|
|
|
+ // userid= jwt.Payload.Sub;
|
|
|
|
+ // jwt.Payload.TryGetValue("azp", out schoolid);
|
|
|
|
+ //}
|
|
|
|
+ if (!request.TryGetProperty("route", out JsonElement _route)) return BadRequest();
|
|
|
|
+ List<Activity> activities = new List<Activity>();
|
|
|
|
+ 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)
|
|
|
|
+ {
|
|
|
|
+ if (website.scope.Equals("area"))
|
|
|
|
+ {
|
|
|
|
+ //区级所有学校
|
|
|
|
+ string sqlOpen = $"select value c from c where c.scope='area' and (c.publish=1 or c.publish=2 ) and c.owner='{website.id}' ";
|
|
|
|
+ var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
|
+ activities.AddRange(resultOpen.list);
|
|
|
|
+ }
|
|
|
|
+ if (website.scope.Equals("school"))
|
|
|
|
+ {
|
|
|
|
+ School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(website.id, new PartitionKey("Base"));
|
|
|
|
+ //区级下放的
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(schoolbase.areaId))
|
|
|
|
+ {
|
|
|
|
+ //区级所有学校
|
|
|
|
+ string sqlOpen = $"select value c from c join s in c.confirmedSchools where c.scope='area' and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false) and s.id='{schoolbase.id}' and s.status=1 ";
|
|
|
|
+ var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
|
+ activities.AddRange(resultOpen.list);
|
|
|
|
+ //区级部分学校
|
|
|
|
+ string sqlSchool = $"select value c from c join i in c.invitedSchools join s in c.confirmedSchools where c.scope='area'and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and i.id='{schoolbase.id}' and s.id='{schoolbase.id}' and s.status=1 ";
|
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ ///学校自己的
|
|
|
|
+ string sqlSchool = $"select value c from c where c.scope='school' and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.id}' ";
|
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //获取开放的
|
|
|
|
+ {
|
|
|
|
+ //完全开放 所有的学校
|
|
|
|
+ string sqlOpen = $"select value c from c where c.scope='public' and (c.publish=1 or c.publish=2 ) ";
|
|
|
|
+ var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
|
+ activities.AddRange(resultOpen.list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(new { activities, website });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|