diff --git a/Sources/App/Controllers/TodoController.swift b/Sources/App/Controllers/TodoController.swift deleted file mode 100644 index 265228d..0000000 --- a/Sources/App/Controllers/TodoController.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Fluent -import Vapor - -struct TodoController: RouteCollection { - func boot(routes: RoutesBuilder) throws { - let todos = routes.grouped("todos") - todos.get(use: index) - todos.post(use: create) - todos.group(":todoID") { todo in - todo.delete(use: delete) - } - } - - func index(req: Request) async throws -> [Todo] { - try await Todo.query(on: req.db).all() - } - - func create(req: Request) async throws -> Todo { - let todo = try req.content.decode(Todo.self) - try await todo.save(on: req.db) - return todo - } - - func delete(req: Request) async throws -> HTTPStatus { - guard let todo = try await Todo.find(req.parameters.get("todoID"), on: req.db) else { - throw Abort(.notFound) - } - try await todo.delete(on: req.db) - return .noContent - } -} diff --git a/Sources/App/Controllers/cntrlCategory.swift b/Sources/App/Controllers/cntrlCategory.swift new file mode 100644 index 0000000..e6c7eae --- /dev/null +++ b/Sources/App/Controllers/cntrlCategory.swift @@ -0,0 +1,44 @@ +import Fluent +import Vapor + +struct cntrlCategory: RouteCollection { + func boot(routes: RoutesBuilder) throws { + let rts = routes.grouped("categories") + rts.get(use: index) + rts.post(use: create) + rts.put(use: update) + rts.group(":id") { todo in + rts.delete(use: delete) + } + } + + func index(req: Request) async throws -> [mdlCategory] { + try await mdlCategory.query(on: req.db).all() + } + + func create(req: Request) async throws -> mdlCategory { + let obj = try req.content.decode(mdlCategory.self) + try await obj.save(on: req.db) + return obj + } + func update(req: Request) async throws -> mdlCategory{ + let obj = try req.content.decode(mdlCategory.self) + let dbobj = try await mdlCategory.query(on: req.db).filter(\.$id == obj.id!).first()! + dbobj.description = obj.description + dbobj.name = obj.name + dbobj.updatedate = Date() + dbobj.isactive = obj.isactive + dbobj.updateuserid = -1 + try await dbobj.update(on: req.db) + return dbobj + + } + + func delete(req: Request) async throws -> HTTPStatus { + guard let obj = try await mdlCategory.find(req.parameters.get("id"), on: req.db) else { + throw Abort(.notFound) + } + try await obj.delete(on: req.db) + return .noContent + } +} diff --git a/Sources/App/Controllers/cntrlDataType.swift b/Sources/App/Controllers/cntrlDataType.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Controllers/cntrlDataType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Controllers/cntrlValueType.swift b/Sources/App/Controllers/cntrlValueType.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Controllers/cntrlValueType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Migrations/CreateTodo.swift b/Sources/App/Migrations/CreateTodo.swift deleted file mode 100644 index bf6d945..0000000 --- a/Sources/App/Migrations/CreateTodo.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Fluent - -struct CreateTodo: AsyncMigration { - func prepare(on database: Database) async throws { - try await database.schema("todos") - .id() - .field("title", .string, .required) - .create() - } - - func revert(on database: Database) async throws { - try await database.schema("todos").delete() - } -} diff --git a/Sources/App/Migrations/migRelations.swift b/Sources/App/Migrations/migRelations.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Migrations/migRelations.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/AuthTables/mdlRole.swift b/Sources/App/Models/AuthTables/mdlRole.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/AuthTables/mdlRole.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/AuthTables/mdlSegment.swift b/Sources/App/Models/AuthTables/mdlSegment.swift new file mode 100644 index 0000000..27f6a9d --- /dev/null +++ b/Sources/App/Models/AuthTables/mdlSegment.swift @@ -0,0 +1,86 @@ +// +// mdlSegment.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlSegment: Model, Content { + static let schema = "segment" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "code") var code: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Siblings(through: mdlXWorkOrderSegment.self, from: \.$segment, to: \.$workorder) var workorders: [mdlWorkOrder] + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, code: String? = nil, description: String? = nil, isactive: Bool? = true, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.code = code + self.description = description + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlSegment{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("segment") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("code", .string) + .field("description", .string) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("segment").delete() + } + } + struct Seed: Migration{ + func prepare(on database: Database) -> EventLoopFuture { + let mdls: [mdlSegment] = [ + .init(id: nil, name: "Inspection", code: "0001", description: nil, createuserid: -1, updateuserid: -1), + .init(id: nil, name: "Oil Sample", code: "0002", description: nil, createuserid: -1, updateuserid: -1), + .init(id: nil, name: "Consumption", code: "0003", description: nil, createuserid: -1, updateuserid: -1), + .init(id: nil, name: "Part", code: "0004", description: nil, createuserid: -1, updateuserid: -1) + ] + return mdls.map { mdl in + mdl.save(on: database) + } + .flatten(on: database.eventLoop) + } + + func revert(on database: Database) -> EventLoopFuture { + mdlSegment.query(on: database).delete() + } + } +} + + + diff --git a/Sources/App/Models/AuthTables/mdlUser.swift b/Sources/App/Models/AuthTables/mdlUser.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/AuthTables/mdlUser.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/ChildTables/mdlResponseType.swift b/Sources/App/Models/BaseTables/ChildTables/mdlResponseType.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/BaseTables/ChildTables/mdlResponseType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/ChildTables/mdlUnit.swift b/Sources/App/Models/BaseTables/ChildTables/mdlUnit.swift new file mode 100644 index 0000000..bd0e2e4 --- /dev/null +++ b/Sources/App/Models/BaseTables/ChildTables/mdlUnit.swift @@ -0,0 +1,67 @@ +// +// mdlUnit.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlUnit: Model, Content { + static let schema = "unit" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Parent(key: "dataTypeId") var datatype: mdlDataType + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, isactive: Bool? = nil, datatypeid: Int? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.isactive = isactive + self.$datatype.$id.value = datatypeid! + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlUnit{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("unit") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("isActive", .bool) + .field("dataTypeId", .int) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("unit").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlCategory.swift b/Sources/App/Models/BaseTables/mdlCategory.swift new file mode 100644 index 0000000..9c2b3ae --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlCategory.swift @@ -0,0 +1,35 @@ +// +// Category.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor + +final class Category: Model, Content { + static let schema = "category" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, isactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + self.name = name + self.description = description + self.isactive = isactive + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} diff --git a/Sources/App/Models/BaseTables/mdlComparisonType.swift b/Sources/App/Models/BaseTables/mdlComparisonType.swift new file mode 100644 index 0000000..5003818 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlComparisonType.swift @@ -0,0 +1,35 @@ +// +// ComparisonType.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor + +final class ComparisonType: Model, Content { + static let schema = "comparisonType" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "creteUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} diff --git a/Sources/App/Models/BaseTables/mdlContactType.swift b/Sources/App/Models/BaseTables/mdlContactType.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlContactType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlDataType.swift b/Sources/App/Models/BaseTables/mdlDataType.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlDataType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlDivision.swift b/Sources/App/Models/BaseTables/mdlDivision.swift new file mode 100644 index 0000000..93ed217 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlDivision.swift @@ -0,0 +1,63 @@ +// +// mdlDivision.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlDivision: Model, Content { + static let schema = "division" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, isactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlDivision{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("division") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("division").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlEquipmentType.swift b/Sources/App/Models/BaseTables/mdlEquipmentType.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlEquipmentType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlFluid.swift b/Sources/App/Models/BaseTables/mdlFluid.swift new file mode 100644 index 0000000..86c101e --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlFluid.swift @@ -0,0 +1,66 @@ +// +// mdlFluid.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlFluid: Model, Content { + static let schema = "fluid" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "sortOrder") var sortorder: Int? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, sortorder: Int? = nil, isactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.sortorder = sortorder + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlFluid{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("fluid") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("sortOrder", .int) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("fluid").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlFuel.swift b/Sources/App/Models/BaseTables/mdlFuel.swift new file mode 100644 index 0000000..4b56074 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlFuel.swift @@ -0,0 +1,66 @@ +// +// mdlFuel.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlFuel: Model, Content { + static let schema = "fuel" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "sortOrder") var sortorder: Int? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, sortorder: Int? = nil, isactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.sortorder = sortorder + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlFuel{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("fuel") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("sortOrder", .int) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("fuel").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlGate.swift b/Sources/App/Models/BaseTables/mdlGate.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlGate.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlIncompleteReason.swift b/Sources/App/Models/BaseTables/mdlIncompleteReason.swift new file mode 100644 index 0000000..8364f18 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlIncompleteReason.swift @@ -0,0 +1,63 @@ +// +// mdlIncompleteReason.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlIncompleteReason: Model, Content { + static let schema = "incompleteReason" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, isactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlIncompleteReason{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("incompleteReason") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("incompleteReason").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlInputType.swift b/Sources/App/Models/BaseTables/mdlInputType.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlInputType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlJobSite.swift b/Sources/App/Models/BaseTables/mdlJobSite.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlJobSite.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlLevel.swift b/Sources/App/Models/BaseTables/mdlLevel.swift new file mode 100644 index 0000000..7a065c1 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlLevel.swift @@ -0,0 +1,66 @@ +// +// mdlLevel.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlLevel: Model, Content { + static let schema = "level" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "sortOrder") var sortorder: Int? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, sortorder: Int? = nil, isactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.sortorder = sortorder + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlLevel{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("level") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("sortOrder", .int) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("level").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlLocation.swift b/Sources/App/Models/BaseTables/mdlLocation.swift new file mode 100644 index 0000000..9a012d5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlLocation.swift @@ -0,0 +1,103 @@ +// +// mdlLocation.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlLocation: Model, Content { + static let schema = "location" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "address") var address: String? + @Field(key: "address2") var address2: String? + @Field(key: "city") var city: String? + @Field(key: "postalCode") var postalcode: String? + @Field(key: "dealerCode") var dealercode: String? + @Field(key: "fileLocation") var filelocation: String? + @Field(key: "isAcrtive") var isactive: Bool? + @Parent(key: "stateId") var state: mdlState + @OptionalParent(key: "unitId") var unit: mdlUnit? + @OptionalParent(key: "labSettingId") var labsetting: mdlLabSetting? + + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, + name: String? = nil, + address: String? = nil, + address2: String? = nil, + city: String? = nil, + postalcode: String? = nil, + dealercode: String? = nil, + filelocation: String? = nil, + isactive: Bool? = nil, + createuserid: Int? = nil, + updateuserid: Int? = nil, + stateid: Int? = nil, + unitid: Int? = nil, + labsettingid: Int? = nil + ) { + self.id = id + + self.name = name + self.address = address + self.address2 = address2 + self.city = city + self.postalcode = postalcode + self.dealercode = dealercode + self.filelocation = filelocation + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + + self.$state.$id.value = stateid! + self.$unit.$id.value = unitid! + self.$labsetting.$id.value = labsettingid! + } +} + +extension mdlLocation{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("location") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("address", .string) + .field("address2", .string) + .field("city", .string) + .field("postalCode", .string) + .field("dealerCode", .string) + .field("fileLocation", .string) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .field("stateId", .int) + .field("unitId", .int) + .field("labSettingId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("location").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlNoteType.swift b/Sources/App/Models/BaseTables/mdlNoteType.swift new file mode 100644 index 0000000..166485b --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlNoteType.swift @@ -0,0 +1,63 @@ +// +// mdlNoteType.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlNoteType: Model, Content { + static let schema = "noteType" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, isactive: Bool? = true, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlNoteType{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("noteType") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("noteType").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlPart.swift b/Sources/App/Models/BaseTables/mdlPart.swift new file mode 100644 index 0000000..323157a --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlPart.swift @@ -0,0 +1,63 @@ +// +// mdlPart.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlPart: Model, Content { + static let schema = "part" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, isactive: Bool? = true, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} + +extension mdlPart{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("part") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("isActive", .bool) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("part").delete() + } + } +} + + + diff --git a/Sources/App/Models/BaseTables/mdlPriority.swift b/Sources/App/Models/BaseTables/mdlPriority.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlPriority.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlReason.swift b/Sources/App/Models/BaseTables/mdlReason.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlReason.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlRepairType.swift b/Sources/App/Models/BaseTables/mdlRepairType.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlRepairType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlSMSCCode.swift b/Sources/App/Models/BaseTables/mdlSMSCCode.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlSMSCCode.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlSignatureType.swift b/Sources/App/Models/BaseTables/mdlSignatureType.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlSignatureType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlState.swift b/Sources/App/Models/BaseTables/mdlState.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlState.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlStatus.swift b/Sources/App/Models/BaseTables/mdlStatus.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlStatus.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlValueType.swift b/Sources/App/Models/BaseTables/mdlValueType.swift new file mode 100644 index 0000000..a2029e5 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlValueType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/25/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlViscosity.swift b/Sources/App/Models/BaseTables/mdlViscosity.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlViscosity.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/CompartmentModule/mdlCompartment.swift b/Sources/App/Models/CompartmentModule/mdlCompartment.swift new file mode 100644 index 0000000..2db5a50 --- /dev/null +++ b/Sources/App/Models/CompartmentModule/mdlCompartment.swift @@ -0,0 +1,41 @@ +// +// Compartment.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor + +final class Compartment: Model, Content { + static let schema = "compartment" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "code") var code: String? + @Field(key: "sortOrder") var sortorder: Int? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, code: String? = nil, sortorder: Int?, isactive: Bool?, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.code = code + self.sortorder = sortorder + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} diff --git a/Sources/App/Models/CompartmentModule/mdlCompartmentLocation.swift b/Sources/App/Models/CompartmentModule/mdlCompartmentLocation.swift new file mode 100644 index 0000000..9a43532 --- /dev/null +++ b/Sources/App/Models/CompartmentModule/mdlCompartmentLocation.swift @@ -0,0 +1,41 @@ +// +// CompartmentLocation.swift +// +// +// Created by Michiel Carman on 1/24/24. +// + +import Fluent +import Vapor + +final class CompartmentLocation: Model, Content { + static let schema = "compartmentLocation" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + @Field(key: "code") var code: String? + @Field(key: "sortOrder") var sortorder: Int? + @Field(key: "isActive") var isactive: Bool? + + @Timestamp(key: "createDate", on: .create) var createdate: Date? + @Field(key: "createUserId") var createuserid: Int? + @Timestamp(key: "updateDate", on: .update) var updatedate: Date? + @Field(key: "updateUserId") var updateuserid: Int? + + init() { } + + init(id: Int? = nil, name: String? = nil, description: String? = nil, code: String? = nil, sortorder: Int?, isactive: Bool?, createuserid: Int? = nil, updateuserid: Int? = nil) { + self.id = id + + self.name = name + self.description = description + self.code = code + self.sortorder = sortorder + self.isactive = isactive + + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} diff --git a/Sources/App/Models/CustomerTables/mdlContact.swift b/Sources/App/Models/CustomerTables/mdlContact.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlContact.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlContactInfo.swift b/Sources/App/Models/CustomerTables/mdlContactInfo.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlContactInfo.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlCustomer.swift b/Sources/App/Models/CustomerTables/mdlCustomer.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlCustomer.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlEquipment.swift b/Sources/App/Models/CustomerTables/mdlEquipment.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlEquipment.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlMake.swift b/Sources/App/Models/CustomerTables/mdlMake.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlMake.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlModel.swift b/Sources/App/Models/CustomerTables/mdlModel.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlModel.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlObjectProperty.swift b/Sources/App/Models/CustomerTables/mdlObjectProperty.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlObjectProperty.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/CustomerTables/mdlProduct.swift b/Sources/App/Models/CustomerTables/mdlProduct.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/CustomerTables/mdlProduct.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/ItemTables/mdlItem.swift b/Sources/App/Models/ItemTables/mdlItem.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/ItemTables/mdlItem.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/ItemTables/mdlItemResponseType.swift b/Sources/App/Models/ItemTables/mdlItemResponseType.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/ItemTables/mdlItemResponseType.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/LabTables/mdlLabSetting.swift b/Sources/App/Models/LabTables/mdlLabSetting.swift new file mode 100644 index 0000000..6f0e740 --- /dev/null +++ b/Sources/App/Models/LabTables/mdlLabSetting.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/26/24. +// + +import Foundation diff --git a/Sources/App/Models/LinkingTables/XFluidViscosity.swift b/Sources/App/Models/LinkingTables/XFluidViscosity.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/LinkingTables/XFluidViscosity.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/LinkingTables/XUserRole.swift b/Sources/App/Models/LinkingTables/XUserRole.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/LinkingTables/XUserRole.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/LinkingTables/XWorkOrderSegment.swift b/Sources/App/Models/LinkingTables/XWorkOrderSegment.swift new file mode 100644 index 0000000..676152d --- /dev/null +++ b/Sources/App/Models/LinkingTables/XWorkOrderSegment.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 2/1/24. +// + +import Foundation diff --git a/Sources/App/Models/OilSampleTables/mdlOilSample.swift b/Sources/App/Models/OilSampleTables/mdlOilSample.swift new file mode 100644 index 0000000..676152d --- /dev/null +++ b/Sources/App/Models/OilSampleTables/mdlOilSample.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 2/1/24. +// + +import Foundation diff --git a/Sources/App/Models/SpecTables/mdlSpec.swift b/Sources/App/Models/SpecTables/mdlSpec.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/SpecTables/mdlSpec.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/SpecTables/mdlSpecItem.swift b/Sources/App/Models/SpecTables/mdlSpecItem.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/SpecTables/mdlSpecItem.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/SpecTables/mdlSpecItemValue.swift b/Sources/App/Models/SpecTables/mdlSpecItemValue.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/SpecTables/mdlSpecItemValue.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation diff --git a/Sources/App/Models/Todo.swift b/Sources/App/Models/Todo.swift deleted file mode 100644 index c3c9eac..0000000 --- a/Sources/App/Models/Todo.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Fluent -import Vapor - -final class Todo: Model, Content { - 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 - } -} diff --git a/Sources/App/Models/WorkOrderTables/mdlWorkOrder.swift b/Sources/App/Models/WorkOrderTables/mdlWorkOrder.swift new file mode 100644 index 0000000..a843f95 --- /dev/null +++ b/Sources/App/Models/WorkOrderTables/mdlWorkOrder.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 1/31/24. +// + +import Foundation