| @@ -12,33 +12,30 @@ struct cntrlRole: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("roles") | let rts = routes.grouped("roles") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { todo in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlRole] { | func index(req: Request) async throws -> [mdlRole] { | ||||
| try await mdlRole.query(on: req.db).with(\.$users).all() | |||||
| try await mdlRole.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlRole{ | |||||
| return try await mdlRole.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlRole { | func create(req: Request) async throws -> mdlRole { | ||||
| let obj = try req.content.decode(mdlRole.self) | let obj = try req.content.decode(mdlRole.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlRole{ | |||||
| let obj = try req.content.decode(mdlRole.self) | |||||
| let dbobj = try await mdlRole.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.description = obj.description | |||||
| dbobj.name = obj.name | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlRole.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlRole.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSegment: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("segments") | let rts = routes.grouped("segments") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSegment] { | func index(req: Request) async throws -> [mdlSegment] { | ||||
| try await mdlSegment.query(on: req.db).all() | |||||
| try await mdlSegment.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSegment{ | |||||
| return try await mdlSegment.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSegment { | func create(req: Request) async throws -> mdlSegment { | ||||
| let obj = try req.content.decode(mdlSegment.self) | let obj = try req.content.decode(mdlSegment.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSegment{ | |||||
| let obj = try req.content.decode(mdlSegment.self) | |||||
| let dbobj = try await mdlSegment.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSegment.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSegment.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -15,59 +15,29 @@ struct cntrlUser: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("users") | let rts = routes.grouped("users") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get("login", ":credentials", use: login) | |||||
| rts.get("login", ":x", use: login) | |||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { todo in | |||||
| rts.group(":x") { todo in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| rts.get("api", use: api) | |||||
| //let encryptionKey = SymmetricKey(data: Environment.get("ENCRYPTION_KEY")!.data(using: .utf8)!) | |||||
| // rts.get(use: "login"){ | |||||
| // req -> String in guard let dataQuery = req.query[String.self, at: "data"], let data = Data(base64Encoded: dataQuery) else{ | |||||
| // throw Abort(.badRequest) | |||||
| // } | |||||
| // let encryptionKey = SymmetricKey(size: .bits256) { | |||||
| // let sealedBox = try AES.GCM.SealedBox(combined: data) | |||||
| // let decryptedData = try AES.GCM.open(sealedBox, using: encryptionKey) | |||||
| // guard let decryptedString = String(data: decryptedData, encoding: .utf8) else{ | |||||
| // throw Abort(.internalServerError, "Failed to decode decrypted data.") | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| } | } | ||||
| func api(req: Request) async throws -> String{ | func api(req: Request) async throws -> String{ | ||||
| return Environment.get("API_KEY")! | return Environment.get("API_KEY")! | ||||
| } | } | ||||
| func login(req: Request) async throws -> mdlUser{ | func login(req: Request) async throws -> mdlUser{ | ||||
| guard let dataQuery = req.parameters.get("credentials") else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery) | |||||
| let credentials = decryptedString.components(separatedBy: ":") | |||||
| guard credentials.count == 2 else { | |||||
| throw Abort(.badRequest, reason: "Invalid credential format.") | |||||
| } | |||||
| let username = credentials[0] | |||||
| let password = credentials[1] | |||||
| return try await mdlUser.query(on: req.db) | |||||
| .with(\.$roles) | |||||
| .with(\.$division) | |||||
| .with(\.$gate) | |||||
| .with(\.$location) | |||||
| .filter(\.$username == username) | |||||
| .filter( \.$password == password) | |||||
| .first()! | |||||
| return try await mdlUser.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlUser] { | func index(req: Request) async throws -> [mdlUser] { | ||||
| try await mdlUser.query(on: req.db).with(\.$roles).all() | |||||
| //try await mdlUser.query(on: req.db).with(\.$roles).all() | |||||
| return try await mdlUser.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlUser{ | |||||
| return try await mdlUser.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlUser { | func create(req: Request) async throws -> mdlUser { | ||||
| @@ -78,22 +48,10 @@ struct cntrlUser: RouteCollection { | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlUser{ | |||||
| let obj = try req.content.decode(mdlUser.self) | |||||
| let dbobj = try await mdlUser.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.firstname = obj.firstname | |||||
| dbobj.lastname = obj.lastname | |||||
| dbobj.email = obj.email | |||||
| dbobj.password = obj.password | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlUser.find(req.parameters.get("id"), on: req.db) else { | |||||
| guard let obj = try await mdlUser.find(req.parameters.get("x"), on: req.db) else { | |||||
| throw Abort(.notFound) | throw Abort(.notFound) | ||||
| } | } | ||||
| try await obj.delete(on: req.db) | try await obj.delete(on: req.db) | ||||
| @@ -12,32 +12,30 @@ struct cntrlResponseType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("responsetypes") | let rts = routes.grouped("responsetypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlResponseType] { | func index(req: Request) async throws -> [mdlResponseType] { | ||||
| try await mdlResponseType.query(on: req.db).all() | |||||
| try await mdlResponseType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlResponseType{ | |||||
| return try await mdlResponseType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlResponseType { | func create(req: Request) async throws -> mdlResponseType { | ||||
| let obj = try req.content.decode(mdlResponseType.self) | let obj = try req.content.decode(mdlResponseType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlResponseType{ | |||||
| let obj = try req.content.decode(mdlResponseType.self) | |||||
| let dbobj = try await mdlResponseType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlResponseType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlResponseType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlUnit: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("units") | let rts = routes.grouped("units") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlUnit] { | func index(req: Request) async throws -> [mdlUnit] { | ||||
| try await mdlUnit.query(on: req.db).all() | |||||
| try await mdlUnit.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlUnit{ | |||||
| return try await mdlUnit.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlUnit { | func create(req: Request) async throws -> mdlUnit { | ||||
| let obj = try req.content.decode(mdlUnit.self) | let obj = try req.content.decode(mdlUnit.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlUnit{ | |||||
| let obj = try req.content.decode(mdlUnit.self) | |||||
| let dbobj = try await mdlUnit.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlUnit.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlUnit.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -5,34 +5,30 @@ struct cntrlCategory: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("categories") | let rts = routes.grouped("categories") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { todo in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlCategory] { | func index(req: Request) async throws -> [mdlCategory] { | ||||
| try await mdlCategory.query(on: req.db).all() | |||||
| try await mdlCategory.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlCategory{ | |||||
| return try await mdlCategory.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlCategory { | func create(req: Request) async throws -> mdlCategory { | ||||
| let obj = try req.content.decode(mdlCategory.self) | let obj = try req.content.decode(mdlCategory.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | 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 { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlCategory.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlCategory.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -10,34 +10,32 @@ import Vapor | |||||
| struct cntrlComparisonType: RouteCollection { | struct cntrlComparisonType: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("comparisonTypes") | |||||
| let rts = routes.grouped("comparisontypes") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlComparisonType] { | func index(req: Request) async throws -> [mdlComparisonType] { | ||||
| try await mdlComparisonType.query(on: req.db).all() | |||||
| try await mdlComparisonType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlComparisonType{ | |||||
| return try await mdlComparisonType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlComparisonType { | func create(req: Request) async throws -> mdlComparisonType { | ||||
| let obj = try req.content.decode(mdlComparisonType.self) | let obj = try req.content.decode(mdlComparisonType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlComparisonType{ | |||||
| let obj = try req.content.decode(mdlComparisonType.self) | |||||
| let dbobj = try await mdlComparisonType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlComparisonType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlComparisonType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -10,34 +10,32 @@ import Vapor | |||||
| struct cntrlContactType: RouteCollection { | struct cntrlContactType: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("contactTypes") | |||||
| let rts = routes.grouped("contacttypes") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlContactType] { | func index(req: Request) async throws -> [mdlContactType] { | ||||
| try await mdlContactType.query(on: req.db).all() | |||||
| try await mdlContactType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlContactType{ | |||||
| return try await mdlContactType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlContactType { | func create(req: Request) async throws -> mdlContactType { | ||||
| let obj = try req.content.decode(mdlContactType.self) | let obj = try req.content.decode(mdlContactType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlContactType{ | |||||
| let obj = try req.content.decode(mdlContactType.self) | |||||
| let dbobj = try await mdlContactType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlContactType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlContactType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -3,43 +3,32 @@ import Vapor | |||||
| struct cntrlDataTypes: RouteCollection { | struct cntrlDataTypes: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("dataTypes") | |||||
| let rts = routes.grouped("datatypes") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":id", use: search) | |||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rt.delete(use: delete) | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlDataType] { | func index(req: Request) async throws -> [mdlDataType] { | ||||
| try await mdlDataType.query(on: req.db).with(\.$units).all() | |||||
| try await mdlDataType.ObjQuery(req: req).with(\.$units).all() | |||||
| } | } | ||||
| func search(req: Request) async throws -> mdlDataType{ | |||||
| guard let id = req.parameters.get("id", as: Int.self) else{ | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| return try await mdlDataType.query(on: req.db).with(\.$units).filter(\.$id == id).first()! | |||||
| func read(req:Request) async throws -> mdlDataType{ | |||||
| return try await mdlDataType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlDataType { | func create(req: Request) async throws -> mdlDataType { | ||||
| let obj = try req.content.decode(mdlDataType.self) | let obj = try req.content.decode(mdlDataType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlDataType{ | |||||
| let obj = try req.content.decode(mdlDataType.self) | |||||
| let dbobj = try await mdlDataType.query(on: req.db).with(\.$units).filter(\.$id == obj.id!).first()! | |||||
| dbobj.description = obj.description | |||||
| dbobj.name = obj.name | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlDataType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlDataType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlDivision: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("divisions") | let rts = routes.grouped("divisions") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlDivision] { | func index(req: Request) async throws -> [mdlDivision] { | ||||
| try await mdlDivision.query(on: req.db).all() | |||||
| try await mdlDivision.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlDivision{ | |||||
| return try await mdlDivision.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlDivision { | func create(req: Request) async throws -> mdlDivision { | ||||
| let obj = try req.content.decode(mdlDivision.self) | let obj = try req.content.decode(mdlDivision.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlDivision{ | |||||
| let obj = try req.content.decode(mdlDivision.self) | |||||
| let dbobj = try await mdlDivision.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlDivision.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlDivision.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlEquipmentType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("equipmenttypes") | let rts = routes.grouped("equipmenttypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlEquipmentType] { | func index(req: Request) async throws -> [mdlEquipmentType] { | ||||
| try await mdlEquipmentType.query(on: req.db).all() | |||||
| try await mdlEquipmentType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlEquipmentType{ | |||||
| return try await mdlEquipmentType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlEquipmentType { | func create(req: Request) async throws -> mdlEquipmentType { | ||||
| let obj = try req.content.decode(mdlEquipmentType.self) | let obj = try req.content.decode(mdlEquipmentType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlEquipmentType{ | |||||
| let obj = try req.content.decode(mdlEquipmentType.self) | |||||
| let dbobj = try await mdlEquipmentType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlEquipmentType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlEquipmentType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlFluid: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("fluids") | let rts = routes.grouped("fluids") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlFluid] { | func index(req: Request) async throws -> [mdlFluid] { | ||||
| try await mdlFluid.query(on: req.db).all() | |||||
| try await mdlFluid.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlFluid{ | |||||
| return try await mdlFluid.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlFluid { | func create(req: Request) async throws -> mdlFluid { | ||||
| let obj = try req.content.decode(mdlFluid.self) | let obj = try req.content.decode(mdlFluid.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlFluid{ | |||||
| let obj = try req.content.decode(mdlFluid.self) | |||||
| let dbobj = try await mdlFluid.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlFluid.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlFluid.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlFuel: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("fuels") | let rts = routes.grouped("fuels") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlFuel] { | func index(req: Request) async throws -> [mdlFuel] { | ||||
| try await mdlFuel.query(on: req.db).all() | |||||
| try await mdlFuel.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlFuel{ | |||||
| return try await mdlFuel.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlFuel { | func create(req: Request) async throws -> mdlFuel { | ||||
| let obj = try req.content.decode(mdlFuel.self) | let obj = try req.content.decode(mdlFuel.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlFuel{ | |||||
| let obj = try req.content.decode(mdlFuel.self) | |||||
| let dbobj = try await mdlFuel.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlFuel.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlFuel.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlGate: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("gates") | let rts = routes.grouped("gates") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlGate] { | func index(req: Request) async throws -> [mdlGate] { | ||||
| try await mdlGate.query(on: req.db).all() | |||||
| try await mdlGate.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlGate{ | |||||
| return try await mdlGate.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlGate { | func create(req: Request) async throws -> mdlGate { | ||||
| let obj = try req.content.decode(mdlGate.self) | let obj = try req.content.decode(mdlGate.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlGate{ | |||||
| let obj = try req.content.decode(mdlGate.self) | |||||
| let dbobj = try await mdlGate.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlGate.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlGate.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,15 +12,20 @@ struct cntrlIncompleteReason: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("incompletereasons") | let rts = routes.grouped("incompletereasons") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlIncompleteReason] { | func index(req: Request) async throws -> [mdlIncompleteReason] { | ||||
| try await mdlIncompleteReason.query(on: req.db).all() | |||||
| try await mdlIncompleteReason.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlIncompleteReason{ | |||||
| return try await mdlIncompleteReason.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlIncompleteReason { | func create(req: Request) async throws -> mdlIncompleteReason { | ||||
| @@ -28,16 +33,6 @@ struct cntrlIncompleteReason: RouteCollection { | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlIncompleteReason{ | |||||
| let obj = try req.content.decode(mdlIncompleteReason.self) | |||||
| let dbobj = try await mdlIncompleteReason.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlIncompleteReason.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlIncompleteReason.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInputType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inputtypes") | let rts = routes.grouped("inputtypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInputType] { | func index(req: Request) async throws -> [mdlInputType] { | ||||
| try await mdlInputType.query(on: req.db).all() | |||||
| try await mdlInputType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInputType{ | |||||
| return try await mdlInputType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInputType { | func create(req: Request) async throws -> mdlInputType { | ||||
| let obj = try req.content.decode(mdlInputType.self) | let obj = try req.content.decode(mdlInputType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInputType{ | |||||
| let obj = try req.content.decode(mdlInputType.self) | |||||
| let dbobj = try await mdlInputType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInputType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInputType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlJobSite: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("jobsites") | let rts = routes.grouped("jobsites") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlJobSite] { | func index(req: Request) async throws -> [mdlJobSite] { | ||||
| try await mdlJobSite.query(on: req.db).all() | |||||
| try await mdlJobSite.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlJobSite{ | |||||
| return try await mdlJobSite.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlJobSite { | func create(req: Request) async throws -> mdlJobSite { | ||||
| let obj = try req.content.decode(mdlJobSite.self) | let obj = try req.content.decode(mdlJobSite.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlJobSite{ | |||||
| let obj = try req.content.decode(mdlJobSite.self) | |||||
| let dbobj = try await mdlJobSite.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlJobSite.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlJobSite.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlLevel: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("levels") | let rts = routes.grouped("levels") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlLevel] { | func index(req: Request) async throws -> [mdlLevel] { | ||||
| try await mdlLevel.query(on: req.db).all() | try await mdlLevel.query(on: req.db).all() | ||||
| } | } | ||||
| func read(req:Request) async throws -> mdlLevel{ | |||||
| return try await mdlLevel.ObjQuery(req: req).first()! | |||||
| } | |||||
| func create(req: Request) async throws -> mdlLevel { | func create(req: Request) async throws -> mdlLevel { | ||||
| let obj = try req.content.decode(mdlLevel.self) | let obj = try req.content.decode(mdlLevel.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlLevel{ | |||||
| let obj = try req.content.decode(mdlLevel.self) | |||||
| let dbobj = try await mdlLevel.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlLevel.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlLevel.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlLocation: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("locations") | let rts = routes.grouped("locations") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlLocation] { | func index(req: Request) async throws -> [mdlLocation] { | ||||
| try await mdlLocation.query(on: req.db).all() | |||||
| try await mdlLocation.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlLocation{ | |||||
| return try await mdlLocation.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlLocation { | func create(req: Request) async throws -> mdlLocation { | ||||
| let obj = try req.content.decode(mdlLocation.self) | let obj = try req.content.decode(mdlLocation.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlLocation{ | |||||
| let obj = try req.content.decode(mdlLocation.self) | |||||
| let dbobj = try await mdlLocation.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlLocation.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlLocation.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlNoteType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("notetypes") | let rts = routes.grouped("notetypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlNoteType] { | func index(req: Request) async throws -> [mdlNoteType] { | ||||
| try await mdlNoteType.query(on: req.db).all() | |||||
| try await mdlNoteType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlNoteType{ | |||||
| return try await mdlNoteType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlNoteType { | func create(req: Request) async throws -> mdlNoteType { | ||||
| let obj = try req.content.decode(mdlNoteType.self) | let obj = try req.content.decode(mdlNoteType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlNoteType{ | |||||
| let obj = try req.content.decode(mdlNoteType.self) | |||||
| let dbobj = try await mdlNoteType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlNoteType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlNoteType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlPart: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("parts") | let rts = routes.grouped("parts") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlPart] { | func index(req: Request) async throws -> [mdlPart] { | ||||
| try await mdlPart.query(on: req.db).all() | |||||
| try await mdlPart.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlPart{ | |||||
| return try await mdlPart.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlPart { | func create(req: Request) async throws -> mdlPart { | ||||
| let obj = try req.content.decode(mdlPart.self) | let obj = try req.content.decode(mdlPart.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlPart{ | |||||
| let obj = try req.content.decode(mdlPart.self) | |||||
| let dbobj = try await mdlPart.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlPart.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlPart.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlPriority: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("priorities") | let rts = routes.grouped("priorities") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlPriority] { | func index(req: Request) async throws -> [mdlPriority] { | ||||
| try await mdlPriority.query(on: req.db).all() | |||||
| try await mdlPriority.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlPriority{ | |||||
| return try await mdlPriority.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlPriority { | func create(req: Request) async throws -> mdlPriority { | ||||
| let obj = try req.content.decode(mdlPriority.self) | let obj = try req.content.decode(mdlPriority.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlPriority{ | |||||
| let obj = try req.content.decode(mdlPriority.self) | |||||
| let dbobj = try await mdlPriority.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlPriority.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlPriority.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlReason: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("reasons") | let rts = routes.grouped("reasons") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlReason] { | func index(req: Request) async throws -> [mdlReason] { | ||||
| try await mdlReason.query(on: req.db).all() | |||||
| try await mdlReason.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlReason{ | |||||
| return try await mdlReason.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlReason { | func create(req: Request) async throws -> mdlReason { | ||||
| let obj = try req.content.decode(mdlReason.self) | let obj = try req.content.decode(mdlReason.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlReason{ | |||||
| let obj = try req.content.decode(mdlReason.self) | |||||
| let dbobj = try await mdlReason.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlReason.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlReason.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlRepairType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("repairtypes") | let rts = routes.grouped("repairtypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlRepairType] { | func index(req: Request) async throws -> [mdlRepairType] { | ||||
| try await mdlRepairType.query(on: req.db).all() | |||||
| try await mdlRepairType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlRepairType{ | |||||
| return try await mdlRepairType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlRepairType { | func create(req: Request) async throws -> mdlRepairType { | ||||
| let obj = try req.content.decode(mdlRepairType.self) | let obj = try req.content.decode(mdlRepairType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlRepairType{ | |||||
| let obj = try req.content.decode(mdlRepairType.self) | |||||
| let dbobj = try await mdlRepairType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlRepairType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlRepairType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSMSCCode: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("smsccodes") | let rts = routes.grouped("smsccodes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSMSCCode] { | func index(req: Request) async throws -> [mdlSMSCCode] { | ||||
| try await mdlSMSCCode.query(on: req.db).all() | |||||
| try await mdlSMSCCode.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSMSCCode{ | |||||
| return try await mdlSMSCCode.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSMSCCode { | func create(req: Request) async throws -> mdlSMSCCode { | ||||
| let obj = try req.content.decode(mdlSMSCCode.self) | let obj = try req.content.decode(mdlSMSCCode.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSMSCCode{ | |||||
| let obj = try req.content.decode(mdlSMSCCode.self) | |||||
| let dbobj = try await mdlSMSCCode.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSMSCCode.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSMSCCode.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSignatureType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("signaturetypes") | let rts = routes.grouped("signaturetypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSignatureType] { | func index(req: Request) async throws -> [mdlSignatureType] { | ||||
| try await mdlSignatureType.query(on: req.db).all() | |||||
| try await mdlSignatureType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSignatureType{ | |||||
| return try await mdlSignatureType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSignatureType { | func create(req: Request) async throws -> mdlSignatureType { | ||||
| let obj = try req.content.decode(mdlSignatureType.self) | let obj = try req.content.decode(mdlSignatureType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSignatureType{ | |||||
| let obj = try req.content.decode(mdlSignatureType.self) | |||||
| let dbobj = try await mdlSignatureType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSignatureType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSignatureType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlState: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("states") | let rts = routes.grouped("states") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlState] { | func index(req: Request) async throws -> [mdlState] { | ||||
| try await mdlState.query(on: req.db).all() | |||||
| try await mdlState.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlState{ | |||||
| return try await mdlState.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlState { | func create(req: Request) async throws -> mdlState { | ||||
| let obj = try req.content.decode(mdlState.self) | let obj = try req.content.decode(mdlState.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlState{ | |||||
| let obj = try req.content.decode(mdlState.self) | |||||
| let dbobj = try await mdlState.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlState.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlState.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlStatus: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("statuses") | let rts = routes.grouped("statuses") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlStatus] { | func index(req: Request) async throws -> [mdlStatus] { | ||||
| try await mdlStatus.query(on: req.db).all() | |||||
| try await mdlStatus.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlStatus{ | |||||
| return try await mdlStatus.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlStatus { | func create(req: Request) async throws -> mdlStatus { | ||||
| let obj = try req.content.decode(mdlStatus.self) | let obj = try req.content.decode(mdlStatus.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlStatus{ | |||||
| let obj = try req.content.decode(mdlStatus.self) | |||||
| let dbobj = try await mdlStatus.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlStatus.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlStatus.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -3,43 +3,32 @@ import Vapor | |||||
| struct cntrlValueType: RouteCollection { | struct cntrlValueType: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("valueTypes") | |||||
| let rts = routes.grouped("valuetypes") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":id", use: search) | |||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rt.delete(use: delete) | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlValueType] { | func index(req: Request) async throws -> [mdlValueType] { | ||||
| try await mdlValueType.query(on: req.db).all() | |||||
| try await mdlValueType.ObjQuery(req: req).all() | |||||
| } | } | ||||
| func search(req: Request) async throws -> mdlValueType{ | |||||
| guard let id = req.parameters.get("id", as: Int.self) else{ | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| return try await mdlValueType.query(on: req.db).filter(\.$id == id).first()! | |||||
| func read(req:Request) async throws -> mdlValueType{ | |||||
| return try await mdlValueType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlValueType { | func create(req: Request) async throws -> mdlValueType { | ||||
| let obj = try req.content.decode(mdlValueType.self) | let obj = try req.content.decode(mdlValueType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlValueType{ | |||||
| let obj = try req.content.decode(mdlValueType.self) | |||||
| let dbobj = try await mdlValueType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.description = obj.description | |||||
| dbobj.name = obj.name | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlValueType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlValueType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,19 +12,27 @@ struct cntrlViscosity: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("viscosities") | let rts = routes.grouped("viscosities") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlViscosity] { | func index(req: Request) async throws -> [mdlViscosity] { | ||||
| try await mdlViscosity.query(on: req.db).all() | |||||
| try await mdlViscosity.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlViscosity{ | |||||
| return try await mdlViscosity.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlViscosity { | func create(req: Request) async throws -> mdlViscosity { | ||||
| let obj = try req.content.decode(mdlViscosity.self) | let obj = try req.content.decode(mdlViscosity.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| @@ -12,32 +12,30 @@ struct cntrlCompartment: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("compartments") | let rts = routes.grouped("compartments") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlCompartment] { | func index(req: Request) async throws -> [mdlCompartment] { | ||||
| try await mdlCompartment.query(on: req.db).all() | |||||
| try await mdlCompartment.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlCompartment{ | |||||
| return try await mdlCompartment.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlCompartment { | func create(req: Request) async throws -> mdlCompartment { | ||||
| let obj = try req.content.decode(mdlCompartment.self) | let obj = try req.content.decode(mdlCompartment.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlCompartment{ | |||||
| let obj = try req.content.decode(mdlCompartment.self) | |||||
| let dbobj = try await mdlCompartment.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlCompartment.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlCompartment.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,19 +12,27 @@ struct cntrlCompartmentLocation: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("compartmentlocations") | let rts = routes.grouped("compartmentlocations") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlCompartmentLocation] { | func index(req: Request) async throws -> [mdlCompartmentLocation] { | ||||
| try await mdlCompartmentLocation.query(on: req.db).all() | |||||
| try await mdlCompartmentLocation.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlCompartmentLocation{ | |||||
| return try await mdlCompartmentLocation.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlCompartmentLocation { | func create(req: Request) async throws -> mdlCompartmentLocation { | ||||
| let obj = try req.content.decode(mdlCompartmentLocation.self) | let obj = try req.content.decode(mdlCompartmentLocation.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| @@ -12,32 +12,30 @@ struct cntrlContact: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("contacts") | let rts = routes.grouped("contacts") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlContact] { | func index(req: Request) async throws -> [mdlContact] { | ||||
| try await mdlContact.query(on: req.db).all() | |||||
| try await mdlContact.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlContact{ | |||||
| return try await mdlContact.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlContact { | func create(req: Request) async throws -> mdlContact { | ||||
| let obj = try req.content.decode(mdlContact.self) | let obj = try req.content.decode(mdlContact.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlContact{ | |||||
| let obj = try req.content.decode(mdlContact.self) | |||||
| let dbobj = try await mdlContact.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlContact.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlContact.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlContactInfo: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("contactinfos") | let rts = routes.grouped("contactinfos") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlContactInfo] { | func index(req: Request) async throws -> [mdlContactInfo] { | ||||
| try await mdlContactInfo.query(on: req.db).all() | |||||
| try await mdlContactInfo.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlContactInfo{ | |||||
| return try await mdlContactInfo.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlContactInfo { | func create(req: Request) async throws -> mdlContactInfo { | ||||
| let obj = try req.content.decode(mdlContactInfo.self) | let obj = try req.content.decode(mdlContactInfo.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlContactInfo{ | |||||
| let obj = try req.content.decode(mdlContactInfo.self) | |||||
| let dbobj = try await mdlContactInfo.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlContactInfo.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlContactInfo.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlCustomer: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("customers") | let rts = routes.grouped("customers") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlCustomer] { | func index(req: Request) async throws -> [mdlCustomer] { | ||||
| try await mdlCustomer.query(on: req.db).all() | |||||
| try await mdlCustomer.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlCustomer{ | |||||
| return try await mdlCustomer.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlCustomer { | func create(req: Request) async throws -> mdlCustomer { | ||||
| let obj = try req.content.decode(mdlCustomer.self) | let obj = try req.content.decode(mdlCustomer.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlCustomer{ | |||||
| let obj = try req.content.decode(mdlCustomer.self) | |||||
| let dbobj = try await mdlCustomer.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlCustomer.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlCustomer.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlEquipment: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("equipments") | let rts = routes.grouped("equipments") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlEquipment] { | func index(req: Request) async throws -> [mdlEquipment] { | ||||
| try await mdlEquipment.query(on: req.db).all() | |||||
| try await mdlEquipment.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlEquipment{ | |||||
| return try await mdlEquipment.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlEquipment { | func create(req: Request) async throws -> mdlEquipment { | ||||
| let obj = try req.content.decode(mdlEquipment.self) | let obj = try req.content.decode(mdlEquipment.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlEquipment{ | |||||
| let obj = try req.content.decode(mdlEquipment.self) | |||||
| let dbobj = try await mdlEquipment.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlEquipment.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlEquipment.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlMake: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("makes") | let rts = routes.grouped("makes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlMake] { | func index(req: Request) async throws -> [mdlMake] { | ||||
| try await mdlMake.query(on: req.db).all() | |||||
| try await mdlMake.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlMake{ | |||||
| return try await mdlMake.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlMake { | func create(req: Request) async throws -> mdlMake { | ||||
| let obj = try req.content.decode(mdlMake.self) | let obj = try req.content.decode(mdlMake.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlMake{ | |||||
| let obj = try req.content.decode(mdlMake.self) | |||||
| let dbobj = try await mdlMake.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlMake.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlMake.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlModel: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("models") | let rts = routes.grouped("models") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlModel] { | func index(req: Request) async throws -> [mdlModel] { | ||||
| try await mdlModel.query(on: req.db).all() | |||||
| try await mdlModel.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlModel{ | |||||
| return try await mdlModel.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlModel { | func create(req: Request) async throws -> mdlModel { | ||||
| let obj = try req.content.decode(mdlModel.self) | let obj = try req.content.decode(mdlModel.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlModel{ | |||||
| let obj = try req.content.decode(mdlModel.self) | |||||
| let dbobj = try await mdlModel.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlModel.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlModel.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlObjProperty: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("objproperties") | let rts = routes.grouped("objproperties") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlObjProperty] { | func index(req: Request) async throws -> [mdlObjProperty] { | ||||
| try await mdlObjProperty.query(on: req.db).all() | |||||
| try await mdlObjProperty.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlObjProperty{ | |||||
| return try await mdlObjProperty.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlObjProperty { | func create(req: Request) async throws -> mdlObjProperty { | ||||
| let obj = try req.content.decode(mdlObjProperty.self) | let obj = try req.content.decode(mdlObjProperty.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlObjProperty{ | |||||
| let obj = try req.content.decode(mdlObjProperty.self) | |||||
| let dbobj = try await mdlObjProperty.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlObjProperty.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlObjProperty.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlProduct: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("products") | let rts = routes.grouped("products") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlProduct] { | func index(req: Request) async throws -> [mdlProduct] { | ||||
| try await mdlProduct.query(on: req.db).all() | |||||
| try await mdlProduct.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlProduct{ | |||||
| return try await mdlProduct.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlProduct { | func create(req: Request) async throws -> mdlProduct { | ||||
| let obj = try req.content.decode(mdlProduct.self) | let obj = try req.content.decode(mdlProduct.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlProduct{ | |||||
| let obj = try req.content.decode(mdlProduct.self) | |||||
| let dbobj = try await mdlProduct.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlProduct.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlProduct.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlItem: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("items") | let rts = routes.grouped("items") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlItem] { | func index(req: Request) async throws -> [mdlItem] { | ||||
| try await mdlItem.query(on: req.db).all() | |||||
| try await mdlItem.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlItem{ | |||||
| return try await mdlItem.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlItem { | func create(req: Request) async throws -> mdlItem { | ||||
| let obj = try req.content.decode(mdlItem.self) | let obj = try req.content.decode(mdlItem.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlItem{ | |||||
| let obj = try req.content.decode(mdlItem.self) | |||||
| let dbobj = try await mdlItem.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlItem.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlItem.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlItemResponseType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("itemresponsetypes") | let rts = routes.grouped("itemresponsetypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlItemResponseType] { | func index(req: Request) async throws -> [mdlItemResponseType] { | ||||
| try await mdlItemResponseType.query(on: req.db).all() | |||||
| try await mdlItemResponseType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlItemResponseType{ | |||||
| return try await mdlItemResponseType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlItemResponseType { | func create(req: Request) async throws -> mdlItemResponseType { | ||||
| let obj = try req.content.decode(mdlItemResponseType.self) | let obj = try req.content.decode(mdlItemResponseType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlItemResponseType{ | |||||
| let obj = try req.content.decode(mdlItemResponseType.self) | |||||
| let dbobj = try await mdlItemResponseType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlItemResponseType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlItemResponseType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlLabSetting: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("labsettings") | let rts = routes.grouped("labsettings") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlLabSetting] { | func index(req: Request) async throws -> [mdlLabSetting] { | ||||
| try await mdlLabSetting.query(on: req.db).all() | |||||
| try await mdlLabSetting.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlLabSetting{ | |||||
| return try await mdlLabSetting.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlLabSetting { | func create(req: Request) async throws -> mdlLabSetting { | ||||
| let obj = try req.content.decode(mdlLabSetting.self) | let obj = try req.content.decode(mdlLabSetting.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlLabSetting{ | |||||
| let obj = try req.content.decode(mdlLabSetting.self) | |||||
| let dbobj = try await mdlLabSetting.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlLabSetting.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlLabSetting.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlXFluidViscosity: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("xfluidviscosities") | let rts = routes.grouped("xfluidviscosities") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlXFluidViscosity] { | func index(req: Request) async throws -> [mdlXFluidViscosity] { | ||||
| try await mdlXFluidViscosity.query(on: req.db).all() | |||||
| try await mdlXFluidViscosity.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlXFluidViscosity{ | |||||
| return try await mdlXFluidViscosity.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlXFluidViscosity { | func create(req: Request) async throws -> mdlXFluidViscosity { | ||||
| let obj = try req.content.decode(mdlXFluidViscosity.self) | let obj = try req.content.decode(mdlXFluidViscosity.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlXFluidViscosity{ | |||||
| let obj = try req.content.decode(mdlXFluidViscosity.self) | |||||
| let dbobj = try await mdlXFluidViscosity.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlXFluidViscosity.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlXFluidViscosity.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlXUserRole: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("xuserroles") | let rts = routes.grouped("xuserroles") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlXUserRole] { | func index(req: Request) async throws -> [mdlXUserRole] { | ||||
| try await mdlXUserRole.query(on: req.db).all() | |||||
| try await mdlXUserRole.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlXUserRole{ | |||||
| return try await mdlXUserRole.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlXUserRole { | func create(req: Request) async throws -> mdlXUserRole { | ||||
| let obj = try req.content.decode(mdlXUserRole.self) | let obj = try req.content.decode(mdlXUserRole.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlXUserRole{ | |||||
| let obj = try req.content.decode(mdlXUserRole.self) | |||||
| let dbobj = try await mdlXUserRole.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlXUserRole.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlXUserRole.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlOilSample: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("oilsamples") | let rts = routes.grouped("oilsamples") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlOilSample] { | func index(req: Request) async throws -> [mdlOilSample] { | ||||
| try await mdlOilSample.query(on: req.db).all() | |||||
| try await mdlOilSample.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlOilSample{ | |||||
| return try await mdlOilSample.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlOilSample { | func create(req: Request) async throws -> mdlOilSample { | ||||
| let obj = try req.content.decode(mdlOilSample.self) | let obj = try req.content.decode(mdlOilSample.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlOilSample{ | |||||
| let obj = try req.content.decode(mdlOilSample.self) | |||||
| let dbobj = try await mdlOilSample.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlOilSample.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlOilSample.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSpec: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("specs") | let rts = routes.grouped("specs") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSpec] { | func index(req: Request) async throws -> [mdlSpec] { | ||||
| try await mdlSpec.query(on: req.db).all() | |||||
| try await mdlSpec.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSpec{ | |||||
| return try await mdlSpec.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSpec { | func create(req: Request) async throws -> mdlSpec { | ||||
| let obj = try req.content.decode(mdlSpec.self) | let obj = try req.content.decode(mdlSpec.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSpec{ | |||||
| let obj = try req.content.decode(mdlSpec.self) | |||||
| let dbobj = try await mdlSpec.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSpec.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSpec.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSpecItem: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("specitems") | let rts = routes.grouped("specitems") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSpecItem] { | func index(req: Request) async throws -> [mdlSpecItem] { | ||||
| try await mdlSpecItem.query(on: req.db).all() | |||||
| try await mdlSpecItem.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSpecItem{ | |||||
| return try await mdlSpecItem.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSpecItem { | func create(req: Request) async throws -> mdlSpecItem { | ||||
| let obj = try req.content.decode(mdlSpecItem.self) | let obj = try req.content.decode(mdlSpecItem.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSpecItem{ | |||||
| let obj = try req.content.decode(mdlSpecItem.self) | |||||
| let dbobj = try await mdlSpecItem.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSpecItem.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSpecItem.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSpecItemValue: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("specitemvalues") | let rts = routes.grouped("specitemvalues") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSpecItemValue] { | func index(req: Request) async throws -> [mdlSpecItemValue] { | ||||
| try await mdlSpecItemValue.query(on: req.db).all() | |||||
| try await mdlSpecItemValue.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSpecItemValue{ | |||||
| return try await mdlSpecItemValue.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSpecItemValue { | func create(req: Request) async throws -> mdlSpecItemValue { | ||||
| let obj = try req.content.decode(mdlSpecItemValue.self) | let obj = try req.content.decode(mdlSpecItemValue.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSpecItemValue{ | |||||
| let obj = try req.content.decode(mdlSpecItemValue.self) | |||||
| let dbobj = try await mdlSpecItemValue.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSpecItemValue.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSpecItemValue.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlTemplate: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("templates") | let rts = routes.grouped("templates") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlTemplate] { | func index(req: Request) async throws -> [mdlTemplate] { | ||||
| try await mdlTemplate.query(on: req.db).all() | |||||
| try await mdlTemplate.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlTemplate{ | |||||
| return try await mdlTemplate.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlTemplate { | func create(req: Request) async throws -> mdlTemplate { | ||||
| let obj = try req.content.decode(mdlTemplate.self) | let obj = try req.content.decode(mdlTemplate.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlTemplate{ | |||||
| let obj = try req.content.decode(mdlTemplate.self) | |||||
| let dbobj = try await mdlTemplate.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlTemplate.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlTemplate.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlTemplateCategory: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("templatecategories") | let rts = routes.grouped("templatecategories") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlTemplateCategory] { | func index(req: Request) async throws -> [mdlTemplateCategory] { | ||||
| try await mdlTemplateCategory.query(on: req.db).all() | |||||
| try await mdlTemplateCategory.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlTemplateCategory{ | |||||
| return try await mdlTemplateCategory.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlTemplateCategory { | func create(req: Request) async throws -> mdlTemplateCategory { | ||||
| let obj = try req.content.decode(mdlTemplateCategory.self) | let obj = try req.content.decode(mdlTemplateCategory.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlTemplateCategory{ | |||||
| let obj = try req.content.decode(mdlTemplateCategory.self) | |||||
| let dbobj = try await mdlTemplateCategory.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlTemplateCategory.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlTemplateCategory.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlTemplateItemSpec: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("templateitemspecs") | let rts = routes.grouped("templateitemspecs") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlTemplateItemSpec] { | func index(req: Request) async throws -> [mdlTemplateItemSpec] { | ||||
| try await mdlTemplateItemSpec.query(on: req.db).all() | |||||
| try await mdlTemplateItemSpec.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlTemplateItemSpec{ | |||||
| return try await mdlTemplateItemSpec.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlTemplateItemSpec { | func create(req: Request) async throws -> mdlTemplateItemSpec { | ||||
| let obj = try req.content.decode(mdlTemplateItemSpec.self) | let obj = try req.content.decode(mdlTemplateItemSpec.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlTemplateItemSpec{ | |||||
| let obj = try req.content.decode(mdlTemplateItemSpec.self) | |||||
| let dbobj = try await mdlTemplateItemSpec.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlTemplateItemSpec.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlTemplateItemSpec.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlWorkOrderAttachment: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("workorderattachments") | let rts = routes.grouped("workorderattachments") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlWorkOrderAttachment] { | func index(req: Request) async throws -> [mdlWorkOrderAttachment] { | ||||
| try await mdlWorkOrderAttachment.query(on: req.db).all() | |||||
| try await mdlWorkOrderAttachment.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlWorkOrderAttachment{ | |||||
| return try await mdlWorkOrderAttachment.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlWorkOrderAttachment { | func create(req: Request) async throws -> mdlWorkOrderAttachment { | ||||
| let obj = try req.content.decode(mdlWorkOrderAttachment.self) | let obj = try req.content.decode(mdlWorkOrderAttachment.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlWorkOrderAttachment{ | |||||
| let obj = try req.content.decode(mdlWorkOrderAttachment.self) | |||||
| let dbobj = try await mdlWorkOrderAttachment.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlWorkOrderAttachment.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlWorkOrderAttachment.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlConsumption: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("consumptions") | let rts = routes.grouped("consumptions") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlConsumption] { | func index(req: Request) async throws -> [mdlConsumption] { | ||||
| try await mdlConsumption.query(on: req.db).all() | |||||
| try await mdlConsumption.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlConsumption{ | |||||
| return try await mdlConsumption.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlConsumption { | func create(req: Request) async throws -> mdlConsumption { | ||||
| let obj = try req.content.decode(mdlConsumption.self) | let obj = try req.content.decode(mdlConsumption.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlConsumption{ | |||||
| let obj = try req.content.decode(mdlConsumption.self) | |||||
| let dbobj = try await mdlConsumption.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlConsumption.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlConsumption.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspection: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspections") | let rts = routes.grouped("inspections") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspection] { | func index(req: Request) async throws -> [mdlInspection] { | ||||
| try await mdlInspection.query(on: req.db).all() | |||||
| try await mdlInspection.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspection{ | |||||
| return try await mdlInspection.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspection { | func create(req: Request) async throws -> mdlInspection { | ||||
| let obj = try req.content.decode(mdlInspection.self) | let obj = try req.content.decode(mdlInspection.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspection{ | |||||
| let obj = try req.content.decode(mdlInspection.self) | |||||
| let dbobj = try await mdlInspection.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspection.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspection.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionCategory: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectioncategories") | let rts = routes.grouped("inspectioncategories") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionCategory] { | func index(req: Request) async throws -> [mdlInspectionCategory] { | ||||
| try await mdlInspectionCategory.query(on: req.db).all() | |||||
| return try await mdlInspectionCategory.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionCategory{ | |||||
| return try await mdlInspectionCategory.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionCategory { | func create(req: Request) async throws -> mdlInspectionCategory { | ||||
| let obj = try req.content.decode(mdlInspectionCategory.self) | let obj = try req.content.decode(mdlInspectionCategory.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionCategory{ | |||||
| let obj = try req.content.decode(mdlInspectionCategory.self) | |||||
| let dbobj = try await mdlInspectionCategory.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionCategory.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionCategory.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionItem: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionitems") | let rts = routes.grouped("inspectionitems") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionItem] { | func index(req: Request) async throws -> [mdlInspectionItem] { | ||||
| try await mdlInspectionItem.query(on: req.db).all() | |||||
| try await mdlInspectionItem.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionItem{ | |||||
| return try await mdlInspectionItem.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionItem { | func create(req: Request) async throws -> mdlInspectionItem { | ||||
| let obj = try req.content.decode(mdlInspectionItem.self) | let obj = try req.content.decode(mdlInspectionItem.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionItem{ | |||||
| let obj = try req.content.decode(mdlInspectionItem.self) | |||||
| let dbobj = try await mdlInspectionItem.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionItem.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionItem.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionItemResponse: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionitemresponses") | let rts = routes.grouped("inspectionitemresponses") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionItemResponse] { | func index(req: Request) async throws -> [mdlInspectionItemResponse] { | ||||
| try await mdlInspectionItemResponse.query(on: req.db).all() | |||||
| try await mdlInspectionItemResponse.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionItemResponse{ | |||||
| return try await mdlInspectionItemResponse.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionItemResponse { | func create(req: Request) async throws -> mdlInspectionItemResponse { | ||||
| let obj = try req.content.decode(mdlInspectionItemResponse.self) | let obj = try req.content.decode(mdlInspectionItemResponse.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionItemResponse{ | |||||
| let obj = try req.content.decode(mdlInspectionItemResponse.self) | |||||
| let dbobj = try await mdlInspectionItemResponse.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionItemResponse.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionItemResponse.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionItemSpec: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionitemspecs") | let rts = routes.grouped("inspectionitemspecs") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionItemSpec] { | func index(req: Request) async throws -> [mdlInspectionItemSpec] { | ||||
| try await mdlInspectionItemSpec.query(on: req.db).all() | |||||
| try await mdlInspectionItemSpec.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionItemSpec{ | |||||
| return try await mdlInspectionItemSpec.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionItemSpec { | func create(req: Request) async throws -> mdlInspectionItemSpec { | ||||
| let obj = try req.content.decode(mdlInspectionItemSpec.self) | let obj = try req.content.decode(mdlInspectionItemSpec.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionItemSpec{ | |||||
| let obj = try req.content.decode(mdlInspectionItemSpec.self) | |||||
| let dbobj = try await mdlInspectionItemSpec.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionItemSpec.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionItemSpec.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionItemSpecItem: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionitemspecitems") | let rts = routes.grouped("inspectionitemspecitems") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionItemSpecItem] { | func index(req: Request) async throws -> [mdlInspectionItemSpecItem] { | ||||
| try await mdlInspectionItemSpecItem.query(on: req.db).all() | |||||
| try await mdlInspectionItemSpecItem.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionItemSpecItem{ | |||||
| return try await mdlInspectionItemSpecItem.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionItemSpecItem { | func create(req: Request) async throws -> mdlInspectionItemSpecItem { | ||||
| let obj = try req.content.decode(mdlInspectionItemSpecItem.self) | let obj = try req.content.decode(mdlInspectionItemSpecItem.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionItemSpecItem{ | |||||
| let obj = try req.content.decode(mdlInspectionItemSpecItem.self) | |||||
| let dbobj = try await mdlInspectionItemSpecItem.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionItemSpecItem.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionItemSpecItem.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionItemSpecItemTest: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionitemspecitemtests") | let rts = routes.grouped("inspectionitemspecitemtests") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionItemSpecItemTest] { | func index(req: Request) async throws -> [mdlInspectionItemSpecItemTest] { | ||||
| try await mdlInspectionItemSpecItemTest.query(on: req.db).all() | |||||
| try await mdlInspectionItemSpecItemTest.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionItemSpecItemTest{ | |||||
| return try await mdlInspectionItemSpecItemTest.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionItemSpecItemTest { | func create(req: Request) async throws -> mdlInspectionItemSpecItemTest { | ||||
| let obj = try req.content.decode(mdlInspectionItemSpecItemTest.self) | let obj = try req.content.decode(mdlInspectionItemSpecItemTest.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionItemSpecItemTest{ | |||||
| let obj = try req.content.decode(mdlInspectionItemSpecItemTest.self) | |||||
| let dbobj = try await mdlInspectionItemSpecItemTest.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionItemSpecItemTest.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionItemSpecItemTest.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionItemSpecItemValue: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionitemspecitemvalues") | let rts = routes.grouped("inspectionitemspecitemvalues") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionItemSpecItemValue] { | func index(req: Request) async throws -> [mdlInspectionItemSpecItemValue] { | ||||
| try await mdlInspectionItemSpecItemValue.query(on: req.db).all() | |||||
| try await mdlInspectionItemSpecItemValue.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionItemSpecItemValue{ | |||||
| return try await mdlInspectionItemSpecItemValue.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionItemSpecItemValue { | func create(req: Request) async throws -> mdlInspectionItemSpecItemValue { | ||||
| let obj = try req.content.decode(mdlInspectionItemSpecItemValue.self) | let obj = try req.content.decode(mdlInspectionItemSpecItemValue.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionItemSpecItemValue{ | |||||
| let obj = try req.content.decode(mdlInspectionItemSpecItemValue.self) | |||||
| let dbobj = try await mdlInspectionItemSpecItemValue.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionItemSpecItemValue.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionItemSpecItemValue.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionLevel: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectionlevels") | let rts = routes.grouped("inspectionlevels") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionLevel] { | func index(req: Request) async throws -> [mdlInspectionLevel] { | ||||
| try await mdlInspectionLevel.query(on: req.db).all() | |||||
| try await mdlInspectionLevel.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionLevel{ | |||||
| return try await mdlInspectionLevel.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionLevel { | func create(req: Request) async throws -> mdlInspectionLevel { | ||||
| let obj = try req.content.decode(mdlInspectionLevel.self) | let obj = try req.content.decode(mdlInspectionLevel.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionLevel{ | |||||
| let obj = try req.content.decode(mdlInspectionLevel.self) | |||||
| let dbobj = try await mdlInspectionLevel.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionLevel.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionLevel.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlInspectionType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("inspectiontypes") | let rts = routes.grouped("inspectiontypes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlInspectionType] { | func index(req: Request) async throws -> [mdlInspectionType] { | ||||
| try await mdlInspectionType.query(on: req.db).all() | |||||
| try await mdlInspectionType.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlInspectionType{ | |||||
| return try await mdlInspectionType.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlInspectionType { | func create(req: Request) async throws -> mdlInspectionType { | ||||
| let obj = try req.content.decode(mdlInspectionType.self) | let obj = try req.content.decode(mdlInspectionType.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlInspectionType{ | |||||
| let obj = try req.content.decode(mdlInspectionType.self) | |||||
| let dbobj = try await mdlInspectionType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlInspectionType.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlInspectionType.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlNote: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("notes") | let rts = routes.grouped("notes") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlNote] { | func index(req: Request) async throws -> [mdlNote] { | ||||
| try await mdlNote.query(on: req.db).all() | |||||
| try await mdlNote.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlNote{ | |||||
| return try await mdlNote.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlNote { | func create(req: Request) async throws -> mdlNote { | ||||
| let obj = try req.content.decode(mdlNote.self) | let obj = try req.content.decode(mdlNote.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlNote{ | |||||
| let obj = try req.content.decode(mdlNote.self) | |||||
| let dbobj = try await mdlNote.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlNote.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlNote.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlWorkOrderPart: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("workorderparts") | let rts = routes.grouped("workorderparts") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlWorkOrderPart] { | func index(req: Request) async throws -> [mdlWorkOrderPart] { | ||||
| try await mdlWorkOrderPart.query(on: req.db).all() | |||||
| try await mdlWorkOrderPart.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlWorkOrderPart{ | |||||
| return try await mdlWorkOrderPart.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlWorkOrderPart { | func create(req: Request) async throws -> mdlWorkOrderPart { | ||||
| let obj = try req.content.decode(mdlWorkOrderPart.self) | let obj = try req.content.decode(mdlWorkOrderPart.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlWorkOrderPart{ | |||||
| let obj = try req.content.decode(mdlWorkOrderPart.self) | |||||
| let dbobj = try await mdlWorkOrderPart.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlWorkOrderPart.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlWorkOrderPart.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlSignature: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("signatures") | let rts = routes.grouped("signatures") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlSignature] { | func index(req: Request) async throws -> [mdlSignature] { | ||||
| try await mdlSignature.query(on: req.db).all() | |||||
| try await mdlSignature.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlSignature{ | |||||
| return try await mdlSignature.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlSignature { | func create(req: Request) async throws -> mdlSignature { | ||||
| let obj = try req.content.decode(mdlSignature.self) | let obj = try req.content.decode(mdlSignature.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlSignature{ | |||||
| let obj = try req.content.decode(mdlSignature.self) | |||||
| let dbobj = try await mdlSignature.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlSignature.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlSignature.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlWorkOrder: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("workorders") | let rts = routes.grouped("workorders") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlWorkOrder] { | func index(req: Request) async throws -> [mdlWorkOrder] { | ||||
| try await mdlWorkOrder.query(on: req.db).all() | |||||
| try await mdlWorkOrder.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlWorkOrder{ | |||||
| return try await mdlWorkOrder.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlWorkOrder { | func create(req: Request) async throws -> mdlWorkOrder { | ||||
| let obj = try req.content.decode(mdlWorkOrder.self) | let obj = try req.content.decode(mdlWorkOrder.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlWorkOrder{ | |||||
| let obj = try req.content.decode(mdlWorkOrder.self) | |||||
| let dbobj = try await mdlWorkOrder.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlWorkOrder.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlWorkOrder.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlWorkorderFlow: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("workorderflows") | let rts = routes.grouped("workorderflows") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlWorkOrderFlow] { | func index(req: Request) async throws -> [mdlWorkOrderFlow] { | ||||
| try await mdlWorkOrderFlow.query(on: req.db).all() | |||||
| try await mdlWorkOrderFlow.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlWorkOrderFlow{ | |||||
| return try await mdlWorkOrderFlow.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlWorkOrderFlow { | func create(req: Request) async throws -> mdlWorkOrderFlow { | ||||
| let obj = try req.content.decode(mdlWorkOrderFlow.self) | let obj = try req.content.decode(mdlWorkOrderFlow.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlWorkOrderFlow{ | |||||
| let obj = try req.content.decode(mdlWorkOrderFlow.self) | |||||
| let dbobj = try await mdlWorkOrderFlow.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlWorkOrderFlow.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlWorkOrderFlow.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -12,32 +12,30 @@ struct cntrlWorkOrderSegment: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("workordersegments") | let rts = routes.grouped("workordersegments") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get(":x", use: read) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.group(":x") { rt in | |||||
| rts.delete(use: delete) | rts.delete(use: delete) | ||||
| } | } | ||||
| ///Add custom routes here | |||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlWorkOrderSegment] { | func index(req: Request) async throws -> [mdlWorkOrderSegment] { | ||||
| try await mdlWorkOrderSegment.query(on: req.db).all() | |||||
| try await mdlWorkOrderSegment.ObjQuery(req: req).all() | |||||
| } | |||||
| func read(req:Request) async throws -> mdlWorkOrderSegment{ | |||||
| return try await mdlWorkOrderSegment.ObjQuery(req: req).first()! | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlWorkOrderSegment { | func create(req: Request) async throws -> mdlWorkOrderSegment { | ||||
| let obj = try req.content.decode(mdlWorkOrderSegment.self) | let obj = try req.content.decode(mdlWorkOrderSegment.self) | ||||
| if(obj.id != nil){ | |||||
| obj._$idExists = true | |||||
| } | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlWorkOrderSegment{ | |||||
| let obj = try req.content.decode(mdlWorkOrderSegment.self) | |||||
| let dbobj = try await mdlWorkOrderSegment.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlWorkOrderSegment.find(req.parameters.get("id"), on: req.db) else { | guard let obj = try await mdlWorkOrderSegment.find(req.parameters.get("id"), on: req.db) else { | ||||
| @@ -86,6 +86,37 @@ extension mdlRole{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlRole>{ | |||||
| let query = mdlRole.query(on: req.db) | |||||
| .with(\.$users) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -78,6 +78,36 @@ extension mdlSegment{ | |||||
| mdlSegment.query(on: database).delete() | mdlSegment.query(on: database).delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlSegment>{ | |||||
| let query = mdlSegment.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -84,7 +84,41 @@ extension mdlUser{ | |||||
| try await database.schema("user").delete() | try await database.schema("user").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlUser>{ | |||||
| let query = mdlUser.query(on: req.db) | |||||
| .with(\.$roles) | |||||
| .with(\.$division) | |||||
| .with(\.$location) | |||||
| .with(\.$gate) | |||||
| .with(\.$workorders) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| else if(x.count == 2){ | |||||
| let username = x[0] | |||||
| let password = x[1] | |||||
| return query.filter(\.$username == username).filter(\.$password == password) | |||||
| } | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -77,6 +77,38 @@ extension mdlResponseType{ | |||||
| .update() | .update() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlResponseType>{ | |||||
| let query = mdlResponseType.query(on: req.db) | |||||
| .with(\.$repairtype) | |||||
| .with(\.$responses) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -61,6 +61,37 @@ extension mdlUnit{ | |||||
| try await database.schema("unit").delete() | try await database.schema("unit").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlUnit>{ | |||||
| let query = mdlUnit.query(on: req.db) | |||||
| .with(\.$datatype) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -58,4 +58,36 @@ extension mdlCategory{ | |||||
| try await database.schema("category").delete() | try await database.schema("category").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlCategory>{ | |||||
| let query = mdlCategory.query(on: req.db) | |||||
| .with(\.$categories) | |||||
| .with(\.$templatecategories) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -75,5 +75,35 @@ extension mdlComparisonType{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlComparisonType>{ | |||||
| let query = mdlComparisonType.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -75,6 +75,36 @@ extension mdlContactType{ | |||||
| mdlContactType.query(on: database).delete() | mdlContactType.query(on: database).delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlContactType>{ | |||||
| let query = mdlContactType.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -76,4 +76,35 @@ extension mdlDataType{ | |||||
| mdlDataType.query(on: database).delete() | mdlDataType.query(on: database).delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlDataType>{ | |||||
| let query = mdlDataType.query(on: req.db) | |||||
| .with(\.$units) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -60,6 +60,37 @@ extension mdlDivision{ | |||||
| try await database.schema("division").delete() | try await database.schema("division").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlDivision>{ | |||||
| let query = mdlDivision.query(on: req.db) | |||||
| .with(\.$users) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -71,4 +71,34 @@ extension mdlEquipmentType{ | |||||
| mdlEquipmentType.query(on: database).delete() | mdlEquipmentType.query(on: database).delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlEquipmentType>{ | |||||
| let query = mdlEquipmentType.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -60,6 +60,36 @@ extension mdlFluid{ | |||||
| try await database.schema("fluid").delete() | try await database.schema("fluid").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlFluid>{ | |||||
| let query = mdlFluid.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -62,6 +62,37 @@ extension mdlFuel{ | |||||
| try await database.schema("fuel").delete() | try await database.schema("fuel").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlFuel>{ | |||||
| let query = mdlFuel.query(on: req.db) | |||||
| .with(\.$workorders) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -59,6 +59,37 @@ | |||||
| try await database.schema("gate").delete() | try await database.schema("gate").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlGate>{ | |||||
| let query = mdlGate.query(on: req.db) | |||||
| .with(\.$users) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -59,6 +59,37 @@ extension mdlIncompleteReason{ | |||||
| try await database.schema("incompleteReason").delete() | try await database.schema("incompleteReason").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlIncompleteReason>{ | |||||
| let query = mdlIncompleteReason.query(on: req.db) | |||||
| .with(\.$workorders) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -75,4 +75,35 @@ extension mdlInputType{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlInputType>{ | |||||
| let query = mdlInputType.query(on: req.db) | |||||
| .with(\.$inspectionitems) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -74,5 +74,35 @@ extension mdlJobSite{ | |||||
| mdlJobSite.query(on: database).delete() | mdlJobSite.query(on: database).delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlJobSite>{ | |||||
| let query = mdlJobSite.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -60,6 +60,36 @@ extension mdlLevel{ | |||||
| try await database.schema("level").delete() | try await database.schema("level").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlLevel>{ | |||||
| let query = mdlLevel.query(on: req.db) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -112,6 +112,40 @@ extension mdlLocation{ | |||||
| .update() | .update() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlLocation>{ | |||||
| let query = mdlLocation.query(on: req.db) | |||||
| .with(\.$state) | |||||
| .with(\.$unit) | |||||
| .with(\.$users) | |||||
| .with(\.$labsetting) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -59,6 +59,37 @@ extension mdlNoteType{ | |||||
| try await database.schema("noteType").delete() | try await database.schema("noteType").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlNoteType>{ | |||||
| let query = mdlNoteType.query(on: req.db) | |||||
| .with(\.$notes) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -57,6 +57,37 @@ extension mdlPart{ | |||||
| try await database.schema("part").delete() | try await database.schema("part").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlPart>{ | |||||
| let query = mdlPart.query(on: req.db) | |||||
| // .with(\.$<#parent/children#>) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -76,6 +76,37 @@ extension mdlPriority{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlPriority>{ | |||||
| let query = mdlPriority.query(on: req.db) | |||||
| .with(\.$workorders) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -59,6 +59,37 @@ extension mdlReason{ | |||||
| try await database.schema("reason").delete() | try await database.schema("reason").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlReason>{ | |||||
| let query = mdlReason.query(on: req.db) | |||||
| .with(\.$workorders) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -79,6 +79,37 @@ extension mdlRepairType{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlRepairType>{ | |||||
| let query = mdlRepairType.query(on: req.db) | |||||
| .with(\.$units) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -57,6 +57,37 @@ extension mdlSMSCCode{ | |||||
| try await database.schema("smscCode").delete() | try await database.schema("smscCode").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlSMSCCode>{ | |||||
| let query = mdlSMSCCode.query(on: req.db) | |||||
| // .with(\.$<#parent/children#>) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -72,6 +72,37 @@ extension mdlSignatureType{ | |||||
| .update() | .update() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlSignatureType>{ | |||||
| let query = mdlSignatureType.query(on: req.db) | |||||
| // .with(\.$<#parent/children#>) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -124,6 +124,37 @@ extension mdlState{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlState>{ | |||||
| let query = mdlState.query(on: req.db) | |||||
| .with(\.$locations) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -80,6 +80,37 @@ extension mdlStatus{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlStatus>{ | |||||
| let query = mdlStatus.query(on: req.db) | |||||
| .with(\.$workorders) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -74,6 +74,37 @@ extension mdlValueType{ | |||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlValueType>{ | |||||
| let query = mdlValueType.query(on: req.db) | |||||
| // .with(\.$<#parent/children#>) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -57,6 +57,37 @@ extension mdlViscosity{ | |||||
| try await database.schema("viscosity").delete() | try await database.schema("viscosity").delete() | ||||
| } | } | ||||
| } | } | ||||
| public static func ObjQuery(req: Request) async throws -> QueryBuilder<mdlViscosity>{ | |||||
| let query = mdlViscosity.query(on: req.db) | |||||
| // .with(\.$<#parent/children#>) | |||||
| if let x = req.parameters.get("x"){ | |||||
| let dataQuery = req.parameters.get("x") | |||||
| let decryptedString = try CustomCrypto.DecryptString(input: dataQuery!) | |||||
| let x = decryptedString.components(separatedBy: ":") | |||||
| ///This call is the standard get by id call | |||||
| if (x.count == 1){ | |||||
| let id = Int(x[0])! | |||||
| return query.filter(\.$id == id) | |||||
| } | |||||
| ///Optional else if if there are multiple parameters in the call | |||||
| ///You must include an else for each call that has parameters | |||||
| ///Need to check the endpoint to get the right filter statements | |||||
| ///else if(x.count == 2){ | |||||
| /// let username = x[0] | |||||
| /// let password = x[1] | |||||
| /// return query.filter(\.$username == username).filter(\.$password == password) | |||||
| ///} | |||||
| else{ | |||||
| throw Abort(.badRequest) | |||||
| } | |||||
| } | |||||
| else{ | |||||
| return query | |||||
| } | |||||
| } | |||||
| } | } | ||||