123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624 |
- using Azure.Cosmos;
- using Azure.Messaging.ServiceBus;
- using HTEXLib.COMM.Helpers;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.Options;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Text.Json;
- using System.Text.Json.Nodes;
- using System.Threading.Tasks;
- using TEAMModelOS.Filter;
- using TEAMModelOS.Models;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK.Models;
- namespace TEAMModelOS.Controllers
- {
- /// <summary>
- /// 课堂记录
- /// </summary>
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [Route("common/lesson-record")]
- [ApiController]
-
- public class LessonRecordController : ControllerBase
- {
- public static readonly DateTime dateTime1970= new DateTime(1970,1,1).ToLocalTime();
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly SnowflakeId _snowflakeId;
- private readonly AzureServiceBusFactory _serviceBus;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private readonly AzureStorageFactory _azureStorage;
- private readonly AzureRedisFactory _azureRedis;
- public IConfiguration _configuration { get; set; }
- public LessonRecordController(AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing,
- IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, IConfiguration configuration)
- {
- _azureCosmos = azureCosmos;
- _serviceBus = serviceBus;
- _snowflakeId = snowflakeId;
- _dingDing = dingDing;
- _option = option?.Value;
- _azureStorage = azureStorage;
- _azureRedis = azureRedis;
- _configuration = configuration;
- }
- /// <summary>
- /// 更新课堂记录
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("update-lesson-baseinfo")]
- public async Task<IActionResult> UpdateLessonBaseInfo(JsonElement request)
- {
- var client = _azureCosmos.GetCosmosClient();
- if (!request.TryGetProperty("lesson_id", out JsonElement _lessonId)) return BadRequest();
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
- request.TryGetProperty("school", out JsonElement _school);
- if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
- if (!request.TryGetProperty("grant_types", out JsonElement _grant_types)) return BadRequest();
- string tbname ;
- string code ;
- if (_scope.GetString().Equals("school") && !string.IsNullOrWhiteSpace(_school.GetString()))
- {
- code = $"LessonRecord-{_school}";
- tbname = "School";
- }
- else if ($"{_scope}".Equals("private"))
- {
- code = $"LessonRecord-{_tmdid}";
- tbname = "Teacher";
- }
- else
- {
- return BadRequest();
- }
- try
- {
- LessonRecord lessonRecord = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<LessonRecord>($"{_lessonId}", new PartitionKey(code));
- if (_grant_types.ValueKind.Equals(JsonValueKind.Array)) {
- List<LessonUpdate> updates = _grant_types.ToObject<List<LessonUpdate>>();
- if (updates.IsNotEmpty() && updates[0].grant_type.Equals("up-baseinfo"))
- {
- JsonElement element= updates[0].data.ToJsonString().ToObject<JsonElement>();
- element.TryGetProperty("name", out JsonElement _name);
- element.TryGetProperty("subjectId", out JsonElement _subjectId);
- element.TryGetProperty("grade", out JsonElement _grade);
- element.TryGetProperty("category", out JsonElement _category);
- if (_name.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrWhiteSpace($"{_name}"))
- {
- lessonRecord.name = $"{_name}";
- }
- if (_subjectId.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrWhiteSpace($"{_subjectId}"))
- {
- lessonRecord.subjectId = $"{_subjectId}";
- }
- if (_grade.ValueKind.Equals(JsonValueKind.Array))
- {
- lessonRecord.grade = _grade.ToObject<List<string>>();
- }
- if (_category.ValueKind.Equals(JsonValueKind.Array))
- {
- lessonRecord.category = _category.ToObject<List<string>>();
- }
- await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(lessonRecord, $"{_lessonId}", new PartitionKey(code));
- var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
- var messageChange = new ServiceBusMessage(request.ToJsonString());
- messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
- await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
- return Ok(new { status = 200 });
- }
- else
- {
- return BadRequest();
- }
- }
-
- return Ok(new { lessonRecord });
- }
- catch (CosmosException ex) when (ex.Status == 404)
- {
- return BadRequest("课堂记录不存在");
- }
- catch (Exception ex)
- {
- return BadRequest();
- }
- }
- /*
- {
- "scope":"school/private",
- "tmdid":"1595321354",
- "delete_id":"asdeeeqq-adfghnlr-pfkcmsss-ssadffgtre",
- "opt":"delete",
- "school":"hbcn" //如果scope=school 这 school字段必须有值
- }
- */
- /// <summary>
- /// 获取开课记录
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- // [AuthToken(Roles = "teacher,admin")]
- [HttpPost("delete-lesson-record")]
- [Authorize(Roles = "IES")]
- public async Task<IActionResult> DeleteLessonRecord(JsonElement request)
- {
- string lessonId;
- string school;
- string tbname;
- string code;
- if (request.TryGetProperty("delete_id", out JsonElement _delete_id) && !string.IsNullOrEmpty($"{_delete_id}")
- && request.TryGetProperty("tmdid", out JsonElement _dtmdid) && !string.IsNullOrEmpty($"{_dtmdid}")
- && request.TryGetProperty("scope", out JsonElement _dscope) && !string.IsNullOrEmpty($"{_dscope}")
- && request.TryGetProperty("opt", out JsonElement _opt) && !string.IsNullOrEmpty($"{_opt}"))
- {
- request.TryGetProperty("school", out JsonElement _dschool);
- school = $"{_dschool}";
- var client = _azureCosmos.GetCosmosClient();
- if ($"{_opt}".Equals("delete"))
- {
- if ($"{_dscope}".Equals("school") && !string.IsNullOrEmpty($"{school}"))
- {
- code = $"LessonRecord-{school}";
- tbname = "School";
- }
- else if ($"{_dscope}".Equals("private"))
- {
- code = $"LessonRecord-{_dtmdid}";
- tbname = "Teacher";
- }
- else
- {
- return BadRequest() ;
- }
- lessonId = $"{_delete_id}";
- Azure.Response response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync(lessonId, new PartitionKey(code));
- if (response.Status == 200)
- {
- LessonRecord lessonRecord ;
- var doc = JsonDocument.Parse(response.ContentStream);
- lessonRecord = doc.RootElement.ToObject<LessonRecord>();
- lessonRecord.status =404;
- await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(lessonRecord, lessonRecord.id, new PartitionKey(lessonRecord.code));
- var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
- var messageChange = new ServiceBusMessage(request.ToJsonString());
- messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
- await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
- return Ok(new { status = 200 });
- }
- else { return BadRequest(); }
- }
- else { return BadRequest() ; }
- }
- else
- {
- return BadRequest();
- }
- }
- /// <summary>
- /// 获取开课记录 (c.status<>404 or IS_DEFINED(c.status)=false )
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher,admin")]
- [HttpPost("get-lesson-record-count")]
- [Authorize(Roles = "IES")]
- public async Task<IActionResult> GetLessonRecordCont(JsonElement request)
- {
-
- if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
- StringBuilder sql = new StringBuilder();
- sql.Append("select value(count(1)) from c ");
- Dictionary<string ,object> dict = GetLessonCond(request);
- AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
- string tbname = "";
- string code = "";
- if (_scope.GetString().Equals("school"))
- {
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_school}"))
- {
- code = $"LessonRecord-{_school}";
- tbname = "School";
- }
- else {
- return BadRequest();
- }
-
- }
- else if ($"{_scope}".Equals("private"))
- {
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_tmdid}"))
- {
- code = $"LessonRecord-{_tmdid}";
- tbname = "Teacher";
- }
- else
- {
- return BadRequest();
- }
- }
- else
- {
- return BadRequest();
- }
- int count=0;
- cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", " where (c.status<>404 or IS_DEFINED(c.status) = false ) and ");
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<int>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
- {
- count = item;
- }
- return Ok(new { count=count });
- }
- /// <summary>
- /// 获取开课记录
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- // [AuthToken(Roles = "teacher,admin")]
- [HttpPost("get-lesson-record")]
- [Authorize(Roles = "IES")]
- public async Task<IActionResult> GetLessonRecord(JsonElement request)
- {
- if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
- StringBuilder sql = new StringBuilder();
- sql.Append("select value(c) from c ");
- int pageCount = 10;
- Dictionary<string, object> dict = GetLessonCond(request);
- if (request.TryGetProperty("pageCount", out JsonElement _pageCount))
- {
- int.TryParse($"{_pageCount}", out int pcount);
- if (pcount > 0)
- {
- pageCount = pcount;
- }
- }
- if (request.TryGetProperty("DESC", out JsonElement desc))
- {
- dict.Add("@DESC", desc.ToString());
- }
- if (request.TryGetProperty("ASC", out JsonElement asc))
- {
- dict.Add("@ASC", asc.ToString());
- }
- string continuationToken = null;
- if (request.TryGetProperty("continuationToken", out JsonElement _continuationToken))
- {
- if (!string.IsNullOrEmpty($"{_continuationToken}"))
- {
- continuationToken = $"{_continuationToken}";
- }
- }
- AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
- string tbname = "";
- string code = "";
- string school = null;
- if (_scope.GetString().Equals("school"))
- {
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_school}"))
- {
- code = $"LessonRecord-{_school}";
- tbname = "School";
- school = $"{_school}";
- }
- else
- {
- return BadRequest();
- }
- }
- else if ($"{_scope}".Equals("private"))
- {
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_tmdid}"))
- {
- code = $"LessonRecord-{_tmdid}";
- tbname = "Teacher";
- }
- else
- {
- return BadRequest();
- }
- }
- else
- {
- return BadRequest();
- }
- List<LessonRecord> lessonRecords = new List<LessonRecord>();
- try
- {
- cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", " where (c.status<>404 or IS_DEFINED(c.status) = false ) and ");
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
- .GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, continuationToken: continuationToken,
- requestOptions: new QueryRequestOptions() { MaxItemCount = pageCount, PartitionKey = new PartitionKey(code) }))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- lessonRecords.Add(obj.ToObject<LessonRecord>());
- }
- continuationToken = item.GetContinuationToken();
- break;
- }
- }
- var tmdids = lessonRecords.Select(x => x.tmdid).ToHashSet();
- if (tmdids != null && tmdids.Count > 0)
- {
- List<IdNameCode> codes = new List<IdNameCode>();
- string sqltmd = $"select c.id,c.name,c.picture from c where c.id in ({string.Join(",", tmdids.Select(x => $"'{x}'"))})";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<IdNameCode>(queryText: sqltmd, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- codes.Add(item);
- }
- if (codes.IsNotEmpty())
- {
- lessonRecords.ForEach(x => {
- var tmd = codes.Find(z => z.id.Equals(x.tmdid));
- if (tmd != null)
- {
- x.tmdname = tmd.name;
- x.tmdpicture = tmd.picture;
- }
- });
- }
- }
- var groupIds = lessonRecords.SelectMany(x => x.groupIds);
- if (groupIds.Any()) {
- List<GroupListDto> groupLists= await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school);
- lessonRecords.ForEach(x => {
- List<string> groupNmae = new List<string>();
- x.groupIds.ForEach(y => {
- var dto= groupLists.Find(z => z.id.Equals(y));
- string name = dto != null ? dto.name : "-";
- groupNmae.Add(name);
- });
- x.groupIds = groupNmae;
- });
- }
- return Ok(new { currCount = lessonRecords.Count, continuationToken, lessonRecords });
- }
- catch (Exception ex)
- {
- continuationToken = null;
- return Ok(new { currCount = 0, continuationToken = continuationToken, lessonRecords });
- }
- }
- /// <summary>
- /// 获取开课记录
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- // [AuthToken(Roles = "teacher,admin")]
- [HttpPost("get-other-lesson-record")]
- [Authorize(Roles = "IES")]
- public async Task<IActionResult> GetOtherLessonRecord(JsonElement request)
- {
- if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
- string tbname = "";
- string code = "";
- if (_scope.GetString().Equals("school") )
- {
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_school}"))
- {
- code = $"LessonRecord-{_school}";
- tbname = "School";
- }
- else
- {
- return BadRequest();
- }
- }
- else if ($"{_scope}".Equals("private"))
- {
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_tmdid}"))
- {
- code = $"LessonRecord-{_tmdid}";
- tbname = "Teacher";
- }
- else {
- return BadRequest();
- }
- }
- else
- {
- return BadRequest();
- }
- request.TryGetProperty("periodId", out JsonElement _periodId);
- request.TryGetProperty("stime", out JsonElement _stime);
- request.TryGetProperty("etime", out JsonElement _etime);
- //优质课程
- var excellent = new JsonObject
- {
- ["excellent"] = true,
- ["periodId"] = $"{_periodId}",
- ["stime"] = $"{_stime}",
- ["etime"] = $"{_etime}",
- }.ToJsonString().ToObject<JsonElement>();
- //专家好客
- var doubleGreen = new JsonObject
- {
- ["doubleGreen"] = true,
- ["periodId"] = $"{_periodId}",
- ["stime"] = $"{_stime}",
- ["etime"] = $"{_etime}",
- }.ToJsonString().ToObject<JsonElement>();
- //今日课程
- var today = new JsonObject
- {
- ["today"] = true,
- ["periodId"] = $"{_periodId}",
- }.ToJsonString().ToObject<JsonElement>();
- List<LessonRecord> excellentRcd =await GetOtherLessonCond(excellent, code, tbname);
- List<LessonRecord> doubleGreenRcd = await GetOtherLessonCond(doubleGreen, code, tbname);
- List<LessonRecord> todayRcd = await GetOtherLessonCond(today, code, tbname);
- try {
- var tmdids_excellent = excellentRcd.Select(x => x.tmdid);
- var tmdids_doubleGreen = excellentRcd.Select(x => x.tmdid);
- var tmdids_today = excellentRcd.Select(x => x.tmdid);
- List<string> tmdids=new List<string>();
- tmdids.AddRange(tmdids_excellent);
- tmdids.AddRange(tmdids_doubleGreen);
- tmdids.AddRange(tmdids_today);
- if (tmdids != null && tmdids.Count > 0) {
- List< IdNameCode > codes= new List<IdNameCode> ();
- string sqltmd = $"select c.id,c.name,c.picture from c where c.id in ({string.Join(",", tmdids.Select(x => $"'{x}'"))})";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<IdNameCode>(queryText:sqltmd,requestOptions:new QueryRequestOptions { PartitionKey=new PartitionKey("Base") })){
- codes.Add(item);
- }
- if (codes.IsNotEmpty()) {
- excellentRcd.ForEach(x => {
- var tmd= codes.Find(z => z.id.Equals(x.tmdid));
- if (tmd != null) {
- x.tmdname = tmd.name;
- x.tmdpicture= tmd.picture;
- }
- });
- doubleGreenRcd.ForEach(x => {
- var tmd = codes.Find(z => z.id.Equals(x.tmdid));
- if (tmd != null)
- {
- x.tmdname = tmd.name;
- x.tmdpicture = tmd.picture;
- }
- });
- todayRcd.ForEach(x => {
- var tmd = codes.Find(z => z.id.Equals(x.tmdid));
- if (tmd != null)
- {
- x.tmdname = tmd.name;
- x.tmdpicture = tmd.picture;
- }
- });
- }
- }
- return Ok(new { excellentRcd , doubleGreenRcd, todayRcd });
- } catch (Exception ex) {
- return Ok(new { excellentRcd, doubleGreenRcd, todayRcd });
- }
- }
- private async Task<List<LessonRecord>> GetOtherLessonCond(JsonElement request,string code ,string tbname ) {
- StringBuilder sql = new StringBuilder();
- sql.Append("select value(c) from c ");
- Dictionary<string, object> dict = GetLessonCond(request);
- AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
- List<LessonRecord> lessonRecords = new List<LessonRecord>();
- cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", " where (c.status<>404 or IS_DEFINED(c.status) = false ) and ");
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
- .GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition,
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- lessonRecords.Add(obj.ToObject<LessonRecord>());
- }
- }
- }
- return lessonRecords;
- }
- private Dictionary<string, object> GetLessonCond(JsonElement request)
- {
- Dictionary<string, object> dict = new Dictionary<string, object>();
- if (request.TryGetProperty("tmdid", out JsonElement tmdid) && !string.IsNullOrWhiteSpace($"{tmdid}"))
- {
- dict.Add("tmdid", tmdid);
- }
- if (request.TryGetProperty("courseId", out JsonElement courseId) && !string.IsNullOrWhiteSpace($"{courseId}"))
- {
- dict.Add("courseId", courseId);
- }
- if (request.TryGetProperty("periodId", out JsonElement periodId) && !string.IsNullOrWhiteSpace($"{periodId}"))
- {
- dict.Add("periodId", periodId);
- }
- if (request.TryGetProperty("subjectId", out JsonElement subjectId))
- {
- dict.Add("subjectId[*]", subjectId);
- }
- if (request.TryGetProperty("groupIds", out JsonElement groupIds))
- {
- dict.Add("groupIds[*]", groupIds);
- }
- if (request.TryGetProperty("grade", out JsonElement grade))
- {
- dict.Add("grade[*]", grade);
- }
- if (request.TryGetProperty("category", out JsonElement category))
- {
- dict.Add("category[*]", category);
- }
- if (request.TryGetProperty("doubleGreen", out JsonElement doubleGreen) && doubleGreen.GetBoolean())
- {
- dict.Add(">=.tScore", 70);
- dict.Add(">=.pScore", 70);
- }
- if (request.TryGetProperty("quality", out JsonElement quality) && quality.GetBoolean())
- {
- dict.Add(">=.discuss", 1);
- }
- if (request.TryGetProperty("excellent", out JsonElement excellent) && excellent.GetBoolean())
- {
- dict.Add(">=.excellent", 1);
- }
- if (request.TryGetProperty("name", out JsonElement name) && !string.IsNullOrWhiteSpace($"{name}"))
- {
- dict.Add("$.name", name);
- }
- if (request.TryGetProperty("today", out JsonElement today) && today.GetBoolean())
- {
- DateTime dateTimeA= Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
- DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(1);
- double dayOf00_00_00= (dateTimeA - dateTime1970).TotalMilliseconds;
- double day1Of00_00_00 = (dateTimeB - dateTime1970).TotalMilliseconds;
- dict.Add(">=.startTime", dayOf00_00_00);
- dict.Add("<.startTime", day1Of00_00_00);
- }
- if (request.TryGetProperty("stime", out JsonElement stime) && !string.IsNullOrWhiteSpace($"{stime}"))
- {
- dict.Add(">=.startTim", stime);
- }
- if (request.TryGetProperty("etime", out JsonElement etime) && !string.IsNullOrWhiteSpace($"{etime}"))
- {
- dict.Add("<=.startTim", etime);
- }
- return dict;
- }
- }
- }
|