|
@@ -13,6 +13,7 @@ using System.Text.Json;
|
|
|
using TEAMModelOS.Models;
|
|
|
using TEAMModelOS.SDK.Extension.SnowFlake;
|
|
|
using TEAMModelOS.SDK.Helper.Security.TmdCrypt;
|
|
|
+using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Syllabus
|
|
|
{
|
|
@@ -21,8 +22,8 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
// [Authorize]
|
|
|
public class StudentController : BaseController
|
|
|
{
|
|
|
- private readonly IAzureCosmosDBRepository azureCosmosDBRepository;
|
|
|
- public StudentController(IAzureCosmosDBRepository _azureCosmosDBRepository)
|
|
|
+ private readonly IAzureCosmosDBV3Repository azureCosmosDBRepository;
|
|
|
+ public StudentController(IAzureCosmosDBV3Repository _azureCosmosDBRepository)
|
|
|
{
|
|
|
azureCosmosDBRepository = _azureCosmosDBRepository;
|
|
|
}
|
|
@@ -57,7 +58,7 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
if (request.@params.TryGetValue("schoolCode", out object _))
|
|
|
{
|
|
|
- List<Student> data = await azureCosmosDBRepository.FindByDict<Student>(request.@params,false);
|
|
|
+ List<Student> data = await azureCosmosDBRepository.FindByDict<Student>(request.@params);
|
|
|
return builder.Data(data).build();
|
|
|
}
|
|
|
else
|
|
@@ -77,7 +78,7 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
List<Student> students = new List<Student>();
|
|
|
foreach (string key in dictInfo.Keys)
|
|
|
{
|
|
|
- List<Classroom> classrooms = await azureCosmosDBRepository.FindByDict<Classroom>(new Dictionary<string, object> { { "classroomCode", key } } ,true);
|
|
|
+ List<Classroom> classrooms = await azureCosmosDBRepository.FindByDict<Classroom>(new Dictionary<string, object> { { "classroomCode", key } } );
|
|
|
if (classrooms.IsNotEmpty())
|
|
|
{
|
|
|
long createDate = DateTimeOffset.UtcNow.Ticks;
|
|
@@ -131,16 +132,12 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
return builder.Data(data).build();
|
|
|
}
|
|
|
[HttpPost("UpdateAllStudent")]
|
|
|
- public async Task<BaseJosnRPCResponse> UpdateAllStudent(JosnRPCRequest<Dictionary<string, Dictionary<string, object>>> request)
|
|
|
+ public async Task<BaseJosnRPCResponse> UpdateAllStudent(JosnRPCRequest<List<Student>> 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<Student> data = null;
|
|
|
- if (find && update)
|
|
|
- {
|
|
|
- data = await azureCosmosDBRepository.UpdateAll<Student>(findObj, updateObj);
|
|
|
- }
|
|
|
+ //bool find = request.@params.TryGetValue("find", out Dictionary<string, object> findObj);
|
|
|
+ //bool update = request.@params.TryGetValue("update", out Dictionary<string, object> updateObj);
|
|
|
+ List<Student> data = await azureCosmosDBRepository.UpdateAll<Student>(request.@params);
|
|
|
return builder.Data(data).build();
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -152,7 +149,7 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
public async Task<BaseJosnRPCResponse> DeleteStudentInfo(JosnRPCRequest<Student> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
- string data = await azureCosmosDBRepository.DeleteAsync<Student>(request.@params.id, request.@params.schoolCode);
|
|
|
+ Student data = await azureCosmosDBRepository.DeleteAsync<Student>(request.@params.id, request.@params.schoolCode);
|
|
|
return builder.Data(data).build();
|
|
|
} /// <summary>
|
|
|
/// 根据ID删除
|
|
@@ -163,8 +160,9 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
public async Task<BaseJosnRPCResponse> DeleteStudentInfo(JosnRPCRequest<Dictionary<string,object>> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
- List<Student> data = await azureCosmosDBRepository.DeleteAll<Student>(request.@params);
|
|
|
- return builder.Data(data).build();
|
|
|
+ List<Student> students= await azureCosmosDBRepository.FindByDict<Student>(request.@params);
|
|
|
+ await azureCosmosDBRepository.DeleteAll<Student>(students);
|
|
|
+ return builder.build();
|
|
|
}
|
|
|
}
|
|
|
}
|