Skip to content

Commit d59414c

Browse files
committed
refactor(F15): Refactor
Remove all f15 prefix of all class and change register name to registration center
1 parent c7cddee commit d59414c

File tree

17 files changed

+75
-79
lines changed

17 files changed

+75
-79
lines changed
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@
88

99
namespace F15.BusinessLogic;
1010

11-
public sealed class F15Service : IServiceHandler<F15AppRequestModel, F15AppResponseModel>
11+
public sealed class Service : IServiceHandler<AppRequestModel, AppResponseModel>
1212
{
13-
private readonly Lazy<IF15Repository> _repository;
13+
private readonly Lazy<IRepository> _repository;
1414

15-
public F15Service(Lazy<IF15Repository> repository)
15+
public Service(Lazy<IRepository> repository)
1616
{
1717
_repository = repository;
1818
}
1919

20-
public async Task<F15AppResponseModel> ExecuteAsync(
21-
F15AppRequestModel request,
22-
CancellationToken ct
23-
)
20+
public async Task<AppResponseModel> ExecuteAsync(AppRequestModel request, CancellationToken ct)
2421
{
2522
var doesTaskExist = await _repository.Value.DoesTodoTaskExistAsync(request.TodoTaskId, ct);
2623
if (!doesTaskExist)
2724
{
28-
return F15Constant.DefaultResponse.App.TASK_NOT_FOUND;
25+
return Constant.DefaultResponse.App.TASK_NOT_FOUND;
2926
}
3027

3128
var taskDetail = await _repository.Value.GetTaskDetailByIdAsync(request.TodoTaskId, ct);
32-
var appResponse = new F15AppResponseModel()
29+
var appResponse = new AppResponseModel()
3330
{
34-
AppCode = F15Constant.AppCode.SUCCESS,
31+
AppCode = Constant.AppCode.SUCCESS,
3532
Body = new()
3633
{
3734
TodoTask = new()
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace F15.Common;
66

7-
public static class F15Constant
7+
public static class Constant
88
{
9+
public const string CONTROLLER_NAME = "F15Endpoint";
10+
911
public const string ENDPOINT_PATH = "f15/task/{TodoTaskId:required}";
1012

1113
public const string REQUEST_ARGUMENT_NAME = "request";
@@ -14,21 +16,21 @@ public static class DefaultResponse
1416
{
1517
public static class App
1618
{
17-
public static readonly F15AppResponseModel TASK_NOT_FOUND = new()
19+
public static readonly AppResponseModel TASK_NOT_FOUND = new()
1820
{
1921
AppCode = AppCode.TASK_NOT_FOUND,
2022
};
2123
}
2224

2325
public static class Http
2426
{
25-
public static readonly F15Response VALIDATION_FAILED = new()
27+
public static readonly Response VALIDATION_FAILED = new()
2628
{
2729
AppCode = (int)AppCode.VALIDATION_FAILED,
2830
HttpCode = StatusCodes.Status400BadRequest,
2931
};
3032

31-
public static readonly F15Response TASK_NOT_FOUND = new()
33+
public static readonly Response TASK_NOT_FOUND = new()
3234
{
3335
AppCode = (int)AppCode.TASK_NOT_FOUND,
3436
HttpCode = StatusCodes.Status404NotFound,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace F15.DataAccess;
66

7-
public interface IF15Repository
7+
public interface IRepository
88
{
99
Task<bool> DoesTodoTaskExistAsync(long taskId, CancellationToken ct);
1010

11-
Task<F15TodoTaskModel> GetTaskDetailByIdAsync(long taskId, CancellationToken ct);
11+
Task<TodoTaskModel> GetTaskDetailByIdAsync(long taskId, CancellationToken ct);
1212
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
namespace F15.DataAccess;
1111

12-
public sealed class F15Repository : IF15Repository
12+
public sealed class Repository : IRepository
1313
{
1414
private readonly AppDbContext _appContext;
1515

16-
public F15Repository(AppDbContext context)
16+
public Repository(AppDbContext context)
1717
{
1818
_appContext = context;
1919
}
@@ -23,12 +23,12 @@ public Task<bool> DoesTodoTaskExistAsync(long taskId, CancellationToken ct)
2323
return _appContext.Set<TodoTaskEntity>().AnyAsync(entity => entity.Id == taskId, ct);
2424
}
2525

26-
public async Task<F15TodoTaskModel> GetTaskDetailByIdAsync(long taskId, CancellationToken ct)
26+
public async Task<TodoTaskModel> GetTaskDetailByIdAsync(long taskId, CancellationToken ct)
2727
{
2828
return await _appContext
2929
.Set<TodoTaskEntity>()
3030
.Where(entity => entity.Id == taskId)
31-
.Select(entity => new F15TodoTaskModel
31+
.Select(entity => new TodoTaskModel
3232
{
3333
Content = entity.Content,
3434
DueDate = entity.DueDate,

Src/Core/F15/Mapper/F15HttpResponseMapper.cs renamed to Src/Core/F15/Mapper/HttpResponseMapper.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
namespace F15.Mapper;
1010

11-
public static class F15HttpResponseMapper
11+
public static class HttpResponseMapper
1212
{
1313
private static ConcurrentDictionary<
14-
F15Constant.AppCode,
15-
Func<F15AppRequestModel, F15AppResponseModel, HttpContext, F15Response>
14+
Constant.AppCode,
15+
Func<AppRequestModel, AppResponseModel, HttpContext, Response>
1616
> _httpResponseMapper;
1717

1818
private static void Init()
@@ -23,12 +23,12 @@ private static void Init()
2323
}
2424

2525
_httpResponseMapper.TryAdd(
26-
F15Constant.AppCode.SUCCESS,
26+
Constant.AppCode.SUCCESS,
2727
(appRequest, appResponse, httpContex) =>
2828
{
2929
return new()
3030
{
31-
AppCode = (int)F15Constant.AppCode.SUCCESS,
31+
AppCode = (int)Constant.AppCode.SUCCESS,
3232
HttpCode = StatusCodes.Status200OK,
3333
Body = new()
3434
{
@@ -49,23 +49,23 @@ private static void Init()
4949
);
5050

5151
_httpResponseMapper.TryAdd(
52-
F15Constant.AppCode.TASK_NOT_FOUND,
52+
Constant.AppCode.TASK_NOT_FOUND,
5353
(appRequest, appResponse, httpContex) =>
5454
{
55-
return F15Constant.DefaultResponse.Http.TASK_NOT_FOUND;
55+
return Constant.DefaultResponse.Http.TASK_NOT_FOUND;
5656
}
5757
);
5858
}
5959

60-
public static F15Response Get(
61-
F15AppRequestModel appRequest,
62-
F15AppResponseModel appResponse,
60+
public static Response Get(
61+
AppRequestModel appRequest,
62+
AppResponseModel appResponse,
6363
HttpContext httpContext
6464
)
6565
{
6666
Init();
6767

68-
var stateBag = httpContext.Items[nameof(F15StateBag)] as F15StateBag;
68+
var stateBag = httpContext.Items[nameof(StateBag)] as StateBag;
6969

7070
var httpResponse = _httpResponseMapper[appResponse.AppCode]
7171
(appRequest, appResponse, httpContext);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace F15.Models;
44

5-
public sealed class F15AppRequestModel : IServiceRequest<F15AppResponseModel>
5+
public sealed class AppRequestModel : IServiceRequest<AppResponseModel>
66
{
77
public long TodoTaskId { get; set; }
88
}

Src/Core/F15/Models/F15AppResponseModel.cs renamed to Src/Core/F15/Models/AppResponseModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace F15.Models;
66

7-
public sealed class F15AppResponseModel : IServiceResponse
7+
public sealed class AppResponseModel : IServiceResponse
88
{
9-
public F15Constant.AppCode AppCode { get; set; }
9+
public Constant.AppCode AppCode { get; set; }
1010

1111
public BodyModel Body { get; set; }
1212

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace F15.Models;
44

5-
public sealed class F15TodoTaskModel
5+
public sealed class TodoTaskModel
66
{
77
public long Id { get; set; }
88

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
namespace F15.Presentation;
1717

18-
public sealed class F15Endpoint : ControllerBase
18+
[Tags(Constant.CONTROLLER_NAME)]
19+
public sealed class Endpoint : ControllerBase
1920
{
20-
private readonly F15Service _service;
21+
private readonly Service _service;
2122

22-
public F15Endpoint(F15Service service)
23+
public Endpoint(Service service)
2324
{
2425
_service = service;
2526
}
@@ -41,22 +42,22 @@ public F15Endpoint(F15Service service)
4142
[ProducesResponseType(StatusCodes.Status200OK)]
4243
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
4344
[ProducesResponseType(StatusCodes.Status403Forbidden)]
44-
[ProducesResponseType(1, Type = typeof(F15Response))]
45+
[ProducesResponseType(1, Type = typeof(Response))]
4546
[Produces(MediaTypeNames.Application.Json)]
4647
// =============================================================
47-
[HttpGet(F15Constant.ENDPOINT_PATH)]
48+
[HttpGet(Constant.ENDPOINT_PATH)]
4849
[Authorize(Policy = nameof(DefaultAuthorizationRequirement))]
49-
[ServiceFilter<F15SetStateBagFilter>]
50-
[ServiceFilter<F15ValidationFilter>]
50+
[ServiceFilter<SetStateBagFilter>]
51+
[ServiceFilter<ValidationFilter>]
5152
public async Task<IActionResult> ExecuteF15Async(
52-
[Required] F15Request request,
53+
[Required] Request request,
5354
CancellationToken ct
5455
)
5556
{
56-
var appRequest = new F15AppRequestModel { TodoTaskId = request.TodoTaskId };
57+
var appRequest = new AppRequestModel { TodoTaskId = request.TodoTaskId };
5758
var appResponse = await _service.ExecuteAsync(appRequest, ct);
5859

59-
var httpResponse = F15HttpResponseMapper.Get(appRequest, appResponse, HttpContext);
60+
var httpResponse = HttpResponseMapper.Get(appRequest, appResponse, HttpContext);
6061

6162
return StatusCode(httpResponse.HttpCode, httpResponse);
6263
}

Src/Core/F15/Presentation/Filters/SetStateBag/F15StateBag.cs

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

0 commit comments

Comments
 (0)