|
@@ -0,0 +1,69 @@
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
|
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
|
+using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
|
|
|
+using TEAMModelOS.Service.Models.Learn;
|
|
|
+
|
|
|
+namespace TEAMModelOS.Controllers.Learn
|
|
|
+{
|
|
|
+ [Route("api/[controller]")]
|
|
|
+ [ApiController]
|
|
|
+ public class LearnController: BaseController
|
|
|
+ {
|
|
|
+ private readonly IAzureCosmosDBV3Repository cosmosDBV3Repository;
|
|
|
+ public LearnController(IAzureCosmosDBV3Repository _cosmosDBV3Repository)
|
|
|
+ {
|
|
|
+ cosmosDBV3Repository = _cosmosDBV3Repository;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 保存考试信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("SaveUnit")]
|
|
|
+ public async Task<BaseJosnRPCResponse> SaveUnit(JosnRPCRequest<LearnUnit> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(request.@params.id))
|
|
|
+ {
|
|
|
+ request.@params.id = Guid.NewGuid().ToString();
|
|
|
+
|
|
|
+ await cosmosDBV3Repository.SaveOrUpdate(request.@params);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await cosmosDBV3Repository.SaveOrUpdate(request.@params);
|
|
|
+ }
|
|
|
+ return builder.Data(request.@params).build();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询最小单元
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("FindUnit")]
|
|
|
+ public async Task<BaseJosnRPCResponse> FindUnit(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ return builder.Data(await cosmosDBV3Repository.FindByDict<LearnUnit>(request.@params)).build();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 删除最小单元
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("DeleteUnit")]
|
|
|
+ public async Task<BaseJosnRPCResponse> DeleteUnit(JosnRPCRequest<IdPk> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ return builder.Data(await cosmosDBV3Repository.DeleteAsync<LearnUnit>(request.@params)).build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|