|
@@ -27,6 +27,162 @@ namespace TEAMModelOS.SDK
|
|
{
|
|
{
|
|
public class SchoolService
|
|
public class SchoolService
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+ public static async Task<School> ModifySchool(School school, AzureCosmosFactory _azureCosmos) {
|
|
|
|
+
|
|
|
|
+ //修补五育的科目关联
|
|
|
|
+ var subjects = school.period.SelectMany(x => x.subjects).Where(y => (!string.IsNullOrWhiteSpace(y.bindId) &&
|
|
|
|
+ (y.bindId.Equals("subject_painting") || y.bindId.Equals("subject_sport")
|
|
|
|
+ || y.bindId.Equals("subject_labour") || y.bindId.Equals("subject_virtue") || y.bindId.Equals("subject_music")
|
|
|
|
+
|
|
|
|
+ || y.bindId.Equals("subject_chinese") || y.bindId.Equals("subject_math") || y.bindId.Equals("subject_english")
|
|
|
|
+ || y.bindId.Equals("subject_physics") || y.bindId.Equals("subject_chemistry") || y.bindId.Equals("subject_biology")
|
|
|
|
+ || y.bindId.Equals("subject_politics") || y.bindId.Equals("subject_history") || y.bindId.Equals("subject_geography")
|
|
|
|
+
|
|
|
|
+ ))
|
|
|
|
+ || y.name.Contains("音乐") || y.name.Contains("美术") || y.name.Contains("劳动") || y.name.Contains("德育") || y.name.Contains("体育")
|
|
|
|
+ || y.name.Contains("语文") || y.name.Contains("数学") || y.name.Contains("英语") || y.name.Contains("物理") || y.name.Contains("化学")
|
|
|
|
+ || y.name.Contains("生物") || y.name.Contains("政治") || y.name.Contains("历史") || y.name.Contains("地理")
|
|
|
|
+ );
|
|
|
|
+ if (subjects.Any())
|
|
|
|
+ {
|
|
|
|
+ bool change = false;
|
|
|
|
+ foreach (var subject in subjects)
|
|
|
|
+ {
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("语文"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_chinese";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("数学"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_math";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("英语"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_english";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("物理"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_physics";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("化学"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_chemistry";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("生物"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_biology";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("政治"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_politics";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("历史"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_history";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("地理"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_geography";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("音乐"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_music";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("美术"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_painting";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("劳动"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_labour";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("德育"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_virtue";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ if (string.IsNullOrWhiteSpace(subject.bindId) && subject.name.Contains("体育"))
|
|
|
|
+ {
|
|
|
|
+ subject.bindId="subject_sport";
|
|
|
|
+ change= true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //{
|
|
|
|
+ // List<Period> periods = new List<Period>();
|
|
|
|
+ // var hastype_period = school.period.Where(p => !string.IsNullOrWhiteSpace(p.periodType));
|
|
|
|
+ // if (hastype_period.Any())
|
|
|
|
+ // {
|
|
|
|
+ // periods.AddRange(hastype_period);
|
|
|
|
+ // }
|
|
|
|
+ // var nottype_period = school.period.Where(p => string.IsNullOrWhiteSpace(p.periodType));
|
|
|
|
+ // if (nottype_period!=null && nottype_period.Count()>0)
|
|
|
|
+ // {
|
|
|
|
+ // foreach (var period in nottype_period)
|
|
|
|
+ // {
|
|
|
|
+ // if (period.name.Contains("小学"))
|
|
|
|
+ // {
|
|
|
|
+ // change= true;
|
|
|
|
+ // period.periodType= "primary";
|
|
|
|
+ // }
|
|
|
|
+ // if (period.name.Contains("初中"))
|
|
|
|
+ // {
|
|
|
|
+ // change= true;
|
|
|
|
+ // period.periodType = "junior";
|
|
|
|
+ // }
|
|
|
|
+ // if (period.name.Contains("高中"))
|
|
|
|
+ // {
|
|
|
|
+ // change= true;
|
|
|
|
+ // period.periodType = "senior";
|
|
|
|
+ // }
|
|
|
|
+ // if (string.IsNullOrWhiteSpace(period.periodType) && school.period.Count == 1)
|
|
|
|
+ // {
|
|
|
|
+ // if (school.name.Contains("小学"))
|
|
|
|
+ // {
|
|
|
|
+ // change= true;
|
|
|
|
+ // period.periodType = "primary";
|
|
|
|
+
|
|
|
|
+ // }
|
|
|
|
+ // if (school.name.Contains("初中"))
|
|
|
|
+ // {
|
|
|
|
+ // change= true;
|
|
|
|
+ // period.periodType = "junior";
|
|
|
|
+ // }
|
|
|
|
+ // if (school.name.Contains("高中"))
|
|
|
|
+ // {
|
|
|
|
+ // change= true;
|
|
|
|
+ // period.periodType = "senior";
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // if (!string.IsNullOrWhiteSpace(period.periodType))
|
|
|
|
+ // {
|
|
|
|
+ // periods.Add(period);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ if (change)
|
|
|
|
+ {
|
|
|
|
+ School schoolSelf = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return school;
|
|
|
|
+ }
|
|
|
|
+
|
|
public static async Task<(int code, string msg, object data)> JoinScool(string school, string id, string name, string picture, long ts,
|
|
public static async Task<(int code, string msg, object data)> JoinScool(string school, string id, string name, string picture, long ts,
|
|
AzureCosmosFactory _azureCosmos,AzureStorageFactory _azureStorage,CoreAPIHttpService _coreAPIHttpService,DingDing _dingDing,Option _option,IConfiguration _configuration, IWebHostEnvironment _environment)
|
|
AzureCosmosFactory _azureCosmos,AzureStorageFactory _azureStorage,CoreAPIHttpService _coreAPIHttpService,DingDing _dingDing,Option _option,IConfiguration _configuration, IWebHostEnvironment _environment)
|
|
{
|
|
{
|