|
@@ -103,42 +103,21 @@ namespace TEAMModelOS.Controllers
|
|
shares.ForEach(async x=> {
|
|
shares.ForEach(async x=> {
|
|
await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
|
|
await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
|
|
//发送共编或分享通知
|
|
//发送共编或分享通知
|
|
- if (x.coedit == true) {
|
|
|
|
- Notification notification = new Notification
|
|
|
|
- {
|
|
|
|
- hubName = "hita",
|
|
|
|
- type = "msg",
|
|
|
|
- from = $"ies5:{request.school}",
|
|
|
|
- to = new List<string>() { x.code.Replace("Share-","") },
|
|
|
|
- label = $"coedit_syllabus",
|
|
|
|
- body = new { biz = "coedit", tmdid = x.issuer, schoolcode = $"{request.school}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
|
|
|
|
- expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
|
|
|
|
- };
|
|
|
|
- var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
|
|
|
|
- var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
|
|
|
|
- var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
|
|
|
|
- var location = _option.Location;
|
|
|
|
- var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
|
|
|
|
- }
|
|
|
|
- if (x.share == true)
|
|
|
|
|
|
+ Notification notification = new Notification
|
|
{
|
|
{
|
|
- Notification notification = new Notification
|
|
|
|
- {
|
|
|
|
- hubName = "hita",
|
|
|
|
- type = "msg",
|
|
|
|
- from = $"ies5:{request.school}",
|
|
|
|
- to = new List<string>() { x.code.Replace("Share-", "") },
|
|
|
|
- label = $"share_syllabus",
|
|
|
|
- body = new { biz = "share", tmdid = x.issuer, schoolcode = $"{request.school}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
|
|
|
|
- expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
|
|
|
|
- };
|
|
|
|
- var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
|
|
|
|
- var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
|
|
|
|
- var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
|
|
|
|
- var location = _option.Location;
|
|
|
|
- var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ hubName = "hita",
|
|
|
|
+ type = "msg",
|
|
|
|
+ from = $"ies5:{request.school}",
|
|
|
|
+ to = new List<string>() { x.code.Replace("Share-","") },
|
|
|
|
+ label = $"{x.type}_syllabus",
|
|
|
|
+ body = new { biz = x.type, tmdid = x.issuer, schoolcode = $"{request.school}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
|
|
|
|
+ expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
|
|
|
|
+ };
|
|
|
|
+ var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
|
|
|
|
+ var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
|
|
|
|
+ var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
|
|
|
|
+ var location = _option.Location;
|
|
|
|
+ var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
|
|
});
|
|
});
|
|
await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
|
|
|
|
@@ -196,17 +175,15 @@ namespace TEAMModelOS.Controllers
|
|
volumeId = request.volumeId,
|
|
volumeId = request.volumeId,
|
|
volumeName = request.volumeName,
|
|
volumeName = request.volumeName,
|
|
syllabusName = request.syllabusName,
|
|
syllabusName = request.syllabusName,
|
|
- code = $"Share-{xmd.tmdid}",
|
|
|
|
|
|
+ code = $"Share-{request.type}-{xmd.tmdid}",
|
|
pk = "Share",
|
|
pk = "Share",
|
|
ttl = -1,
|
|
ttl = -1,
|
|
issuer = request.issuer,
|
|
issuer = request.issuer,
|
|
createTime = now,
|
|
createTime = now,
|
|
school = request.school,
|
|
school = request.school,
|
|
scope = request.scope,
|
|
scope = request.scope,
|
|
- coedit = request.coedit,
|
|
|
|
- share = request.share,
|
|
|
|
- cagree = 0,
|
|
|
|
- sagree = 0
|
|
|
|
|
|
+ type =request.type,
|
|
|
|
+ agree = request.agree
|
|
};
|
|
};
|
|
shares.Add(share);
|
|
shares.Add(share);
|
|
});
|
|
});
|
|
@@ -219,7 +196,7 @@ namespace TEAMModelOS.Controllers
|
|
int indx = 0;
|
|
int indx = 0;
|
|
for (int index = 0; index < syllabus.auth.Count; index++)
|
|
for (int index = 0; index < syllabus.auth.Count; index++)
|
|
{
|
|
{
|
|
- if (syllabus.auth[index].tmdid == xmd.tmdid)
|
|
|
|
|
|
+ if (syllabus.auth[index].tmdid == xmd.tmdid && request.type== syllabus.auth[index].type)
|
|
{
|
|
{
|
|
flag = true;
|
|
flag = true;
|
|
indx = index;
|
|
indx = index;
|
|
@@ -233,8 +210,8 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
tmdid = xmd.tmdid,
|
|
tmdid = xmd.tmdid,
|
|
tmdname = xmd.tmdname,
|
|
tmdname = xmd.tmdname,
|
|
- coedit = request.coedit,
|
|
|
|
- share = request.share,
|
|
|
|
|
|
+ type = request.type,
|
|
|
|
+ agree = request.agree,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
//新增
|
|
//新增
|
|
@@ -244,8 +221,8 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
tmdid = xmd.tmdid,
|
|
tmdid = xmd.tmdid,
|
|
tmdname = xmd.tmdname,
|
|
tmdname = xmd.tmdname,
|
|
- coedit = request.coedit,
|
|
|
|
- share = request.share,
|
|
|
|
|
|
+ type = request.type,
|
|
|
|
+ agree = request.agree,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -257,8 +234,8 @@ namespace TEAMModelOS.Controllers
|
|
new SyllabusAuth {
|
|
new SyllabusAuth {
|
|
tmdid = xmd.tmdid,
|
|
tmdid = xmd.tmdid,
|
|
tmdname = xmd.tmdname,
|
|
tmdname = xmd.tmdname,
|
|
- coedit=request.coedit,
|
|
|
|
- share=request.share,
|
|
|
|
|
|
+ type = request.type,
|
|
|
|
+ agree = request.agree,
|
|
}
|
|
}
|
|
};
|
|
};
|
|
});
|
|
});
|
|
@@ -266,20 +243,23 @@ namespace TEAMModelOS.Controllers
|
|
return (syllabus, shares);
|
|
return (syllabus, shares);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// {"code":"教师编码","id":"章节id"}
|
|
|
|
- /// 教师删除自己收到的
|
|
|
|
|
|
+ /// {"code":"教师编码","id":"章节id","type":"coedit/share","opt":"ignore/agree"}
|
|
|
|
+ ///
|
|
|
|
+ /// 教师操作收到的分享及课纲共编, ignore 忽略,需要删除Share 数据 并更新syllabus.auth
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
- [HttpPost("del-share")]
|
|
|
|
|
|
+ [HttpPost("agree-share")]
|
|
// [AuthToken(Roles = "Teacher")]
|
|
// [AuthToken(Roles = "Teacher")]
|
|
- public async Task<IActionResult> DelShare(JsonElement request) {
|
|
|
|
|
|
+ public async Task<IActionResult> AgreeShare(JsonElement request) {
|
|
try {
|
|
try {
|
|
|
|
+ if (!request.TryGetProperty("type", out JsonElement type)) { return BadRequest(); }
|
|
if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
|
|
if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
|
|
if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
|
|
if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
|
|
|
|
+ if (!request.TryGetProperty("opt", out JsonElement opt)) { return BadRequest(); }
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{code}"));
|
|
|
|
|
|
+ Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
|
|
Syllabus syllabus = null;
|
|
Syllabus syllabus = null;
|
|
if (share.scope == "school")
|
|
if (share.scope == "school")
|
|
{
|
|
{
|
|
@@ -293,9 +273,16 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
syllabus.auth.ForEach(x =>
|
|
syllabus.auth.ForEach(x =>
|
|
{
|
|
{
|
|
- if (x.tmdid == $"{code}")
|
|
|
|
|
|
+ if (x.tmdid == $"{code}" && x.type==$"{type}")
|
|
{
|
|
{
|
|
- x.sagree = 0;
|
|
|
|
|
|
+ if ($"{opt}".Equals("ignore"))
|
|
|
|
+ {
|
|
|
|
+ x.agree = 0;
|
|
|
|
+ }
|
|
|
|
+ else if ($"{opt}".Equals("ignore")) {
|
|
|
|
+ x.agree = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -307,109 +294,22 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
|
|
syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
|
|
}
|
|
}
|
|
- return Ok(new { status = 200 });
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/del-share()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
- return Ok(new { status = 500 });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /// <summary>
|
|
|
|
- /// {"code":"教师编码","id":"章节id","agree":1共编同意,2共编拒绝,3分享同意,4分享拒绝}
|
|
|
|
- /// 教师拉取自己收到的分享及共编
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="request"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- [ProducesDefaultResponseType]
|
|
|
|
- [HttpPost("agree")]
|
|
|
|
- // [AuthToken(Roles = "Teacher")]
|
|
|
|
- public async Task<IActionResult> Agree(JsonElement request) {
|
|
|
|
- try {
|
|
|
|
- if (!request.TryGetProperty("agree", out JsonElement agree)) { return BadRequest(); }
|
|
|
|
- if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
|
|
|
|
- if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
|
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
|
- Share share= await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{code}"));
|
|
|
|
- if (agree.ValueKind.Equals(JsonValueKind.Number))
|
|
|
|
|
|
+ if ($"{opt}".Equals("ignore"))
|
|
{
|
|
{
|
|
- int agreeNum = agree.GetInt32();
|
|
|
|
- if (agreeNum == 1)
|
|
|
|
- {
|
|
|
|
- share.cagree = 1;
|
|
|
|
- }
|
|
|
|
- else if (agreeNum == 2)
|
|
|
|
- {
|
|
|
|
- share.cagree = 2;
|
|
|
|
- }
|
|
|
|
- else if (agreeNum == 3)
|
|
|
|
- {
|
|
|
|
- share.sagree = 1;
|
|
|
|
- }
|
|
|
|
- else if (agreeNum == 4)
|
|
|
|
- {
|
|
|
|
- share.sagree = 2;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- return Ok(new { status = 500 });
|
|
|
|
- }
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, $"{id}", new PartitionKey($"Share-{code}"));
|
|
|
|
- Syllabus syllabus = null;
|
|
|
|
- if (share.scope == "school")
|
|
|
|
- {
|
|
|
|
- syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
|
|
|
|
- }
|
|
|
|
- else if (share.scope == "private")
|
|
|
|
- {
|
|
|
|
- syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
|
|
|
|
- }
|
|
|
|
- if (syllabus.auth.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- syllabus.auth.ForEach(x =>
|
|
|
|
- {
|
|
|
|
- if (x.tmdid == $"{code}")
|
|
|
|
- {
|
|
|
|
- if (agreeNum == 1)
|
|
|
|
- {
|
|
|
|
- x.cagree = 1;
|
|
|
|
- }
|
|
|
|
- else if (agreeNum == 2)
|
|
|
|
- {
|
|
|
|
- x.cagree = 2;
|
|
|
|
- }
|
|
|
|
- else if (agreeNum == 3)
|
|
|
|
- {
|
|
|
|
- x.sagree = 1;
|
|
|
|
- }
|
|
|
|
- else if (agreeNum == 4)
|
|
|
|
- {
|
|
|
|
- x.sagree = 2;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (share.scope == "school")
|
|
|
|
- {
|
|
|
|
- syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
|
|
|
|
- }
|
|
|
|
- else if (share.scope == "private")
|
|
|
|
- {
|
|
|
|
- syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
|
|
|
|
- }
|
|
|
|
- return Ok(new { status = 200 });
|
|
|
|
|
|
+ share.agree = 1;
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share,$"{id}", new PartitionKey($"Share-{type}-{code}"));
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else if ($"{opt}".Equals("ignore"))
|
|
{
|
|
{
|
|
- return Ok(new { status = 500 });
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
|
|
}
|
|
}
|
|
- } catch (Exception ex)
|
|
|
|
- {
|
|
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/agree()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ return Ok(new { status = 200 });
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/agree-share()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
return Ok(new { status = 500 });
|
|
return Ok(new { status = 500 });
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// {"code":"教师编码","type":"coedit/share"}
|
|
/// {"code":"教师编码","type":"coedit/share"}
|
|
/// 教师拉取自己收到的分享及共编
|
|
/// 教师拉取自己收到的分享及共编
|
|
@@ -429,18 +329,7 @@ namespace TEAMModelOS.Controllers
|
|
request.TryGetProperty("id", out JsonElement id);
|
|
request.TryGetProperty("id", out JsonElement id);
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
StringBuilder queryText = new StringBuilder("select value(c) from c");
|
|
StringBuilder queryText = new StringBuilder("select value(c) from c");
|
|
- if (type.ValueKind.Equals(JsonValueKind.String) && type.GetString() == "coedit")
|
|
|
|
- {
|
|
|
|
- queryText.Append(" where c.coedit=true");
|
|
|
|
- }
|
|
|
|
- else if (type.ValueKind.Equals(JsonValueKind.String) && type.GetString() == "share")
|
|
|
|
- {
|
|
|
|
- queryText.Append(" where c.share=true");
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/find()\n type== coedit|share 参数必选一个", GroupNames.醍摩豆服務運維群組);
|
|
|
|
- return BadRequest();
|
|
|
|
- }
|
|
|
|
|
|
+ queryText.Append($" where c.type='{type}' ");
|
|
if (id.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(id.GetString())) {
|
|
if (id.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(id.GetString())) {
|
|
queryText.Append($" and c.id='{id}'");
|
|
queryText.Append($" and c.id='{id}'");
|
|
}
|
|
}
|