Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit b5d77dc

Browse files
committed
Merge vapor-3 into feature/align-with-submissions
2 parents 78c98df + 328ad1d commit b5d77dc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Sources/AdminPanel/Models/AdminPanelUserRole/AdminPanelUserRole.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Core
1+
import MySQL
2+
import Vapor
23

34
public enum AdminPanelUserRole: String {
45
case superAdmin
@@ -63,3 +64,16 @@ extension AdminPanelUserRole: AdminPanelUserRoleType {
6364
return lhs.weight == rhs.weight
6465
}
6566
}
67+
68+
extension AdminPanelUserRole: MySQLDataConvertible {
69+
public func convertToMySQLData() -> MySQLData {
70+
return MySQLData(string: self.rawValue)
71+
}
72+
73+
public static func convertFromMySQLData(_ mysqlData: MySQLData) throws -> AdminPanelUserRole {
74+
guard let role = AdminPanelUserRole(rawValue: mysqlData.string()) else {
75+
throw Abort(.internalServerError, reason: "Could not convert MySQLData to AdminPanelUserRole")
76+
}
77+
return role
78+
}
79+
}

0 commit comments

Comments
 (0)