Skip to content

Commit 7122218

Browse files
committed
minor fixes
1 parent 6f5547d commit 7122218

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Chapter 12/myProject/Sources/App/Modules/Api/Controllers/ApiListController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protocol ApiListController: ListController {
1818
extension ApiListController {
1919

2020
func listApi(_ req: Request) async throws -> [ListObject] {
21-
let models = try await DatabaseModel.query(on: req.db).all()
21+
let models = try await list(req)
2222
return try await listOutput(req, models)
2323
}
2424

Chapter 12/myProject/Sources/App/Modules/Blog/Controllers/BlogCategoryApiController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ struct BlogCategoryApiController: ApiController {
1414
typealias ApiModel = Blog.Category
1515
typealias DatabaseModel = BlogCategoryModel
1616

17-
func listOutput(_ req: Request, _ models: [BlogCategoryModel]) async throws -> [Blog.Category.List] {
17+
func listOutput(_ req: Request, _ models: [DatabaseModel]) async throws -> [Blog.Category.List] {
1818
models.map { .init(id: $0.id!, title: $0.title) }
1919
}
2020

21-
func detailOutput(_ req: Request, _ model: BlogCategoryModel) async throws -> Blog.Category.Detail {
21+
func detailOutput(_ req: Request, _ model: DatabaseModel) async throws -> Blog.Category.Detail {
2222
.init(id: model.id!, title: model.title)
2323
}
2424

25-
func createInput(_ req: Request, _ model: BlogCategoryModel, _ input: Blog.Category.Create) async throws {
25+
func createInput(_ req: Request, _ model: DatabaseModel, _ input: Blog.Category.Create) async throws {
2626
model.title = input.title
2727
}
2828

29-
func updateInput(_ req: Request, _ model: BlogCategoryModel, _ input: Blog.Category.Update) async throws {
29+
func updateInput(_ req: Request, _ model: DatabaseModel, _ input: Blog.Category.Update) async throws {
3030
model.title = input.title
3131
}
3232

33-
func patchInput(_ req: Request, _ model: BlogCategoryModel, _ input: Blog.Category.Patch) async throws {
33+
func patchInput(_ req: Request, _ model: DatabaseModel, _ input: Blog.Category.Patch) async throws {
3434
model.title = input.title ?? model.title
3535
}
3636
}

Chapter 12/myProject/Sources/App/Modules/Blog/Controllers/BlogPostApiController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct BlogPostApiController: ApiController {
1414
typealias ApiModel = Blog.Post
1515
typealias DatabaseModel = BlogPostModel
1616

17-
func listOutput(_ req: Request, _ models: [BlogPostModel]) async throws -> [Blog.Post.List] {
17+
func listOutput(_ req: Request, _ models: [DatabaseModel]) async throws -> [Blog.Post.List] {
1818
models.map { model in
1919
.init(id: model.id!,
2020
title: model.title,
@@ -25,7 +25,7 @@ struct BlogPostApiController: ApiController {
2525
}
2626
}
2727

28-
func detailOutput(_ req: Request, _ model: BlogPostModel) async throws -> Blog.Post.Detail {
28+
func detailOutput(_ req: Request, _ model: DatabaseModel) async throws -> Blog.Post.Detail {
2929
.init(id: model.id!,
3030
title: model.title,
3131
slug: model.slug,
@@ -37,15 +37,15 @@ struct BlogPostApiController: ApiController {
3737
content: model.content)
3838
}
3939

40-
func createInput(_ req: Request, _ model: BlogPostModel, _ input: Blog.Post.Create) async throws {
40+
func createInput(_ req: Request, _ model: DatabaseModel, _ input: Blog.Post.Create) async throws {
4141
model.title = input.title
4242
}
4343

44-
func updateInput(_ req: Request, _ model: BlogPostModel, _ input: Blog.Post.Update) async throws {
44+
func updateInput(_ req: Request, _ model: DatabaseModel, _ input: Blog.Post.Update) async throws {
4545
model.title = input.title
4646
}
4747

48-
func patchInput(_ req: Request, _ model: BlogPostModel, _ input: Blog.Post.Patch) async throws {
48+
func patchInput(_ req: Request, _ model: DatabaseModel, _ input: Blog.Post.Patch) async throws {
4949
model.title = input.title ?? model.title
5050
}
5151
}

0 commit comments

Comments
 (0)