Changeset 73b69b2 for ChapterX.API/Controllers/CommentsController.cs
- Timestamp:
- 03/24/26 22:13:36 (3 months ago)
- Branches:
- main
- Children:
- 7fbb91c
- Parents:
- acf690c
- File:
-
- 1 edited
-
ChapterX.API/Controllers/CommentsController.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ChapterX.API/Controllers/CommentsController.cs
racf690c r73b69b2 1 1 using ChapterX.Application.Comment.Commands; 2 2 using ChapterX.Application.Comment.Queries; 3 using ChapterX.Domain.Repositories; 3 4 using MediatR; 4 5 using Microsoft.AspNetCore.Authorization; … … 13 14 { 14 15 private readonly IMediator _mediator; 16 private readonly ICommentRepository _commentRepository; 15 17 private readonly ILogger<CommentsController> _logger; 16 18 17 public CommentsController(IMediator mediator, I Logger<CommentsController> logger)19 public CommentsController(IMediator mediator, ICommentRepository commentRepository, ILogger<CommentsController> logger) 18 20 { 19 21 _mediator = mediator; 22 _commentRepository = commentRepository; 20 23 _logger = logger; 24 } 25 26 [HttpGet("story/{storyId:int}")] 27 [AllowAnonymous] 28 public async Task<ActionResult> GetByStory(int storyId) 29 { 30 var comments = await _commentRepository.GetByStoryIdAsync(storyId); 31 var result = comments.Select(c => new 32 { 33 id = c.Id, 34 content = c.Content, 35 userId = c.UserId, 36 storyId = c.StoryId, 37 username = c.User?.Username ?? "", 38 createdAt = c.CreatedAt, 39 }); 40 return Ok(result); 21 41 } 22 42
Note:
See TracChangeset
for help on using the changeset viewer.
