12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Threading.Tasks;
- using GxPress.Auth;
- using GxPress.Common.Page;
- using GxPress.Repository.Interface;
- using GxPress.Request.Comment;
- using GxPress.Result.Comment;
- using Microsoft.AspNetCore.Mvc;
- using GxPress.Common.Exceptions;
- using Microsoft.AspNetCore.Authorization;
- namespace GxPress.Api.WebControllers
- {
-
-
-
- [Route("api/web/comment")]
- [ApiController]
- [Authorize]
- public class WebCommentController : Controller
- {
- private readonly ICommentRepository _commentRepository;
- private readonly ILoginContext _loginContext;
- public WebCommentController(ICommentRepository commentRepository, ILoginContext loginContext)
- {
- _commentRepository = commentRepository;
- _loginContext = loginContext;
- }
-
-
-
-
-
- [HttpPost("add")]
- public async Task<bool> Add([FromBody] CommentInRequest request)
- {
-
- request.UserId = _loginContext.AccountId;
- if (string.IsNullOrWhiteSpace(request.Content))
- throw new BusinessException("评论内容为空");
- return await _commentRepository.CommentInAsync(request) > 0;
- }
-
-
-
-
-
- [HttpPost("list")]
- public async Task<PagedList<CommentPageResult>> GetPagedList([FromBody] CommentSearchPageRequest request)
- {
- return await _commentRepository.GetPagedList(request);
- }
-
-
-
-
-
- [HttpDelete("delete")]
- public async Task<bool> Delete([FromBody] CommentDeleteRequest request)
- {
- return await _commentRepository.DeleteCommentAsync(request);
- }
-
-
-
-
-
- [HttpPut("update")]
- public async Task<bool> UpdateComment([FromBody] CommentUpdateRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _commentRepository.UpdateCommentAsync(request);
- }
- }
- }
|