added UserController, UserDTO, CreateUser migration, User model
This commit is contained in:
1 parent
6357258f45
commit
56d1988b17
13 files changed
+297
-159
No files matched your search
@@ -1,29 +0,0 @@
|
||||
import Fluent
|
||||
import struct Foundation.UUID
|
||||
|
||||
/// Property wrappers interact poorly with `Sendable` checking, causing a warning for the `@ID` property
|
||||
/// It is recommended you write your model with sendability checking on and then suppress the warning
|
||||
/// afterwards with `@unchecked Sendable`.
|
||||
final class Todo: Model, @unchecked Sendable {
|
||||
static let schema = "todos"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "title")
|
||||
var title: String
|
||||
|
||||
init() { }
|
||||
|
||||
init(id: UUID? = nil, title: String) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
}
|
||||
|
||||
func toDTO() -> TodoDTO {
|
||||
.init(
|
||||
id: self.id,
|
||||
title: self.$title.value
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import Fluent
|
||||
|
||||
import struct Foundation.UUID
|
||||
|
||||
final class User: Model, @unchecked Sendable {
|
||||
static let schema = "users"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "username")
|
||||
var username: String
|
||||
|
||||
@Field(key: "email")
|
||||
var email: String
|
||||
|
||||
@Field(key: "password")
|
||||
var password: String
|
||||
|
||||
@Field(key: "group")
|
||||
var group: String
|
||||
|
||||
@Field(key: "is_superuser")
|
||||
var isSuperuser: Bool
|
||||
|
||||
init() {}
|
||||
|
||||
init(
|
||||
id: UUID? = nil, username: String, email: String, password: String, group: String,
|
||||
isSuperuser: Bool
|
||||
) {
|
||||
self.id = id
|
||||
self.username = username
|
||||
self.email = email
|
||||
self.password = password
|
||||
self.group = group
|
||||
self.isSuperuser = isSuperuser
|
||||
}
|
||||
|
||||
func toDTO() -> UserDTO {
|
||||
.init(
|
||||
id: self.id,
|
||||
username: self.username,
|
||||
email: self.email,
|
||||
group: self.group,
|
||||
isSuperuser: self.isSuperuser
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user