|
@@ -172,14 +172,15 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
var sJson = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
Study study = sJson.ToObject<Study>();
|
|
|
if (response.Status == (int)HttpStatusCode.OK)
|
|
|
- {
|
|
|
+ {
|
|
|
var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
- StudyRecord record = json.ToObject<StudyRecord>();
|
|
|
+ StudyRecord record = json.ToObject<StudyRecord>();
|
|
|
if (!string.IsNullOrEmpty(record.sign))
|
|
|
{
|
|
|
return Ok(new { code = 200, msg = "已经签到" });
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
record.sign = study.startTime < now ? "2" : "1";
|
|
|
record.signTime = now;
|
|
|
}
|
|
@@ -187,14 +188,15 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
+ {
|
|
|
StudyRecord setting = new();
|
|
|
setting.id = id.GetString();
|
|
|
- setting.tId = tmdid;
|
|
|
+ setting.tId = tmdid;
|
|
|
setting.signTime = now;
|
|
|
setting.code = "StudyRecord-" + tmdid;
|
|
|
setting.sign = study.startTime < now ? "2" : "1";
|
|
|
- if (string.IsNullOrEmpty(setting.sign) || setting.signTime == 0) {
|
|
|
+ if (string.IsNullOrEmpty(setting.sign) || setting.signTime == 0)
|
|
|
+ {
|
|
|
return Ok(new { code = 500, msg = "签到失败,请重新签到" });
|
|
|
}
|
|
|
await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(setting, new PartitionKey($"{setting.code}"));
|
|
@@ -204,14 +206,22 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
{
|
|
|
return Ok(new { code = HttpStatusCode.NotFound });
|
|
|
}
|
|
|
+ var srecord = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id.ToString(), new PartitionKey($"StudyRecord-{tmdid}"));
|
|
|
+ if (srecord.Status == (int)HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { code = 500, msg = "签到失败,请重新签到" });
|
|
|
+ }
|
|
|
|
|
|
- return Ok();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},study/sign-in()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
return BadRequest();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|