|
@@ -147,10 +147,10 @@ namespace TEAMModelOS.Controllers
|
|
|
activity.code="Activity";
|
|
|
activity.pk="Activity";
|
|
|
//如果是区级活动,enroll报名制,则学校的确认状态默认为1 。
|
|
|
- if (activity.scope.Equals("area", StringComparison.OrdinalIgnoreCase) && activity.joinMode.Equals("enroll", StringComparison.OrdinalIgnoreCase))
|
|
|
- {
|
|
|
- activity.schools.ForEach(z => z.status=1);
|
|
|
- }
|
|
|
+ //if (activity.scope.Equals("area", StringComparison.OrdinalIgnoreCase) && activity.joinMode.Equals("enroll", StringComparison.OrdinalIgnoreCase))
|
|
|
+ //{
|
|
|
+ // activity.schools.ForEach(z => z.status=1);
|
|
|
+ //}
|
|
|
//醍摩豆智慧学区
|
|
|
if (!activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase) && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
@@ -242,6 +242,7 @@ namespace TEAMModelOS.Controllers
|
|
|
case bool when $"{grant_type}".Equals("list-school", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(school)) {
|
|
|
+ School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
List<Activity> activities = new List<Activity>();
|
|
|
string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
|
|
|
|
|
@@ -251,23 +252,76 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//获取开放的
|
|
|
{
|
|
|
- string sqlOpen = $"select value c from c where c.scope='public'{yearSql} and( ARRAY_LENGTH(c.schools)=0 or IS_DEFINED(c.schools) = false ) ";
|
|
|
- string sqlSchool = $"select value c from c join s in c.schools where c.scope='public'{yearSql} and s.id='{school}' ";
|
|
|
+
|
|
|
+ //完全开放 所有的学校
|
|
|
+ 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");
|
|
|
+ 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}' ";
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
+ resultSchool.list.ForEach(z => {
|
|
|
+ var confirmedSchool = z.confirmedSchools.Find(z => z.id.Equals(school));
|
|
|
+ if (confirmedSchool==null)
|
|
|
+ {
|
|
|
+ z.confirmedSchools.Add(new ActivityConfirmedSchool
|
|
|
+ {
|
|
|
+ id=schoolbase.id,
|
|
|
+ name=schoolbase.name,
|
|
|
+ picture=schoolbase.picture,
|
|
|
+ status=0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
}
|
|
|
//获取区级下放的
|
|
|
{
|
|
|
- School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+
|
|
|
if (!string.IsNullOrWhiteSpace(schoolbase.areaId)) {
|
|
|
- string sqlOpen = $"select value c from c where c.scope='area'{yearSql} and c.owner='{schoolbase.areaId}' and( ARRAY_LENGTH(c.schools)=0 or IS_DEFINED(c.schools) = false) ";
|
|
|
- string sqlSchool = $"select value c from c join s in c.schools where c.scope='area'{yearSql} and c.owner='{schoolbase.areaId}' and s.id='{school}' ";
|
|
|
+ //区级所有学校
|
|
|
+ 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) ";
|
|
|
+ var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
+ resultOpen.list.ForEach(z => {
|
|
|
+ var confirmedSchool = z.confirmedSchools.Find(z => z.id.Equals(school));
|
|
|
+ if (confirmedSchool==null)
|
|
|
+ {
|
|
|
+ z.confirmedSchools.Add(new ActivityConfirmedSchool
|
|
|
+ {
|
|
|
+ id=schoolbase.id,
|
|
|
+ name=schoolbase.name,
|
|
|
+ picture=schoolbase.picture,
|
|
|
+ status=0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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}' ";
|
|
|
+ var resultSchool= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
+ resultSchool.list.ForEach(z => {
|
|
|
+ var confirmedSchool = z.confirmedSchools.Find(z => z.id.Equals(school));
|
|
|
+ if (confirmedSchool==null)
|
|
|
+ {
|
|
|
+ z.confirmedSchools.Add(new ActivityConfirmedSchool
|
|
|
+ {
|
|
|
+ id=schoolbase.id,
|
|
|
+ name=schoolbase.name,
|
|
|
+ picture=schoolbase.picture,
|
|
|
+ status=0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
}
|
|
|
}
|
|
|
//获取学校自己的
|
|
|
{
|
|
|
- string sqlOpen = $"select value c from c where c.scope='school'{yearSql} and c.owner='{school}' ";
|
|
|
- }
|
|
|
- var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>("", "Activity");
|
|
|
- return Ok(new { activities = result.list.OrderByDescending(z => z.stime) });
|
|
|
+ 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");
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
+ }
|
|
|
+ return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -275,6 +329,103 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
case bool when $"{grant_type}".Equals("list-teacher", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
+ List<Activity> activities = new List<Activity>();
|
|
|
+ string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
|
|
|
+
|
|
|
+ if (request.TryGetProperty("year", out JsonElement _year))
|
|
|
+ {
|
|
|
+ yearSql = $" and c.year={_year}";
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(school)) {
|
|
|
+ School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ //获取区级下放的
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!string.IsNullOrWhiteSpace(schoolbase.areaId))
|
|
|
+ {
|
|
|
+ //区级所有学校
|
|
|
+ string sqlOpen = $"select value c from c join s in c.confirmedSchools 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) and s.id='{school}' and s.status=1 ";
|
|
|
+ var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
+ resultOpen.list.ForEach(z => {
|
|
|
+ //处理是否是邀请制
|
|
|
+ if (z.joinMode.Equals("invite"))
|
|
|
+ {
|
|
|
+ var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
|
|
|
+ if (inviteTeacher!=null) {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //区级部分学校
|
|
|
+ string sqlSchool = $"select value c from c join i in c.invitedSchools join s in c.confirmedSchools where c.scope='area'{yearSql} and (c.publish=1 or c.publish=2 ) and c.owner='{schoolbase.areaId}' and i.id='{school}' and s.id='{school}' and s.status=1 ";
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
+ resultSchool.list.ForEach(z => {
|
|
|
+ //处理是否是邀请制
|
|
|
+ if (z.joinMode.Equals("invite"))
|
|
|
+ {
|
|
|
+ var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
|
|
|
+ if (inviteTeacher!=null)
|
|
|
+ {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取学校自己的
|
|
|
+ {
|
|
|
+ string sqlSchool = $"select value c from c where c.scope='school'{yearSql} and (c.publish=1 or c.publish=2 ) and c.owner='{school}' ";
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
+
|
|
|
+ resultSchool.list.ForEach(z => {
|
|
|
+ //处理是否是邀请制
|
|
|
+ if (z.joinMode.Equals("invite"))
|
|
|
+ {
|
|
|
+ var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
|
|
|
+ if (inviteTeacher!=null)
|
|
|
+ {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取开放的
|
|
|
+ {
|
|
|
+ //完全开放 所有的学校
|
|
|
+ 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");
|
|
|
+ activities.AddRange(resultOpen.list);
|
|
|
+ //部分学校
|
|
|
+ string sqlSchool = $"select value c from c join i in c.invitedSchools join s in c.confirmedSchools where c.scope='public'{yearSql} and (c.publish=1 or c.publish=2 ) and i.id='{school}' and s.id='{school}' and s.status=1 ";
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
+ resultSchool.list.ForEach(z => {
|
|
|
+ //处理是否是邀请制
|
|
|
+ if (z.joinMode.Equals("invite"))
|
|
|
+ {
|
|
|
+ var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
|
|
|
+ if (inviteTeacher!=null)
|
|
|
+ {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activities.Add(z);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case bool when $"{grant_type}".Equals("list-portal", StringComparison.OrdinalIgnoreCase):
|