Browse Source

修改接口

CrazyIter 5 năm trước cách đây
mục cha
commit
0f3efc9a99

+ 23 - 23
TEAMModelOS.API/Controllers/Core/StudentInfoController.cs

@@ -15,31 +15,31 @@ namespace TEAMModelOS.API.Controllers.Core
     [Route("api/[controller]")]
     [ApiController]
     // [Authorize]
-    public class StudentInfoController : BaseController
+    public class StudentController : BaseController
     {
         private readonly IAzureCosmosDBRepository azureCosmosDBRepository;
-        public StudentInfoController(IAzureCosmosDBRepository _azureCosmosDBRepository)
+        public StudentController(IAzureCosmosDBRepository _azureCosmosDBRepository)
         {
             azureCosmosDBRepository = _azureCosmosDBRepository;
         }
 
-        [HttpPost("SaveStudentInfo")]
-        public async Task<BaseJosnRPCResponse> SaveStudentInfo(JosnRPCRequest<StudentInfo> request)
+        [HttpPost("SaveStudent")]
+        public async Task<BaseJosnRPCResponse> SaveStudentInfo(JosnRPCRequest<Student> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            StudentInfo data = await azureCosmosDBRepository.Save<StudentInfo>(request.@params);
+            Student data = await azureCosmosDBRepository.Save<Student>(request.@params);
             return builder.Data(data).build();
         }
 
 
-        [HttpPost("FindStudentParams")]
+        [HttpPost("FindStudent")]
         public async Task<BaseJosnRPCResponse> FindStudent(JosnRPCRequest<Dictionary<string, object>> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
 
             if (request.@params.TryGetValue("SchoolCode", out object SchoolCode))
             {
-                List<StudentInfo> data = await azureCosmosDBRepository.FindByParams<StudentInfo>(request.@params);
+                List<Student> data = await azureCosmosDBRepository.FindByParams<Student>(request.@params);
                 return builder.Data(data).build();
             }
             else
@@ -47,52 +47,52 @@ namespace TEAMModelOS.API.Controllers.Core
                 return builder.Error("SchoolCode  is null !").build();
             }
         }
-        [HttpPost("SaveAllStudentInfo")]
-        public async Task<BaseJosnRPCResponse> SaveAllStudentInfo(JosnRPCRequest<List<StudentInfo>> request)
+        [HttpPost("SaveAllStudent")]
+        public async Task<BaseJosnRPCResponse> SaveAllStudentInfo(JosnRPCRequest<List<Student>> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            Dictionary<string, List<StudentInfo>> dictInfo = new Dictionary<string, List<StudentInfo>>();
-            foreach (IGrouping<string, StudentInfo> group in request.@params.GroupBy(c => c.classroomCode))
+            Dictionary<string, List<Student>> dictInfo = new Dictionary<string, List<Student>>();
+            foreach (IGrouping<string, Student> group in request.@params.GroupBy(c => c.classroomCode))
             {
                 dictInfo.Add(group.Key, group.ToList());
             }
-            List<StudentInfo> studentInfos = new List<StudentInfo>();
+            List<Student> studentInfos = new List<Student>();
             foreach (string key in dictInfo.Keys)
             {
                 List<Classroom> classroom = await azureCosmosDBRepository.FindByParams<Classroom>(new Dictionary<string, object> { { "ClassroomCode", key } });
                 if (classroom.IsNotEmpty())
                 {
-                    dictInfo.TryGetValue(key, out List<StudentInfo> sts);
+                    dictInfo.TryGetValue(key, out List<Student> sts);
                     sts.ForEach(x => {
                         x.gradeCode = classroom[0].gradeCode;
                         x.periodCode = classroom[0].periodCode;
                         x.schoolCode = classroom[0].schoolCode;
                         x.id = x.studentId;
                     });
-                    List<StudentInfo> data = await azureCosmosDBRepository.SaveAll<StudentInfo>(sts);
+                    List<Student> data = await azureCosmosDBRepository.SaveAll<Student>(sts);
                     studentInfos.AddRange(data);
                 }
             }
             return builder.Data(studentInfos).build();
         }
 
-        [HttpPost("UpdateStudentInfo")]
-        public async Task<BaseJosnRPCResponse> UpdateStudentInfo(JosnRPCRequest<StudentInfo> request)
+        [HttpPost("UpdateStudent")]
+        public async Task<BaseJosnRPCResponse> UpdateStudentInfo(JosnRPCRequest<Student> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            StudentInfo data = await azureCosmosDBRepository.Update<StudentInfo>(request.@params);
+            Student data = await azureCosmosDBRepository.Update<Student>(request.@params);
             return builder.Data(data).build();
         }
-        [HttpPost("UpdateAllStudentInfo")]
+        [HttpPost("UpdateAllStudent")]
         public async Task<BaseJosnRPCResponse> DeleteALlStudentInfo(JosnRPCRequest<Dictionary<string, Dictionary<string, object>>> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             bool find = request.@params.TryGetValue("find", out Dictionary<string, object> findObj);
             bool update = request.@params.TryGetValue("update", out Dictionary<string, object> updateObj);
-            List<StudentInfo> data = null;
+            List<Student> data = null;
             if (find && update)
             {
-                data = await azureCosmosDBRepository.UpdateAll<StudentInfo>(findObj, updateObj);
+                data = await azureCosmosDBRepository.UpdateAll<Student>(findObj, updateObj);
             }
             return builder.Data(data).build();
         }
@@ -101,11 +101,11 @@ namespace TEAMModelOS.API.Controllers.Core
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-        [HttpPost("DeleteStudentInfo")]
-        public async Task<BaseJosnRPCResponse> DeleteStudentInfo(JosnRPCRequest<StudentInfo> request)
+        [HttpPost("DeleteStudent")]
+        public async Task<BaseJosnRPCResponse> DeleteStudentInfo(JosnRPCRequest<Student> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            string data = await azureCosmosDBRepository.DeleteAsync<StudentInfo>(request.@params.id, request.@params.schoolCode);
+            string data = await azureCosmosDBRepository.DeleteAsync<Student>(request.@params.id, request.@params.schoolCode);
             return builder.Data(data).build();
         }
     }

+ 1 - 1
TEAMModelOS.API/Models/Core/StudentInfo.cs

@@ -6,7 +6,7 @@ using TEAMModelOS.SDK.Context.Attributes.Azure;
 
 namespace TEAMModelOS.API.Models.Core
 {
-    public class StudentInfo
+    public class Student
     {
         [JsonProperty(PropertyName = "id")]
         public string id { get; set; }