|
@@ -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();
|
|
|
}
|
|
|
}
|