1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237 |
-
- using Azure.Cosmos;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Options;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.Json;
- using System.Threading.Tasks;
- using TEAMModelOS.Models;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK.Extension;
- using static TEAMModelOS.Controllers.SchoolTeacherController;
- using HTEXLib.COMM.Helpers;
- using TEAMModelOS.Filter;
- using Azure;
- using Azure.Messaging.ServiceBus;
- using Microsoft.Extensions.Configuration;
- namespace TEAMModelOS.Controllers
- {
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- //[Authorize(Roles = "IES5")]
- [Route("research/ability")]
- [ApiController]
- public class AbilitySubController : ControllerBase
- {
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly SnowflakeId _snowflakeId;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private readonly ThirdApisService _thirdApisService;
- private readonly HttpTrigger _httpTrigger;
- private readonly AzureServiceBusFactory _serviceBus;
- public IConfiguration _configuration { get; set; }
- public AbilitySubController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, ThirdApisService thirdApisService, HttpTrigger httpTrigge, AzureServiceBusFactory serviceBus, IConfiguration configuration)
- {
- _azureCosmos = azureCosmos;
- _snowflakeId = snowflakeId;
- _dingDing = dingDing;
- _option = option?.Value;
- _thirdApisService = thirdApisService;
- _httpTrigger = httpTrigge;
- _serviceBus = serviceBus;
- _configuration = configuration;
- }
-
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("save-subs")]
- [AuthToken(Roles = "teacher,admin,area")]
- public async Task<IActionResult> SaveSubs(JsonElement request)
- {
- try
- {
- (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
- if (string.IsNullOrEmpty(school))
- {
- if (!request.TryGetProperty("school", out JsonElement _school))
- {
- return BadRequest();
- }
- else
- {
- school = $"{_school}";
- }
- }
- var client = _azureCosmos.GetCosmosClient();
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
- if (!request.TryGetProperty("abilityIds", out JsonElement _abilityIds)) return BadRequest();
- List<string> abilityIds = _abilityIds.ToObject<List<string>>();
- foreach (var abilityId in abilityIds)
- {
- if (!string.IsNullOrEmpty(abilityId))
- {
- string code = $"AbilitySub-{school}-{_tmdid}";
- try
- {
- await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<AbilitySub>(abilityId, new PartitionKey(code));
- }
- catch (CosmosException ex)
- {
- if (ex.Status == 404)
- {
- AbilitySub abilitySub = new AbilitySub
- {
- id = abilityId,
- code = $"AbilitySub-{school}-{_tmdid}",
- school = $"{school}",
- creatorId = $"{_tmdid}",
- done = false,
- hour = 0,
- comid = Guid.NewGuid().ToString(),
- pk = "AbilitySub"
- };
- await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(abilitySub, new PartitionKey(abilitySub.code));
- }
- }
- }
- }
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
- await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{school}",new List<string> { StatisticsService.TeacherAility }, 0) }, _configuration, _serviceBus);
- return Ok(new { abilityIds });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},AbilityController/SaveSubs()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- /// <summary>
- ///当前老师 获取没有订阅以及已经订阅的能力点学习课程
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [AuthToken(Roles = "teacher,admin,area")]
- [HttpPost("get-subs")]
- public async Task<IActionResult> GetSubs(JsonElement request)
- {
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return Ok(new { error = 400 });
- ///没有订阅的
- List<Ability> notSub = new List<Ability>();
- ///已经订阅的
- List<Ability> hadSubs = new List<Ability>();
- ///订阅的学习记录
- List<AbilitySub> rcdSubs = new List<AbilitySub>();
- //必修
- List<Ability> currencyAb1 = new List<Ability>();
- //通识
- List<Ability> currencyAb2 = new List<Ability>();
- //tmdid
- if (!request.TryGetProperty("tmdid", out JsonElement tmdid)) return Ok(new { error = 400 });
- //学校编码
- (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
- if (string.IsNullOrEmpty(school))
- {
- if (!request.TryGetProperty("school", out JsonElement _school))
- {
- return Ok(new { error = 400 });
- }
- else
- {
- school = $"{_school}";
- }
- }
- if (!string.IsNullOrEmpty(school))
- {
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
- .GetItemQueryIterator<Ability>(queryText: $"select value(c) from c where c.status = 1 ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
- {
- notSub.Add(item);
- if (item.currency == 2)
- {
- currencyAb2.Add(item);
- }
- if (item.currency == 1)
- {
- currencyAb1.Add(item);
- }
- }
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
- .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{tmdid}") }))
- {
- var had = notSub.Where(x => x.id.Equals(item.id)).FirstOrDefault();
- if (had != null)
- {
- notSub.Remove(had);
- hadSubs.Add(had);
- }
- rcdSubs.Add(item);
- }
- }
- else
- {
- return Ok(new { error = 400 });
- };
- (string accessConfig, Area area, AreaSetting setting) = await ThirdService.GetAccessConfig(client, $"{standard}");
- //automatic,自动分配系统设置的=0,manual手动挑选的=1
- int from = 0;
- //未对接其他平台。有对接其他平台则必修。
- if (!string.IsNullOrEmpty(accessConfig))
- {
- Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
- HashSet<string> pxid = teacher.binds.SelectMany(x => x.pxid).ToHashSet();
- var abilitys = await ThirdService.GetDiagnosisList(client, $"{standard}", _dingDing, setting, _httpTrigger, pxid, _option);
- if (abilitys != null)
- {
- abilitys.ForEach(x => { x.currency = 1; });
- currencyAb1 = abilitys;
- //同时处理 原有设置必修的能力点。
- hadSubs.FindAll(x => x.currency == 1).ForEach(y => { y.currency = 0; });
- from = 1;
- }
- else
- {
- currencyAb1 = null;
- }
- }
- //通识
- foreach (var item in currencyAb2)
- {
- var had = hadSubs.Where(x => x.id.Equals(item.id)).FirstOrDefault();
- if (had == null)
- {
- hadSubs.Add(item);
- AbilitySub abilitySub = new AbilitySub
- {
- id = item.id,
- code = $"AbilitySub-{school}-{id}",
- school = $"{school}",
- creatorId = $"{id}",
- done = false,
- hour = 0,
- comid = Guid.NewGuid().ToString(),
- pk = "AbilitySub" ,
- from = 0,
- currency = item.currency
- };
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(abilitySub, new PartitionKey(abilitySub.code));
- }
- }
- if (currencyAb1 != null)
- {
- //必修
- foreach (var item in currencyAb1)
- {
- var had = hadSubs.Where(x => x.id.Equals(item.id)).FirstOrDefault();
- if (had == null)
- {
- hadSubs.Add(item);
- AbilitySub abilitySub = new AbilitySub
- {
- id = item.id,
- code = $"AbilitySub-{school}-{id}",
- school = $"{school}",
- creatorId = $"{id}",
- done = false,
- hour = 0,
- comid = Guid.NewGuid().ToString(),
- pk = "AbilitySub",
- from=from,
- currency = item.currency
- };
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(abilitySub, new PartitionKey(abilitySub.code));
- }
- }
- }
- return Ok(new { rcdSubs, hadSubs });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},AbilityController:get-subs\n{ex.Message}{ex.StackTrace}\n{request.ToJsonString()}", GroupNames.成都开发測試群組);
- return Ok(new { error = 400 });
- }
- }
- private async IAsyncEnumerable<List<AbilitySub>> GetSubsAsyn(List<string> tmdids, string _school, HashSet<string> ids)
- {
- foreach (var tmdid in tmdids)
- {
- List<AbilitySub> abilitySubs = new List<AbilitySub>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
- .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{_school}-{tmdid}") }))
- {
- ids.Add(item.id);
- abilitySubs.Add(item);
- }
- yield return abilitySubs;
- }
- }
- /// <summary>
- /// 批量更新认证材料分数。
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("score-teacher-submit")]
- [AuthToken(Roles = "admin,teacher", Permissions = "train-appraise")]
- public async Task<IActionResult> UpsertSubmitScore(JsonElement request)
- {
- try
- {
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
- if (!request.TryGetProperty("score", out JsonElement _score)) return BadRequest();
- if (!request.TryGetProperty("tmdids", out JsonElement _tmdids)) return BadRequest();
- if (!request.TryGetProperty("roleType", out JsonElement _roleType)) return BadRequest();
- var (userid, name, picture, school) = HttpContext.GetAuthTokenInfo();
- int score = -999;
- var client = _azureCosmos.GetCosmosClient();
- int.TryParse($"{_score}", out score);
- List<string> tmdids = _tmdids.ToObject<List<string>>();
- List<AbilitySub> abilitySubs = new List<AbilitySub>();
- HashSet<AbilitySub> subs = new HashSet<AbilitySub>();
- HashSet<string> ids = new HashSet<string>();
- // List<string> abilities = new List<string>();
- await foreach (var item in GetSubsAsyn(tmdids, school, ids))
- {
- abilitySubs.AddRange(item);
- }
- var su = abilitySubs.FindAll(x => x.from == 1);
- if (su.IsNotEmpty())
- {
- subs = new HashSet<AbilitySub>(su);
- }
- if (ids.Count > 0)
- {
- string queryText = $"SELECT value(c.id) FROM c WHERE c.currency=1 and c.id IN ({string.Join(",", ids.Select(o => $"'{o}'"))})";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
- .GetItemQueryIterator<string>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
- {
- var sb = abilitySubs.FindAll(x => x.id.Equals(item));
- if (sb != null)
- {
- subs.UnionWith(sb);
- }
- //abilities.Add(item);
- }
- }
- if (subs.Count > 0 && score >= -1 && score <= 2)
- {
- long nowTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
- List<Task<ItemResponse<AbilitySub>>> abilitySubTasks = new List<Task<ItemResponse<AbilitySub>>>();
- subs.ToList().ForEach(sub => {
- OtherScore otherScore = null;
- if ($"{_roleType}".Equals("school"))
- {
- otherScore = sub.otherScore.Find(x => x.roleType.Equals($"{_roleType}"));
- }
- else
- {
- otherScore = sub.otherScore.Find(x => x.roleType.Equals($"{_roleType}") && x.tmdid.Equals(userid));
- }
- if (otherScore != null)
- {
-
- otherScore.score = score;
- otherScore.scoreUploads.ForEach(x => {
- x.score = score;
- });
- otherScore.tmdid = userid;
- otherScore.tmdname = name;
- otherScore.time = nowTime;
- }
- else
- {
- if (sub.uploads != null)
- {
- List<ScoreUpload> scoreUploads = new List<ScoreUpload>();
- sub.uploads.ForEach(x => {
- scoreUploads.Add(new ScoreUpload
- {
- score = score,
- stdid = x.stdid,
- taskid = x.taskid,
- titleIds = x.titleIds,
- });
- });
- otherScore = new OtherScore
- {
- roleType = $"{_roleType}",
- tmdid = userid,
- tmdname = name,
- score = score,
- time = nowTime,
- scoreUploads = scoreUploads
- };
- }
- }
- abilitySubTasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(sub, sub.id, new PartitionKey(sub.code)));
- });
- List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
- tmdids.ForEach(x => {
- list.Add(($"{standard}", $"{x}", $"{school}", new List<string> { StatisticsService.TeacherAility }, 1));
-
- });
- int pagesize = 50;
- if (abilitySubTasks.Count <= pagesize)
- {
- await Task.WhenAll(abilitySubTasks);
- }
- else
- {
- int pages = (abilitySubTasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
- for (int i = 0; i < pages; i++)
- {
- var lists = abilitySubTasks.Skip((i) * pagesize).Take(pagesize).ToList();
- await Task.WhenAll(lists);
- }
- }
- await StatisticsService.SendServiceBus(list, _configuration, _serviceBus);
- return Ok(new { status = 200 });
- }
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},UpsertSubmitScore/UpsertSubmitScore()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- }
- return Ok(new { error = 0, msg = "参数异常" });
- }
- /// <summary>
- /// 对某个订阅的能力点进行操作
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("sub-opt")]
- [AuthToken(Roles = "teacher,admin,area")]
- public async Task<IActionResult> SubOpt(JsonElement request)
- {
- try
- {
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
- var client = _azureCosmos.GetCosmosClient();
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
- if (!request.TryGetProperty("opt", out JsonElement _opt)) return BadRequest();
- if (!request.TryGetProperty("abilityId", out JsonElement _abilityId)) return BadRequest();
- string code = $"AbilitySub-{_school}-{_tmdid}";
- int status = 0;
- AbilitySub abilitySub = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<AbilitySub>($"{_abilityId}", new PartitionKey(code));
- Ability abilityA = await client.GetContainer("TEAMModelOS", "Normal").ReadItemAsync<Ability>($"{_abilityId}", new PartitionKey($"Ability-{standard}"));
- switch ($"{_opt}")
- {
- case "ReadSelfOnlineRcd":
- //获取线上学习记录
- return Ok(new { abilitySub.taskRcds });
- case "ReadSomeoneSub":
- //获取线一个人的完整的能力点订阅数据
- var replyIds = abilitySub.otherScore.SelectMany(x => x.replyIds).Where(y=>!string.IsNullOrEmpty(y));
- List<DebateReply> replies = new List<DebateReply>();
- if (replyIds != null && replyIds.Count()>0) {
-
- string sql = $"select value(A1) from c join A1 in c.replies where A1.id in({string.Join(",", replyIds.Select(o => $"'{o}'"))})";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
- .GetItemQueryIterator<DebateReply>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Debate-{_school}") }))
- {
- replies.Add(item);
- }
- abilitySub.otherScore.ForEach(x => {
- x.replyIds.RemoveAll(x =>string.IsNullOrEmpty(x) || !replies.Select(r=>r.id).Contains(x));
-
- });
- }
- List<OtherScoreReply> scoreReplies= new List<OtherScoreReply>();
- abilitySub.otherScore.ForEach(x => {
- OtherScoreReply scoreReply = new OtherScoreReply
- {
- roleType=x.roleType,
- tmdid=x.tmdid,
- tmdname=x.tmdname,
- score=x.score,
- scoreUploads=x.scoreUploads,
- time=x.time
- };
- var rs= replies.FindAll(m => x.replyIds.Contains(m.id));
- scoreReply.replies.AddRange(rs);
- scoreReplies.Add(scoreReply);
- });
- Dictionary<string, List<DebateReply>> pairs = new Dictionary<string, List<DebateReply>>();
- abilitySub.otherScore.GroupBy(x => x.roleType).Select(m => new { key= m.Key, list = m.ToList() }).ToList().ForEach(y => {
- var reply= replies.FindAll(z =>y.list.SelectMany(a=>a.replyIds).Contains(z.id));
- pairs.Add(y.key, reply);
- });
- return Ok(new { abilitySub,scoreReplies, ability = abilityA });
- case "SetOnlineDone":
- //完成线上学习
- abilitySub.done = true;
- //abilitySub.abilityCount = abilityA.abilityCount;
- //abilitySub.hour = abilityA.hour;
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
- return Ok(new { abilitySub });
- case "ExerciseScore":
- //保存自测结果
- if (!request.TryGetProperty("exercise", out JsonElement _exercise)) return BadRequest();
- if (!string.IsNullOrEmpty($"{_exercise}"))
- {
- //exercise -1未自测 0不合格 1 合格
- abilitySub.exerciseScore = int.Parse($"{_exercise}");
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
- status = 1;
- await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}",new List<string> { StatisticsService.TeacherAility }, 1) }, _configuration, _serviceBus);
- return Ok(new { status });
- }
- else
- {
- return BadRequest("参数exercise没有值");
- }
- case "ExerciseRcd":
- //获取自测结果
- return Ok(new { exercise = abilitySub.exerciseScore });
- case "Upload":
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- //上传作品和自评
- if (!request.TryGetProperty("uploads", out JsonElement _uploads)) return BadRequest();
- if (!request.TryGetProperty("self", out JsonElement _self)) return BadRequest();
- List<SubUpload> uploads = _uploads.ToObject<List<SubUpload>>();
- if (!string.IsNullOrEmpty($"{_self}"))
- {
- //_self 0 不及格,1及格,2优秀
- abilitySub.self = int.Parse($"{_self}");
- }
- else
- {
- return BadRequest();
- }
- if (uploads.IsNotEmpty())
- {
- abilitySub.abilityCount = abilityA.abilityCount;
- abilitySub.hour = abilityA.hour;
- uploads.ForEach(u =>
- {
- var up = abilitySub.uploads.Find(x => x.stdid.Equals(u.stdid));
- if (up != null)
- {
- up.urls = u.urls;
- up.taskid = u.taskid;
- up.titleIds = u.titleIds;
- up.time = now;
- }
- else
- {
- u.time = now;
- abilitySub.uploads.Add(u);
- }
- });
- abilitySub.selfTime = now;
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
- status = 1;
- await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}", new List<string> { StatisticsService.TeacherAility }, 0) }, _configuration, _serviceBus);
- }
- else
- {
- return BadRequest();
- }
- return Ok(new { status });
- case "YouRateSomone":
- //你对别人的某个能力点的学习进行评价,不能评价自己的,
- if (!request.TryGetProperty("otherScore", out JsonElement _other)) return BadRequest();
- RoleScore other = _other.ToObject<RoleScore>();
- string replyId = null;
- if (other != null)
- {
- //if (abilitySub.creatorId.Equals(other.tmdid))
- //{
- // return BadRequest("不能评价自己的");
- //}
- long nowTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
- if (!string.IsNullOrEmpty(other.reply))
- {
- replyId = Guid.NewGuid().ToString();
- DebateReply debateReply = new DebateReply
- {
- atUserType = "tmdid",
- userType = "tmdid",
- id = replyId,
- pid = abilitySub.comid,
- tmdid = other.tmdid,
- tmdname = other.tmdname,
- comment = other.reply,
- atTmdid = $"{_tmdid}",
- atTmdname = other.atTmdname,
- time = nowTime
- };
- try
- {
- Debate debate = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Debate>(abilitySub.comid, new PartitionKey($"Debate-{_school}"));
- debate.replies.Add(debateReply);
- await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Debate>(debate, abilitySub.comid, new PartitionKey($"Debate-{_school}"));
- }
- catch (CosmosException ex)
- {
- if (ex.Status == 404)
- {
- Debate debate = new Debate
- {
- userType = "tmdid",
- comid = $"{abilityA.comid}",
- code = $"Debate-{_school}",
- id = $"{abilitySub.comid}",
- tmdid = abilitySub.creatorId,
- tmdname = other.atTmdname,
- title = $"{other.atTmdname}-{abilityA.name}",
- time = nowTime,
- comment = "",
- school = $"{_school}",
- replies = new List<DebateReply>() { debateReply },
- source = "uploadscore",
- openType = 0,
- ttl = -1,
- pk = "Debate"
- };
- await client.GetContainer("TEAMModelOS", "School").CreateItemAsync<Debate>(debate, new PartitionKey($"Debate-{_school}"));
- }
- }
- }
- if (other.roleType.Equals("school"))
- {
- //学校的身份不管是谁,只能以学校的身份进行一次评论
- abilitySub.allDone = true;
- var otherScore = abilitySub.otherScore.Find(x => x.roleType.Equals(other.roleType));
- if (otherScore != null)
- {
- otherScore.tmdid = other.tmdid;
- otherScore.tmdname = other.tmdname;
- otherScore.score = other.score;
- if (!string.IsNullOrEmpty(replyId))
- {
- if (otherScore.replyIds.IsNotEmpty())
- {
- otherScore.replyIds.Add(replyId);
- }
- else
- {
- otherScore.replyIds = new List<string>() { replyId };
- }
- }
- otherScore.scoreUploads = other.scoreUploads;
- otherScore.time = nowTime;
- }
- else
- {
- abilitySub.otherScore.Add(new OtherScore
- {
- roleType = other.roleType,
- tmdid = other.tmdid,
- tmdname = other.tmdname,
- score = other.score,
- replyIds = new List<string>() { replyId },
- scoreUploads = other.scoreUploads,
- time = nowTime
- });
- }
- }
- else if (other.roleType.Equals("leader"))
- {
- //小组评的身份不管是谁,只能以学校的身份进行一次评论
- abilitySub.allDone = true;
- var otherScore = abilitySub.otherScore.Find(x => x.roleType.Equals(other.roleType));
- if (otherScore != null)
- {
- otherScore.tmdid = other.tmdid;
- otherScore.tmdname = other.tmdname;
- otherScore.score = other.score;
- if (!string.IsNullOrEmpty(replyId))
- {
- if (otherScore.replyIds.IsNotEmpty())
- {
- otherScore.replyIds.Add(replyId);
- }
- else
- {
- otherScore.replyIds = new List<string>() { replyId };
- }
- }
- otherScore.scoreUploads = other.scoreUploads;
- otherScore.time = nowTime;
- }
- else
- {
- abilitySub.otherScore.Add(new OtherScore
- {
- roleType = other.roleType,
- tmdid = other.tmdid,
- tmdname = other.tmdname,
- score = other.score,
- replyIds = new List<string>() { replyId },
- scoreUploads = other.scoreUploads,
- time = nowTime
- });
- }
- }
- else
- {
- //其他身份的同一个人可以以不同身份进行点评
- var otherScore = abilitySub.otherScore.Find(x => x.tmdid.Equals(other.tmdid) && x.roleType.Equals(other.roleType));
- if (otherScore != null)
- {
- otherScore.tmdid = other.tmdid;
- otherScore.tmdname = other.tmdname;
- otherScore.score = other.score;
- if (!string.IsNullOrEmpty(replyId))
- {
- if (otherScore.replyIds.IsNotEmpty())
- {
- otherScore.replyIds.Add(replyId);
- }
- else
- {
- otherScore.replyIds = new List<string>() { replyId };
- }
- }
- otherScore.scoreUploads = other.scoreUploads;
- otherScore.time = nowTime;
- }
- else
- {
- abilitySub.otherScore.Add(new OtherScore
- {
- roleType = other.roleType,
- tmdid = other.tmdid,
- tmdname = other.tmdname,
- score = other.score,
- replyIds = new List<string>() { replyId },
- scoreUploads = other.scoreUploads,
- time = nowTime
- });
- }
- }
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
- await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}", new List<string> { StatisticsService.TeacherAility }, 1) }, _configuration, _serviceBus);
- status = 1;
- }
- return Ok(new { status, abilitySub });
- case "YouGetSomoneRate":
- //你获取你对别人的某个能力点的学习评价
- OtherScore score = null;
- if (!request.TryGetProperty("yourTmdid", out JsonElement _yourTmdid)) return BadRequest();
- if (string.IsNullOrEmpty($"{_yourTmdid}"))
- {
- score = abilitySub.otherScore.Find(x => x.tmdid.Equals($"{_yourTmdid}"));
- if (score != null)
- {
- status = 1;
- return Ok(new { score, status });
- }
- else
- {
- return Ok(new { status, score });
- }
- }
- else
- {
- return Ok(new { status, score });
- }
- case "SaveLearnOnlineRcd":
- //保存线上学习记录
- if (!request.TryGetProperty("taskRcds", out JsonElement _taskRcds)) return BadRequest();
- AbilityTaskRcd taskRcds = _taskRcds.ToObject<AbilityTaskRcd>();
- if (taskRcds != null)
- {
- bool isnew = true;
- abilitySub.taskRcds.ForEach(x =>
- {
- if (x.id.Equals(taskRcds.id))
- {
- //重新上传或者覆盖之前
- x.done = taskRcds.done;
- x.urls = taskRcds.urls;
- isnew = false;
- }
- });
- if (isnew)
- {
- abilitySub.taskRcds.Add(taskRcds);
- }
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
- status = 1;
- }
- return Ok(new { status, abilitySub.taskRcds });
- case "SaveVideoRcd":
- //保存线上学习记录
- if (!request.TryGetProperty("videoRcd", out JsonElement _videoRcd)) return BadRequest();
- AbilityVideoRcd videoRcd = _videoRcd.ToObject<AbilityVideoRcd>();
- if (videoRcd != null)
- {
- bool isnew = true;
- abilitySub.videoRcds.ForEach(x =>
- {
- if (x.abilityId.Equals(videoRcd.abilityId) && x.abilityTaskId.Equals(videoRcd.abilityTaskId) && x.url.Equals(videoRcd.url))
- {
- //重新上传或者覆盖之前
- x.done = videoRcd.done;
- x.time = videoRcd.time;
- isnew = false;
- }
- });
- if (isnew)
- {
- abilitySub.videoRcds.Add(videoRcd);
- }
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
- status = 1;
- }
- return Ok(new { status, abilitySub.videoRcds });
- case "SaveFileRcd":
- //保存文件学习记录
- if (!request.TryGetProperty("fileRcd", out JsonElement _fileRcd)) return BadRequest();
- List< TeacherFileRcd > fileRcds = new List< TeacherFileRcd >();
- if (_fileRcd.ValueKind.Equals(JsonValueKind.Object))
- {
- TeacherFileRcd fileRcd = _fileRcd.ToObject<TeacherFileRcd>();
- fileRcds.Add( fileRcd );
- }
- else if (_fileRcd.ValueKind.Equals(JsonValueKind.Array))
- {
- fileRcds = _fileRcd.ToObject<List<TeacherFileRcd>>();
- }
- TeacherFile teacherFile = null;
- try
- {
- teacherFile = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<TeacherFile>($"{_tmdid}", new PartitionKey($"TeacherFile-{_school}"));
- fileRcds.ForEach(fileRcd => {
- var file = teacherFile.fileRecords.Find(x => x.hash.Equals(fileRcd.hash));
- if (file != null)
- {
- file.hash = fileRcd.hash;
- file.view = fileRcd.view;
- file.done = fileRcd.done;
- FileAbility ability = file.files.Find(x => x.abilityId.Equals(fileRcd.abilityId) && x.url.Equals(fileRcd.url) && x.taskId.Equals(fileRcd.taskId) && x.nodeId.Equals(fileRcd.nodeId));
- if (ability != null)
- {
- ability.url = fileRcd.url;
- ability.abilityId = fileRcd.abilityId;
- ability.taskId = fileRcd.taskId;
- ability.nodeId = fileRcd.nodeId;
-
- }
- else
- {
- file.files.Add(new FileAbility { url = fileRcd.url, abilityId = fileRcd.abilityId, taskId = fileRcd.taskId, nodeId = fileRcd.nodeId, });
- }
- }
- else
- {
- teacherFile.fileRecords.Add(new FileRecord
- {
- hash = fileRcd.hash,
- size = fileRcd.size,
- duration = fileRcd.duration,
- view = fileRcd.view,
- type = fileRcd.type,
- done = fileRcd.done,
- files = new List<FileAbility> { new FileAbility { url = fileRcd.url, abilityId = fileRcd.abilityId, taskId = fileRcd.taskId, nodeId = fileRcd.nodeId, } }
- });
- }
- });
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey($"TeacherFile-{_school}"));
- }
- catch (CosmosException)
- {
- fileRcds.ForEach(fileRcd => {
- teacherFile = new TeacherFile
- {
- pk = "TeacherFile",
- id = $"{_tmdid}",
- code = $"TeacherFile-{_school}",
- fileRecords = new List<FileRecord>
- {
- new FileRecord
- {
- hash= fileRcd.hash,
- size=fileRcd.size,
- duration=fileRcd.duration,
- view=fileRcd.view,
- type=fileRcd.type,
- done=fileRcd.done,
- files= new List<FileAbility> { new FileAbility { url=fileRcd.url,abilityId=fileRcd.abilityId,taskId=fileRcd.taskId,nodeId=fileRcd.nodeId} }
- }
- },
- };
- });
- await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey($"TeacherFile-{_school}"));
- }
- if (fileRcds.Exists(x => x.type.Equals("video"))) {
- await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}", new List<string> { StatisticsService.TeacherAility }, 1) }, _configuration, _serviceBus);
- }
- //获取视文件学习记录
- List<dynamic> _files = new List<dynamic>();
- try
- {
- TeacherFile teacherFilercd = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<TeacherFile>($"{_tmdid}", new PartitionKey($"TeacherFile-{_school}"));
- teacherFilercd.fileRecords.ForEach(x => {
- var file = x.files.FindAll(y => y.abilityId.Equals($"{_abilityId}"));
- if (file.IsNotEmpty())
- {
- _files.Add(new { ability = file, view = x.view, hash = x.hash, done = x.done });
- }
- });
- }
- catch (Exception ex)
- {
- }
- return Ok(new { status, files=_files });
- case "ReadSelfVideoRcd":
- //获取视频学习记录
- return Ok(new { abilitySub.videoRcds });
- case "ReadSelfFileRcd":
- //获取视文件学习记录
- List<dynamic> files = new List<dynamic>();
- List<dynamic> abilityFiles = new List<dynamic>();
- try {
- TeacherFile teacherFilercd = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<TeacherFile>($"{_tmdid}", new PartitionKey($"TeacherFile-{_school}"));
- HashSet<string> abilityIds= teacherFilercd.fileRecords.SelectMany(x => x.files).Select(x => x.abilityId).ToHashSet() ;
- teacherFilercd.fileRecords.ForEach(x => {
- var file = x.files.FindAll(y => y.abilityId.Equals($"{_abilityId}"));
- if (file.IsNotEmpty()) {
- files.Add(new { ability =file,view=x.view,hash=x.hash,done=x.done });
- }
- });
- foreach (var abid in abilityIds) {
- var record= teacherFilercd.fileRecords.FindAll(x => x.files.Where(y => y.abilityId.Equals(abid)).Count() > 0);
- long view = 0;
- List<dynamic> urls = new List<dynamic>();
- record.ForEach(x => {
- var file= x.files.FindAll(y => y.abilityId.Equals($"{abid}"));
- if (file.IsNotEmpty())
- {
- view += x.view;
- urls.Add(new { ability = file, view = x.view, hash = x.hash, done = x.done });
- }
- });
- abilityFiles.Add(new { view, abilityId= abid });
- }
- return Ok(new { status, files, abilityFiles });
- } catch (Exception ex) {
-
- }
- return Ok(new { });
- default:
- return Ok(new { status = -1 });
- }
- }
- catch (CosmosException ex)
- {
- return Ok(new { status = -1 });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},AbilityController/SubOpt()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
- return Ok(new { status = -1 });
- }
- } /// <summary>
- /// 获取回复详情信息。
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("get-reply-info")]
- [AuthToken(Roles = "teacher,admin,area")]
- public async Task<IActionResult> GetReplyInfo(JsonElement request)
- {
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
- if (!request.TryGetProperty("replyIds", out JsonElement _replyIds)) return BadRequest();
- List<string> replyIds = _replyIds.ToObject<List<string>>();
- if (replyIds.IsNotEmpty())
- {
- List<dynamic> replies = new List<dynamic>();
- string sql = $"select A1 as replies from c join A1 in c.replies where A1.id in({string.Join(",", replyIds.Select(o => $"'{o}'"))})";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
- .GetItemQueryIterator<dynamic>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Debate-{_school}") }))
- {
- replies.Add(item);
- }
- return Ok(new { replies });
- }
- return Ok();
- }
- /// <summary>
- /// 获取订阅了相同的能力点的教师。
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("get-same-subs")]
- [AuthToken(Roles = "teacher,admin,area")]
- public async Task<IActionResult> GetSameSubs(JsonElement request)
- {
- // (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
- if (!request.TryGetProperty("school", out JsonElement _school))
- {
- return Ok(new { error = 400 });
- }
- var client = _azureCosmos.GetCosmosClient();
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return Ok(new { error = 400 });
- if (!request.TryGetProperty("abilityId", out JsonElement _abilityId)) return Ok(new { error = 400 });
- List<RGroupList> yxtrain= await GroupListService.GetGroupListMemberByType(client, "yxtrain", new List<string> { "school" }, $"{_school}",_dingDing);
- List<dynamic> abilitySubs = new List<dynamic>();
- if (yxtrain.IsNotEmpty()) {
- var members = yxtrain.SelectMany(m => m.members).ToList();
- List<RMember> tmdids = members.FindAll(x => x.type == 1).Where((x, i) => members.FindAll(x => x.type == 1).FindIndex(n => n.id.Equals(x.id)) == i).ToList();
- tmdids= tmdids.FindAll(x => !x.id.Equals($"{_tmdid}"));
- await foreach ((RMember tmdid, JsonElement sub) in GetSubsAsyn(tmdids, $"{_tmdid}", $"{_abilityId}", $"{_school}")) {
- AbilitySub abilitySub= sub.ToObject<AbilitySub>();
- if (abilitySub.uploads.IsNotEmpty()) {
- abilitySubs.Add(new { tmdid, sub= abilitySub });
- }
-
- }
- }
- return Ok(new { abilitySubs });
- }
- private async IAsyncEnumerable<(RMember, JsonElement)> GetSubsAsyn(List<RMember> tmdids,string _tmdid ,string _abilityId,string _school) {
- foreach (var tmdid in tmdids)
- {
- Response subs = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{_abilityId}", new PartitionKey($"AbilitySub-{_school}-{tmdid.id}"));
- if (subs.Status==200) {
- var json = await JsonDocument.ParseAsync(subs.ContentStream);
- JsonElement element =json.RootElement;
- yield return (tmdid, element);
- }
- }
- }
- /// <summary>
- /// 获取本小组的订阅
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("get-group-subs")]
- [AuthToken(Roles = "teacher,admin,area")]
- public async Task<IActionResult> GetGroupSubs(JsonElement request)
- {
- try
- {
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return Ok(new { error = 400 });
- // (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
- string school = "";
- if (!request.TryGetProperty("school", out JsonElement _school))
- {
- return Ok(new { error = 400 });
- }
- else
- {
- school = $"{_school}";
- }
- var client = _azureCosmos.GetCosmosClient();
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return Ok(new { error = 400 });
- request.TryGetProperty("all", out JsonElement _all);
- List<Ability> abilities = new List<Ability>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
- .GetItemQueryIterator<Ability>(queryText: $"select value(c) from c where c.status = 1 ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
- {
- abilities.Add(item);
- }
- //List<ScTeacher> teachers = new List<ScTeacher>();
- //await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ScTeacher>(queryText: $"SELECT c.groupName,c.groupId, c.id, c.name, c.picture FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
- //{
- // if (string.IsNullOrEmpty(item.groupId))
- // {
- // item.groupId = "default";
- // item.groupName = "默认组别";
- // }
- // teachers.Add(item);
- //}
- List<GroupList> tchLists = new List<GroupList>();
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<GroupList>(queryText: $"SELECT value(c) FROM c where c.type='research' ",
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{_school}") }))
- {
- tchLists.Add(item);
- }
- List<string> ids = tchLists.Select(x => x.id).ToList();
- if (!ids.IsNotEmpty())
- {
- ids.Add("default");
- }
- (List<RMember> tmdInfos, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, ids, $"{_school}");
- List<GroupMember> teachers = new List<GroupMember>();
- foreach (var classInfo in classInfos)
- {
- foreach (var tmdinfo in classInfo.members)
- {
- teachers.Add(new GroupMember { groupId = classInfo.id, groupName = classInfo.name, tmdid = tmdinfo.id, tmdname = tmdinfo.name, picture = tmdinfo.picture, tag = tmdinfo.tag });
- }
- }
- if ($"{_all}".Equals("1"))
- {
- List<SubGroupMember> groupMembers = new List<SubGroupMember>();
- // List<Debate> debates = new List<Debate>();
- // HashSet<string> comids = new HashSet<string>();
- foreach (var t in teachers)
- {
- try
- {
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
- .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.tmdid}") }))
- {
- // comids.Add(item.comid);
- groupMembers.Add(new SubGroupMember
- {
- tmdname = t.tmdname,
- tmdid = t.tmdid,
- picture = t.picture,
- groupName = t.groupName,
- groupId = t.groupId,
- sub = new SubGroup
- {
- abilityId = item.id,
- code = item.code,
- uploads = item.uploads,
- otherScore = item.otherScore,
- comid = item.comid,
- self = item.self
- }
- });
- }
- }
- catch (CosmosException ex) { }
- }
- return Ok(new { groupMembers, abilities });
- }
- else
- {
- var teacer = teachers.FindAll(x => x.tmdid.Equals($"{_tmdid}"));
- if (teacer != null)
- {
- List<SubGroupMember> groupMembers = new List<SubGroupMember>();
- var tecs = teachers.Where(x => teacer.Select(y => y.groupId).Contains(x.groupId)).ToList();
- foreach (var t in tecs)
- {
- //排除自己,如果不是组长则不排除
- if (t.tmdid.Equals($"{_tmdid}") && string.IsNullOrEmpty(t.tag)) { continue; }
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
- .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.tmdid}") }))
- {
- groupMembers.Add(new SubGroupMember
- {
- tmdname = t.tmdname,
- tmdid = t.tmdid,
- picture = t.picture,
- groupName = t.groupName,
- groupId = t.groupId,
- sub = new SubGroup
- {
- abilityId = item.id,
- code = item.code,
- uploads = item.uploads,
- otherScore = item.otherScore,
- comid = item.comid,
- self = item.self
- },
- tag = t.tag
- });
- }
- }
- return Ok(new { groupMembers, abilities });
- }
- else
- {
- return Ok(new { error = 400 });
- }
- }
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},AbilityController/SaveSubs()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
- return Ok(new { error = 400 });
- }
- }
- public class GroupMember
- {
- public string tmdname { get; set; }
- public string tmdid { get; set; }
- public string picture { get; set; }
- public string groupName { get; set; }
- public string groupId { get; set; }
- public string tag { get; set; }
- }
- public class SubGroupMember
- {
- public string tmdname { get; set; }
- public string tmdid { get; set; }
- public string picture { get; set; }
- public string groupName { get; set; }
- public string groupId { get; set; }
- public SubGroup sub { get; set; }
- public string tag { get; set; }
- }
- public class SubGroup
- {
- public string comid { get; set; }
- public int self { get; set; }
- public string abilityId { get; set; }
- public string code { get; set; }
- public List<SubUpload> uploads { get; set; }
- public List<OtherScore> otherScore { get; set; }
- }
- public class RoleScore
- {
- /// <summary>
- /// 角色类型 成员 member 学校 school 专家 expert
- /// </summary>
- public string roleType { get; set; }
- /// <summary>
- /// 评论人的id
- /// </summary>
- public string tmdid { get; set; }
- /// <summary>
- /// 评论人
- /// </summary>
- public string tmdname { get; set; }
- /// <summary>
- /// 被评论人的醍摩豆名称
- /// </summary>
- public string atTmdname { get; set; }
- //总评 -1未评,0未通过,1合格,2优秀
- public int score { get; set; } = -1;
- /// <summary>
- /// 某人对你这个能力点的学习评价的的评语记录的Id集合。
- /// </summary>
- public string reply { get; set; }
- /// <summary>
- /// 根据评判标准进行打分
- /// </summary>
- public List<ScoreUpload> scoreUploads { get; set; } = new List<ScoreUpload>();
- }
- }
- }
|