Skip to content

Commit 18d2452

Browse files
committed
feat: DTO정리
1 parent b9738ed commit 18d2452

34 files changed

+80
-259
lines changed

ProjectVG.Api/Controllers/AuthController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.AspNetCore.Mvc;
22
using ProjectVG.Application.Services.User;
33
using ProjectVG.Application.Models.User;
4-
using Microsoft.Extensions.Logging;
54

65
namespace ProjectVG.Api.Controllers
76
{

ProjectVG.Api/Controllers/CharacterController.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using Microsoft.AspNetCore.Mvc;
22
using ProjectVG.Application.Services.Character;
3-
using ProjectVG.Api.Models.Character;
43
using ProjectVG.Application.Models.Character;
4+
using ProjectVG.Api.Models.Character.Request;
5+
using ProjectVG.Api.Models.Character.Response;
56

67
namespace ProjectVG.Api.Controllers
78
{
@@ -19,12 +20,12 @@ public CharacterController(ICharacterService characterService, ILogger<Character
1920
}
2021

2122
[HttpGet]
22-
public async Task<ActionResult<IEnumerable<CharacterResponseDto>>> GetAllCharacters()
23+
public async Task<ActionResult<IEnumerable<CharacterResponse>>> GetAllCharacters()
2324
{
2425
try
2526
{
2627
var characterDtos = await _characterService.GetAllCharactersAsync();
27-
var responses = characterDtos.Select(CharacterMapper.ToResponseDto);
28+
var responses = characterDtos.Select(CharacterResponse.ToResponseDto);
2829
return Ok(responses);
2930
}
3031
catch (Exception ex)
@@ -35,7 +36,7 @@ public async Task<ActionResult<IEnumerable<CharacterResponseDto>>> GetAllCharact
3536
}
3637

3738
[HttpGet("{id}")]
38-
public async Task<ActionResult<CharacterResponseDto>> GetCharacterById(Guid id)
39+
public async Task<ActionResult<CharacterResponse>> GetCharacterById(Guid id)
3940
{
4041
try
4142
{
@@ -45,7 +46,7 @@ public async Task<ActionResult<CharacterResponseDto>> GetCharacterById(Guid id)
4546
return NotFound($"ID {id}인 캐릭터를 찾을 수 없습니다.");
4647
}
4748

48-
var response = CharacterMapper.ToResponseDto(characterDto);
49+
var response = CharacterResponse.ToResponseDto(characterDto);
4950
return Ok(response);
5051
}
5152
catch (Exception ex)
@@ -56,7 +57,7 @@ public async Task<ActionResult<CharacterResponseDto>> GetCharacterById(Guid id)
5657
}
5758

5859
[HttpPost]
59-
public async Task<ActionResult<CharacterResponseDto>> CreateCharacter([FromBody] CreateCharacterRequestDto request)
60+
public async Task<ActionResult<CharacterResponse>> CreateCharacter([FromBody] CreateCharacterRequest request)
6061
{
6162
try
6263
{
@@ -74,7 +75,7 @@ public async Task<ActionResult<CharacterResponseDto>> CreateCharacter([FromBody]
7475
};
7576

7677
var characterDto = await _characterService.CreateCharacterAsync(command);
77-
var response = CharacterMapper.ToResponseDto(characterDto);
78+
var response = CharacterResponse.ToResponseDto(characterDto);
7879
return CreatedAtAction(nameof(GetCharacterById), new { id = response.Id }, response);
7980
}
8081
catch (Exception ex)
@@ -85,7 +86,7 @@ public async Task<ActionResult<CharacterResponseDto>> CreateCharacter([FromBody]
8586
}
8687

8788
[HttpPut("{id}")]
88-
public async Task<ActionResult<CharacterResponseDto>> UpdateCharacter(Guid id, [FromBody] UpdateCharacterRequestDto request)
89+
public async Task<ActionResult<CharacterResponse>> UpdateCharacter(Guid id, [FromBody] UpdateCharacterRequest request)
8990
{
9091
try
9192
{
@@ -103,7 +104,7 @@ public async Task<ActionResult<CharacterResponseDto>> UpdateCharacter(Guid id, [
103104
};
104105

105106
var characterDto = await _characterService.UpdateCharacterAsync(id, command);
106-
var response = CharacterMapper.ToResponseDto(characterDto);
107+
var response = CharacterResponse.ToResponseDto(characterDto);
107108
return Ok(response);
108109
}
109110
catch (KeyNotFoundException)

ProjectVG.Api/Controllers/ChatController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using ProjectVG.Api.Models.Chat;
1+
using ProjectVG.Application.Models.API.Request;
22
using ProjectVG.Application.Services.Chat;
3-
using ProjectVG.Application.Models.Chat;
43
using Microsoft.AspNetCore.Mvc;
54
using Microsoft.AspNetCore.Authorization;
6-
using Microsoft.Extensions.DependencyInjection;
7-
using Microsoft.Extensions.Logging;
85

96
namespace ProjectVG.Api.Controllers
107
{

ProjectVG.Api/Models/Character/CharacterMapper.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

ProjectVG.Api/Models/Character/CharacterResponseDto.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

ProjectVG.Api/Models/Character/CreateCharacterRequestDto.cs renamed to ProjectVG.Api/Models/Character/Request/CreateCharacterRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Text.Json.Serialization;
22

3-
namespace ProjectVG.Api.Models.Character
3+
namespace ProjectVG.Api.Models.Character.Request
44
{
5-
public class CreateCharacterRequestDto
5+
public class CreateCharacterRequest
66
{
77
[JsonPropertyName("name")]
88
public string Name { get; set; } = string.Empty;

ProjectVG.Api/Models/Character/UpdateCharacterRequestDto.cs renamed to ProjectVG.Api/Models/Character/Request/UpdateCharacterRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Text.Json.Serialization;
22

3-
namespace ProjectVG.Api.Models.Character
3+
namespace ProjectVG.Api.Models.Character.Request
44
{
5-
public class UpdateCharacterRequestDto
5+
public class UpdateCharacterRequest
66
{
77
[JsonPropertyName("name")]
88
public string Name { get; set; } = string.Empty;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using ProjectVG.Application.Models.Character;
2+
using System.Text.Json.Serialization;
3+
4+
namespace ProjectVG.Api.Models.Character.Response
5+
{
6+
public class CharacterResponse
7+
{
8+
[JsonPropertyName("id")]
9+
public Guid Id { get; set; }
10+
11+
[JsonPropertyName("name")]
12+
public string Name { get; set; } = string.Empty;
13+
14+
[JsonPropertyName("description")]
15+
public string Description { get; set; } = string.Empty;
16+
17+
[JsonPropertyName("role")]
18+
public string Role { get; set; } = string.Empty;
19+
20+
[JsonPropertyName("is_active")]
21+
public bool IsActive { get; set; } = true;
22+
23+
24+
public static CharacterResponse ToResponseDto(CharacterDto characterDto)
25+
{
26+
return new CharacterResponse {
27+
Id = characterDto.Id,
28+
Name = characterDto.Name,
29+
Description = characterDto.Description,
30+
Role = characterDto.Role,
31+
IsActive = characterDto.IsActive
32+
};
33+
}
34+
}
35+
}

ProjectVG.Api/Models/Chat/ChatRequest.cs renamed to ProjectVG.Api/Models/Chat/Request/ChatRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Text.Json.Serialization;
22
using ProjectVG.Application.Models.Chat;
33

4-
namespace ProjectVG.Api.Models.Chat
4+
namespace ProjectVG.Application.Models.API.Request
55
{
66
public class ChatRequest
77
{
@@ -40,4 +40,4 @@ public ProcessChatCommand ToProcessChatCommand()
4040
};
4141
}
4242
}
43-
}
43+
}

ProjectVG.Application/Middlewares/WebSocketMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Microsoft.AspNetCore.Http;
55
using ProjectVG.Application.Services.Session;
66
using ProjectVG.Common.Models.Session;
7-
using ProjectVG.Application.Models.Chat;
7+
using ProjectVG.Application.Models.WebSocket;
88
using ProjectVG.Infrastructure.Persistence.Session;
99

1010
namespace ProjectVG.Application.Middlewares

0 commit comments

Comments
 (0)