|
@@ -2394,6 +2394,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
public async Task<IActionResult> SetScPeriod(JsonElement jsonElement)
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("scId", out JsonElement scId)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("periodName", out JsonElement periodName)) return BadRequest();
|
|
|
+
|
|
|
+ List<string> periodNames = $"{periodName}".ToObject<List<string>>();
|
|
|
jsonElement.TryGetProperty("Language", out JsonElement Language);
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
@@ -2423,34 +2426,42 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
School school = null;
|
|
|
|
|
|
school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{scId}", new PartitionKey("Base"));
|
|
|
+
|
|
|
if (school != null)
|
|
|
{
|
|
|
- school.period.Add(new Period
|
|
|
+ foreach (var item in periodNames)
|
|
|
{
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- name = "默认学段",
|
|
|
- campusId = campusId,
|
|
|
- semesters = new List<Semester>() { new Semester { name = schoolConfig.semester[0].term, start = schoolConfig.semester[0].start, month = schoolConfig.semester[0].month, day = schoolConfig.semester[0].day, id = Guid.NewGuid().ToString() },
|
|
|
+ if (school.campuses.Count > 0)
|
|
|
+ campusId = school.campuses.Select(x => x.id).FirstOrDefault().ToString();
|
|
|
+
|
|
|
+ school.period.Add(new Period
|
|
|
+ {
|
|
|
+ id = Guid.NewGuid().ToString(),
|
|
|
+ name = item,
|
|
|
+ campusId = campusId,
|
|
|
+ semesters = new List<Semester>() { new Semester { name = schoolConfig.semester[0].term, start = schoolConfig.semester[0].start, month = schoolConfig.semester[0].month, day = schoolConfig.semester[0].day, id = Guid.NewGuid().ToString() },
|
|
|
new Semester { name = schoolConfig.semester[1].term, start = schoolConfig.semester[1].start, month = schoolConfig.semester[1].month, day = schoolConfig.semester[1].day, id = Guid.NewGuid().ToString() } },
|
|
|
- subjects = new List<Subject>() {
|
|
|
+ subjects = new List<Subject>() {
|
|
|
new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[0].name,type=schoolConfig.PresetSubject[0].type },
|
|
|
new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[1].name,type=schoolConfig.PresetSubject[1].type },
|
|
|
new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[2].name,type=schoolConfig.PresetSubject[2].type }
|
|
|
},
|
|
|
- grades = schoolConfig.grades,
|
|
|
- analysis = new Analysis()
|
|
|
- {
|
|
|
- type = new List<ExamSimple>() { new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[0].name },
|
|
|
+ grades = schoolConfig.grades,
|
|
|
+ analysis = new Analysis()
|
|
|
+ {
|
|
|
+ type = new List<ExamSimple>() { new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[0].name },
|
|
|
new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[1].name },
|
|
|
new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[2].name },
|
|
|
new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[3].name } },
|
|
|
- income = schoolConfig.PresetExam[0].income,
|
|
|
- eugenics = schoolConfig.PresetExam[0].eugenics,
|
|
|
- touch = schoolConfig.PresetExam[0].touch
|
|
|
- }
|
|
|
- });
|
|
|
+ income = schoolConfig.PresetExam[0].income,
|
|
|
+ eugenics = schoolConfig.PresetExam[0].eugenics,
|
|
|
+ touch = schoolConfig.PresetExam[0].touch
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- school.campuses.Add(new Campus { name = school.name, id = campusId });
|
|
|
+ if (!school.campuses.Select(x => x.id).Contains(campusId))
|
|
|
+ school.campuses.Add(new Campus { name = school.name, id = campusId });
|
|
|
}
|
|
|
|
|
|
school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|