소스 검색

学生信息相关接口

CrazyIter 5 년 전
부모
커밋
523032332d
3개의 변경된 파일29개의 추가작업 그리고 12개의 파일을 삭제
  1. 25 8
      TEAMModelOS/Controllers/Core/StudentInfoController.cs
  2. 2 2
      TEAMModelOS/appsettings.Development.json
  3. 2 2
      TEAMModelOS/appsettings.json

+ 25 - 8
TEAMModelOS/Controllers/Core/StudentInfoController.cs

@@ -14,7 +14,7 @@ namespace TEAMModelOS.Controllers.Core
 {
     [Route("api/[controller]")]
     [ApiController]
-    [Authorize]
+   // [Authorize]
     public class StudentInfoController :BaseController
     {
         private readonly IAzureCosmosDBRepository azureCosmosDBRepository;
@@ -42,8 +42,8 @@ namespace TEAMModelOS.Controllers.Core
             }
             List<StudentInfo> studentInfos = new List<StudentInfo>();
             foreach (string key in dictInfo.Keys) {
-               List<Classroom> classroom= await azureCosmosDBRepository.FindByparams<Classroom>(new Dictionary<string, object> { { "ClassroomCode",key } });
-                if (classroom.IsEmpty()) {
+                List<Classroom> classroom= await azureCosmosDBRepository.FindByparams<Classroom>(new Dictionary<string, object> { { "ClassroomCode", key } });
+                if (classroom.IsNotEmpty()) {
                     dictInfo.TryGetValue(key, out List<StudentInfo> sts);
                     sts.ForEach(x => { x.GradeCode = classroom[0].Grade;
                         x.PeriodCode = classroom[0].Period;
@@ -56,18 +56,35 @@ namespace TEAMModelOS.Controllers.Core
             return builder.Data(studentInfos).build();
         }
         
-        [HttpPost("UpdateAllStudentInfo")]
-        public async Task<BaseJosnRPCResponse> UpdateAllStudentInfo(JosnRPCRequest<StudentInfo> request)
+        [HttpPost("UpdateStudentInfo")]
+        public async Task<BaseJosnRPCResponse> UpdateStudentInfo(JosnRPCRequest<StudentInfo> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             StudentInfo data = await azureCosmosDBRepository.Update<StudentInfo>(request.@params);
             return builder.Data(data).build();
         }
-        [HttpPost("DeleteALlStudentInfo")]
-        public async Task<BaseJosnRPCResponse> UpdateStudentInfo(JosnRPCRequest<StudentInfo> request)
+        [HttpPost("UpdateAllStudentInfo")]
+        public async Task<BaseJosnRPCResponse> DeleteALlStudentInfo(JosnRPCRequest<Dictionary<string, Dictionary<string,object>>> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            StudentInfo data = await azureCosmosDBRepository.Update<StudentInfo>(request.@params);
+            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; 
+            if (find && update) {
+                data = await azureCosmosDBRepository.UpdateAll<StudentInfo>(findObj, updateObj);
+            }
+            return builder.Data(data).build();
+        }
+        /// <summary>
+        /// 根据ID删除
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("DeleteStudentInfo")]
+        public async Task<BaseJosnRPCResponse> DeleteStudentInfo(JosnRPCRequest<string> request)
+        {
+            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
+             string data = await azureCosmosDBRepository.DeleteAsync<StudentInfo>(request.@params);
             return builder.Data(data).build();
         }
     }

+ 2 - 2
TEAMModelOS/appsettings.Development.json

@@ -18,8 +18,8 @@
       "AzureTableDialect": ""
     },
     "CosmosDB": {
-      "ConnectionString": "https://localhost:8081",
-      "ConnectionKey": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
+      "ConnectionString": "https://teammodelostest.documents.azure.cn:443/",
+      "ConnectionKey": "ReGoiHuTbU4Q31YYq4NaiormE6Ci71piT7OrvTzAuhrlgt63ajdtDZmwOZKzcz6gnwR326mJp53InY7rohepQQ==",
       "Database": "TEAMModelOS",
       "AzureTableDialect": "",
       "CollectionThroughput": 400

+ 2 - 2
TEAMModelOS/appsettings.json

@@ -18,8 +18,8 @@
       "AzureTableDialect": ""
     },
     "CosmosDB": {
-      "ConnectionString": "https://localhost:8081",
-      "ConnectionKey": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
+      "ConnectionString": "https://teammodelos.documents.azure.cn:443/",
+      "ConnectionKey": "clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==",
       "Database": "TEAMModelOS",
       "AzureTableDialect": "",
       "CollectionThroughput": 400