|
@@ -9,6 +9,8 @@ using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
|
+using TEAMModelOS.SDK.Helper.Common.LogHelper;
|
|
|
|
+using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
|
|
using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
|
|
using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
|
|
using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
|
|
using TEAMModelOS.Service.Models.Core;
|
|
using TEAMModelOS.Service.Models.Core;
|
|
@@ -213,19 +215,19 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 获取学校知识点
|
|
|
|
|
|
+ /// 获取知识
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- [HttpPost("FindSchoolPointByDict")]
|
|
|
|
|
|
+ [HttpPost("FindKnowledge")]
|
|
public async Task<BaseJosnRPCResponse> FindSchoolPointByDict(JosnRPCRequest<Dictionary<string, object>> request)
|
|
public async Task<BaseJosnRPCResponse> FindSchoolPointByDict(JosnRPCRequest<Dictionary<string, object>> request)
|
|
{
|
|
{
|
|
// request.@params.TryAdd("PartitionKey", request.lang);
|
|
// request.@params.TryAdd("PartitionKey", request.lang);
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
- List<SchoolPoint> data = new List<SchoolPoint>();
|
|
|
|
- if (request.@params != null && request.@params.TryGetValue("subjectCode", out _) && request.@params.TryGetValue("period", out _) && request.@params.TryGetValue("schoolCode", out _))
|
|
|
|
|
|
+ List<Knowledge> data = new List<Knowledge>();
|
|
|
|
+ if (request.@params != null)
|
|
{
|
|
{
|
|
- data = await _cosmos.FindByParams<SchoolPoint>(request.@params);
|
|
|
|
|
|
+ data = await _cosmos.FindByParams<Knowledge>(request.@params);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -234,60 +236,34 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
return builder.Data(data.OrderBy(m => m.order)).Extend(new Dictionary<string, object> { { "count", data.Count } }).build();
|
|
return builder.Data(data.OrderBy(m => m.order)).Extend(new Dictionary<string, object> { { "count", data.Count } }).build();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 获取学校的知识块及包含的知识点
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="request"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- [HttpPost("FindSchoolBlockAndPointByDict")]
|
|
|
|
- public async Task<BaseJosnRPCResponse> FindSchoolBlockAndPointByDict(JosnRPCRequest<KnowledgeDto> request)
|
|
|
|
- {
|
|
|
|
- JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
- List<SchoolBlock> data = new List<SchoolBlock>();
|
|
|
|
- if (request.@params != null && request.@params.PointParams.TryGetValue("subjectCode", out _) && request.@params.PointParams.TryGetValue("period", out _) && request.@params.PointParams.TryGetValue("schoolCode", out _))
|
|
|
|
- {
|
|
|
|
- data = await _cosmos.FindByDict<SchoolBlock>(request.@params.PointParams, true);//;knowledgeService.FindSchoolBlockAndPointByDict(request.@params);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- builder.Error("'SubjectCode' or 'SchoolCode' is null or empty!", "'SubjectCode' or 'SchoolCode' is null or empty!");
|
|
|
|
- }
|
|
|
|
- return builder.Data(data).Extend(new Dictionary<string, object> { { "count", data.Count } }).build();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 保存或更新学校知识块及知识点
|
|
|
|
|
|
+ /// 保存或更新知识
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- [HttpPost("SaveOrUpdateSchoolBlock")]
|
|
|
|
- public async Task<BaseJosnRPCResponse> SaveOrUpdateSchoolBlock(JosnRPCRequest<List<SchoolBlock>> request)
|
|
|
|
|
|
+ [HttpPost("SaveOrUpdateKnowledge")]
|
|
|
|
+ public async Task<BaseJosnRPCResponse> SaveOrUpdateSchoolBlock(JosnRPCRequest<List<Knowledge>> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
- long CreateTime = DateTimeOffset.Now.Ticks;
|
|
|
|
if (request.@params.IsNotEmpty())// != null )
|
|
if (request.@params.IsNotEmpty())// != null )
|
|
{
|
|
{
|
|
- List<SchoolBlock> schoolBlocks = request.@params;
|
|
|
|
- List<ResourceReference> resourceReferences = new List<ResourceReference>();
|
|
|
|
- foreach (SchoolBlock item in schoolBlocks)
|
|
|
|
|
|
+ List<Knowledge> schoolBlocks = request.@params;
|
|
|
|
+ foreach (Knowledge item in schoolBlocks)
|
|
{
|
|
{
|
|
if (item.id == null)
|
|
if (item.id == null)
|
|
{
|
|
{
|
|
- item.id = item.schoolCode + "-" + item.subjectCode + "-" + item.knowledgeId.Replace("-", "");
|
|
|
|
- }
|
|
|
|
- foreach (SchoolPoint schoolPoint in item.points)
|
|
|
|
- {
|
|
|
|
- if (schoolPoint.id == null)
|
|
|
|
|
|
+ if (item.scope == "personal")
|
|
{
|
|
{
|
|
- schoolPoint.id = schoolPoint.schoolCode + "-" + schoolPoint.subjectCode + "-" + schoolPoint.knowledgeId.Replace("-", "");
|
|
|
|
|
|
+ item.id = item.partitionKey + item.TEAMModelId + item.knowledgeId;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ item.id = item.partitionKey + "-" + item.subjectCode + "-" + item.knowledgeId.Replace("-", "");
|
|
}
|
|
}
|
|
- ResourceReferenceAdd(schoolPoint.id, "SchoolPoint", item.id, "SchoolBlock", CreateTime, resourceReferences);
|
|
|
|
|
|
+
|
|
|
|
+ item.id = ShaHashHelper.GetSHA1(item.id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (resourceReferences.Count > 0) await _table.SaveOrUpdateAll(resourceReferences);
|
|
|
|
- List<SchoolBlock> ts = await _cosmos.SaveAll(schoolBlocks);
|
|
|
|
|
|
+ List<Knowledge> ts = await _cosmos.SaveAll(schoolBlocks);
|
|
if (ts.Count > 0) builder.Data(ts).Extend(new Dictionary<string, object> { { "count", ts.Count } });
|
|
if (ts.Count > 0) builder.Data(ts).Extend(new Dictionary<string, object> { { "count", ts.Count } });
|
|
else builder.Error(false, ResponseCode.FAILED, "失败");
|
|
else builder.Error(false, ResponseCode.FAILED, "失败");
|
|
}
|
|
}
|
|
@@ -295,97 +271,15 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 手动添加学校的私有知识点
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="request"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- [HttpPost("SaveOrUpdateAllSchoolPoint")]
|
|
|
|
- public async Task<BaseJosnRPCResponse> SaveOrUpdateAllSchoolPoint(JosnRPCRequest<List<SchoolPoint>> request)
|
|
|
|
- {
|
|
|
|
- JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
- if (request.@params.IsNotEmpty())// != null&& request.@params.Count > 0)
|
|
|
|
- {
|
|
|
|
- List<SchoolPoint> schoolBlocks = request.@params;
|
|
|
|
- foreach (SchoolPoint item in schoolBlocks)
|
|
|
|
- {
|
|
|
|
- item.id = item.schoolCode + "-" + item.subjectCode + "-" + item.knowledgeId.Replace("-", "");
|
|
|
|
- //item.source = 1;
|
|
|
|
- SchoolSaveOrUpdate<SchoolPoint> schoolSaveOrUpdate = SaveOrUpdate<SchoolPoint>;
|
|
|
|
- string data = await schoolSaveOrUpdate(item, _cosmos);
|
|
|
|
- if (!data.Equals(""))
|
|
|
|
- {
|
|
|
|
- builder.Data(data);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- builder.Error(false, ResponseCode.FAILED, "失败");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return builder.build();
|
|
|
|
- }
|
|
|
|
- else return builder.Error(false, ResponseCode.PARAMS_ERROR, "参数为空").build();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private static async Task<string> SaveOrUpdate<T>(dynamic schoolBlock, IAzureCosmosDBRepository _cosmos)
|
|
|
|
- {
|
|
|
|
- Type t = typeof(T);
|
|
|
|
- string message = "";
|
|
|
|
- List<T> schoolBlocks = await _cosmos.FindByDict<T>(new Dictionary<string, object> {
|
|
|
|
- { "id", t.GetProperty("id").GetValue(schoolBlock) }
|
|
|
|
- });
|
|
|
|
- if (schoolBlocks.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- for (int i = 0; i < schoolBlocks.Count; i++)
|
|
|
|
- {
|
|
|
|
- schoolBlocks[i] = schoolBlock;
|
|
|
|
- string id = schoolBlocks[i].GetType().GetProperty("id").GetValue(schoolBlocks[i]).ToString();
|
|
|
|
- string key = await _cosmos.ReplaceObject(schoolBlocks[i], id);
|
|
|
|
- if (key.Equals(id))
|
|
|
|
- {
|
|
|
|
- message = "修改成功";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- T a = await _cosmos.Save<T>(schoolBlock);
|
|
|
|
- if (a != null)
|
|
|
|
- {
|
|
|
|
- message = "新增成功";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return message;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 删除学校知识点
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="request"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- [HttpPost("DeleteSchoolPoint")]
|
|
|
|
- public async Task<BaseJosnRPCResponse> DeleteSchoolPoint(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
|
- {
|
|
|
|
- JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
- DeleteDelegate<SchoolPoint> deleteDelegate1 = Delete<SchoolPoint>;
|
|
|
|
- await deleteDelegate1(request, builder);
|
|
|
|
- return builder.build();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 删除学校知识块
|
|
|
|
|
|
+ /// 删除知识
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- [HttpPost("DeleteSchoolBlock")]
|
|
|
|
|
|
+ [HttpPost("DeleteKnowledge")]
|
|
public async Task<BaseJosnRPCResponse> DeleteSchoolBlock(JosnRPCRequest<Dictionary<string, object>> request)
|
|
public async Task<BaseJosnRPCResponse> DeleteSchoolBlock(JosnRPCRequest<Dictionary<string, object>> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
- DeleteDelegate<SchoolBlock> deleteDelegate1 = Delete<SchoolBlock>;
|
|
|
|
|
|
+ DeleteDelegate<Knowledge> deleteDelegate1 = Delete<Knowledge>;
|
|
await deleteDelegate1(request, builder);
|
|
await deleteDelegate1(request, builder);
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|
|
@@ -394,9 +288,24 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
private async Task Delete<T>(JosnRPCRequest<Dictionary<string, object>> request, JsonRPCResponseBuilder builder)
|
|
private async Task Delete<T>(JosnRPCRequest<Dictionary<string, object>> request, JsonRPCResponseBuilder builder)
|
|
{
|
|
{
|
|
List<T> schoolBlocks = await _cosmos.FindByDict<T>(request.@params,true);
|
|
List<T> schoolBlocks = await _cosmos.FindByDict<T>(request.@params,true);
|
|
|
|
+ Type t = typeof(T);
|
|
if (schoolBlocks.IsNotEmpty())
|
|
if (schoolBlocks.IsNotEmpty())
|
|
{
|
|
{
|
|
- schoolBlocks.ForEach(x => { _cosmos.DeleteAsync<T>(x); });
|
|
|
|
|
|
+ schoolBlocks.ForEach(x => {
|
|
|
|
+ //log4net 日志記錄
|
|
|
|
+ string uuidKey = Guid.NewGuid().ToString();
|
|
|
|
+ string logkey = "【" + uuidKey + "】";
|
|
|
|
+ LogHelper.Info(this,
|
|
|
|
+ logkey
|
|
|
|
+ + "【请求内容】"
|
|
|
|
+ + request.@params
|
|
|
|
+ + "【删除表】"
|
|
|
|
+ + t.Name
|
|
|
|
+ + "【删除内容】"
|
|
|
|
+ + x.ToJson()
|
|
|
|
+ + logkey);
|
|
|
|
+ _cosmos.DeleteAsync<T>(x);
|
|
|
|
+ });
|
|
builder.Data("删除成功");
|
|
builder.Data("删除成功");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -406,9 +315,9 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
[HttpPost("Test")]
|
|
[HttpPost("Test")]
|
|
- public async Task<BaseJosnRPCResponse> Test(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public BaseJosnRPCResponse Test(JosnRPCRequest<Dictionary<string, object>> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
if (request.@params != null)
|
|
if (request.@params != null)
|