|
@@ -1039,7 +1039,12 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#region 知识评论
|
|
|
|
|
|
- //[Permission(EPermission.AddKnowledgeCollect)]
|
|
|
+ /// <summary>
|
|
|
+ /// 新增知识评论
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.AddKnowledgeComment)]
|
|
|
[HttpPost("knowledge_comment")]
|
|
|
public async Task Add([FromBody] KnowledgeCommentAddDto dto)
|
|
|
{
|
|
@@ -1056,16 +1061,30 @@ namespace Hotline.Api.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //[Permission(EPermission.DeleteQualityItem)]
|
|
|
- [HttpDelete("itemBatch")]
|
|
|
+ /// <summary>
|
|
|
+ /// 删除知识评论
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.DeleteKnowledgeComment)]
|
|
|
+ [HttpDelete("knowledge_comment")]
|
|
|
public async Task Delete([FromBody] KnowledgeCommentDeleteDto dto)
|
|
|
{
|
|
|
+ var comment = await _knowledgeCommentRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (comment is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效评论");
|
|
|
+ if (comment.CreatorId != _sessionContext.UserId)
|
|
|
+ throw UserFriendlyException.SameMessage("只有评论者可以删除当前评论");
|
|
|
await _knowledgeCommentRepository.RemoveAsync(x => x.Id == dto.Id);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //[Permission(EPermission.UpdateQualityItem)]
|
|
|
- [HttpPut("item")]
|
|
|
+ /// <summary>
|
|
|
+ /// 修改知识评论
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.UpdateKnowledgeComment)]
|
|
|
+ [HttpPut("knowledge_comment")]
|
|
|
public async Task Update([FromBody] KnowledgeCommentUpdateDto dto)
|
|
|
{
|
|
|
var comment = await _knowledgeCommentRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
@@ -1075,8 +1094,13 @@ namespace Hotline.Api.Controllers
|
|
|
await _knowledgeCommentRepository.UpdateAsync(comment, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
- //[Permission(EPermission.QualityItemList)]
|
|
|
- [HttpGet("item/list")]
|
|
|
+ /// <summary>
|
|
|
+ /// 知识评论列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.KnowledgeCommentList)]
|
|
|
+ [HttpGet("knowledge_comment/list")]
|
|
|
public async Task<List<KnowledgeCommentDto>> List([FromQuery] KnowledgeCommentListDto dto)
|
|
|
{
|
|
|
var comments = await _knowledgeCommentRepository.Queryable()
|