|
@@ -3,6 +3,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.SDK.Context.Exception;
|
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
|
using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
|
|
@@ -25,6 +26,53 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
cosmosDBV3Repository = _cosmosDBV3Repository;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 保存或更新学习任务
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("upsertTask")]
|
|
|
+ public async Task<BaseJosnRPCResponse> UpsertTask(JosnRPCRequest<LearnTask> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ if (request.@params.createTime <= 0) {
|
|
|
+ request.@params.createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
|
|
|
+ }
|
|
|
+ await cosmosDBV3Repository.Save(request.@params);
|
|
|
+ return builder.Data(request.@params).build();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询学习任务
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("findTask")]
|
|
|
+ public async Task<BaseJosnRPCResponse> FindTask(JosnRPCRequest<Dictionary<string,object>> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ if (request.@params.ContainsKey("id") || request.@params.ContainsKey("code"))
|
|
|
+ {
|
|
|
+ List<LearnTask> tasks = await cosmosDBV3Repository.FindByDict<LearnTask>(request.@params);
|
|
|
+ return builder.Data(tasks).build();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ throw new BizException("参数错误!",ResponseCode.PARAMS_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 删除学习任务
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("deleteTask")]
|
|
|
+ public async Task<BaseJosnRPCResponse> DeleteTask(JosnRPCRequest<IdPk> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ return builder.Data(await cosmosDBV3Repository.DeleteAsync<LearnTask>(request.@params)).build();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 保存或更新学习单元单元
|
|
|
/// </summary>
|
|
@@ -34,7 +82,6 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
public async Task<BaseJosnRPCResponse> UpsertUnit(JosnRPCRequest<LearnUnit> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
-
|
|
|
if (string.IsNullOrEmpty(request.@params.id))
|
|
|
{
|
|
|
request.@params.id = Guid.NewGuid().ToString();
|
|
@@ -86,17 +133,17 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("upsertProcess")]
|
|
|
- public async Task<BaseJosnRPCResponse> UpsertProcess(JosnRPCRequest<LeanProcess> request) {
|
|
|
+ public async Task<BaseJosnRPCResponse> UpsertProcess(JosnRPCRequest<LearnProcess> request) {
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
|
|
if (string.IsNullOrEmpty(request.@params.id))
|
|
|
{
|
|
|
request.@params.id = Guid.NewGuid().ToString();
|
|
|
request.@params.createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
|
|
|
- await cosmosDBV3Repository.Save<LeanProcess>(request.@params);
|
|
|
+ await cosmosDBV3Repository.Save<LearnProcess>(request.@params);
|
|
|
}
|
|
|
else {
|
|
|
- await cosmosDBV3Repository.Update<LeanProcess>(request.@params);
|
|
|
+ await cosmosDBV3Repository.Update<LearnProcess>(request.@params);
|
|
|
}
|
|
|
|
|
|
return builder.Data(request.@params).build();
|
|
@@ -113,7 +160,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
if (request.@params.Keys.Count>0) {
|
|
|
|
|
|
- builder.Data(await cosmosDBV3Repository.FindByDict<LeanProcess>(request.@params));
|
|
|
+ builder.Data(await cosmosDBV3Repository.FindByDict<LearnProcess>(request.@params));
|
|
|
}
|
|
|
|
|
|
return builder.build();
|
|
@@ -130,7 +177,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
if (request.@params != null)
|
|
|
{
|
|
|
- builder.Data(await cosmosDBV3Repository.DeleteAsync<LeanProcess>(request.@params));
|
|
|
+ builder.Data(await cosmosDBV3Repository.DeleteAsync<LearnProcess>(request.@params));
|
|
|
}
|
|
|
return builder.build();
|
|
|
}
|
|
@@ -141,7 +188,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("upsertRecord")]
|
|
|
- public async Task<BaseJosnRPCResponse> UpsertRecord(JosnRPCRequest<List<LeanRecord>> request)
|
|
|
+ public async Task<BaseJosnRPCResponse> UpsertRecord(JosnRPCRequest<List<LearnRecord>> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
if (ValidateHelper.IsValid(request.@params))
|
|
@@ -153,7 +200,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
x.id = new Guid().ToString();
|
|
|
}
|
|
|
});
|
|
|
- List<LeanRecord> leanProcesses = await cosmosDBV3Repository.SaveOrUpdateAll<LeanRecord>(request.@params);
|
|
|
+ List<LearnRecord> leanProcesses = await cosmosDBV3Repository.SaveOrUpdateAll<LearnRecord>(request.@params);
|
|
|
builder.Data(leanProcesses);
|
|
|
}
|
|
|
return builder.build();
|
|
@@ -170,7 +217,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
if (request.@params.Keys.Count > 0)
|
|
|
{
|
|
|
- builder.Data(await cosmosDBV3Repository.FindByDict<LeanRecord>(request.@params));
|
|
|
+ builder.Data(await cosmosDBV3Repository.FindByDict<LearnRecord>(request.@params));
|
|
|
}
|
|
|
return builder.build();
|
|
|
}
|
|
@@ -187,7 +234,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
if (request.@params != null)
|
|
|
{
|
|
|
- builder.Data(await cosmosDBV3Repository.DeleteAsync<LeanRecord>(request.@params));
|
|
|
+ builder.Data(await cosmosDBV3Repository.DeleteAsync<LearnRecord>(request.@params));
|
|
|
}
|
|
|
return builder.build();
|
|
|
}
|