|
@@ -0,0 +1,67 @@
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.API.Models.Core;
|
|
|
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
|
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
|
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
|
+using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
|
|
|
+
|
|
|
+namespace TEAMModelOS.API.Controllers.Syllabus
|
|
|
+{
|
|
|
+ [Route("api/[controller]")]
|
|
|
+ [ApiController]
|
|
|
+ [Authorize]
|
|
|
+ public class SyllabusController : BaseController
|
|
|
+ {
|
|
|
+ private readonly IAzureCosmosDBRepository azureCosmosDBRepository;
|
|
|
+ public SyllabusController(IAzureCosmosDBRepository _azureCosmosDBRepository)
|
|
|
+ {
|
|
|
+ azureCosmosDBRepository = _azureCosmosDBRepository;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 根据课纲的业务获取
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("GetSchoolInfoAsSyllabus")]
|
|
|
+ public async Task<BaseJosnRPCResponse> GetSchoolInfoAsSyllabus(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ if (request.@params != null && request.@params.TryGetValue("Code", out _))
|
|
|
+ {
|
|
|
+ List<School> schoolSystems = await azureCosmosDBRepository.FindByParams<School>(request.@params);
|
|
|
+ List<dynamic> plist = new List<dynamic>();
|
|
|
+ if (schoolSystems.IsNotEmpty())
|
|
|
+ {
|
|
|
+ List<Period> periods = schoolSystems[0].period;
|
|
|
+ foreach (Period period in periods)
|
|
|
+ {
|
|
|
+ List<dynamic> slist = new List<dynamic>();
|
|
|
+ foreach (Subject subject in period.subjects)
|
|
|
+ {
|
|
|
+ List<dynamic> mlist = new List<dynamic>();
|
|
|
+ foreach (Semester semester in period.semesters)
|
|
|
+ {
|
|
|
+ dynamic sem = new { semester.name, semester.code };
|
|
|
+ mlist.Add(sem);
|
|
|
+ }
|
|
|
+ dynamic sub = new { semester = mlist, subject.subjectName, subject.subjectCode };
|
|
|
+ slist.Add(sub);
|
|
|
+ }
|
|
|
+ dynamic per = new { subject = slist, period.periodName, period.periodCode };
|
|
|
+ plist.Add(per);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return builder.Data(plist).build();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return builder.Error("SchoolCode is null or empty!", "SchoolCode is null or empty!").build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|