|
@@ -18,6 +18,7 @@ using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
|
using TEAMModelOS.Models;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
using TEAMModelOS.Filter;
|
|
|
+using TEAMModelOS.Services.Common;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -31,18 +32,20 @@ namespace TEAMModelOS.Controllers
|
|
|
[ApiController]
|
|
|
public class SurveyController : ControllerBase
|
|
|
{
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
private readonly AzureCosmosFactory _azureCosmos;
|
|
|
private readonly SnowflakeId _snowflakeId;
|
|
|
private readonly AzureServiceBusFactory _serviceBus;
|
|
|
private readonly DingDing _dingDing;
|
|
|
private readonly Option _option;
|
|
|
- public SurveyController(AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
+ public SurveyController(AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis)
|
|
|
{
|
|
|
_snowflakeId= snowflakeId;
|
|
|
_serviceBus = serviceBus;
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_dingDing = dingDing;
|
|
|
_option = option?.Value;
|
|
|
+ _azureRedis = azureRedis;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -273,5 +276,30 @@ namespace TEAMModelOS.Controllers
|
|
|
return BadRequest(e.StackTrace);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 问卷答案提交
|
|
|
+ /// </summary>
|
|
|
+ /// <redis>
|
|
|
+ /// 投票活动选项计数器 使用SortedSet(有序集合)ZSET 数据集合 使用命令 ZINCRBY key:"Vote:Count:AAA",value:"A",score:1
|
|
|
+ /// 投票活动 投票记录 使用Hash(哈希表)使用命令 key:"Vote:Record:AAA",feild:15283771540-20210105,value:"{"opt":["A","C","A"],"time":1608274766154}"
|
|
|
+ /// </redis>
|
|
|
+ /// <param name="request">
|
|
|
+ /// !"id":"aaaa"
|
|
|
+ /// !"code":"Vote-hbcn"/"code":"Vote-1606285227"
|
|
|
+ /// !"record":[["A","B"],["A"],["D"],[],["建议提升服务质量"]]
|
|
|
+ /// </param>
|
|
|
+ /// <returns>
|
|
|
+ /// msgid=0投票失败,1投票成功,2不在时间范围内,3不在发布范围内,4投票周期内重复投票,5周期内的可投票数不足,6未设置投票项
|
|
|
+ /// </returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("answer")]
|
|
|
+ [AuthToken(Roles = "teacher,student")]
|
|
|
+ public async Task<IActionResult> Answer(JsonElement request)
|
|
|
+ {
|
|
|
+ var (userid, _, _, _) = HttpContext.GetAuthTokenInfo();
|
|
|
+ int msgid = await ActivityStudentService.Answer(request, _azureCosmos, _azureRedis, userid);
|
|
|
+ return Ok(new { msgid });
|
|
|
+ }
|
|
|
}
|
|
|
}
|