瀏覽代碼

Consolidated base query into models

main
rpm-mcarman 2 年之前
父節點
當前提交
fe0140ae3f
共有 100 個文件被更改,包括 1701 次插入954 次删除
  1. +11
    -14
      Sources/App/Controllers/AuthControllers/cntrlRole.swift
  2. +11
    -13
      Sources/App/Controllers/AuthControllers/cntrlSegment.swift
  3. +12
    -54
      Sources/App/Controllers/AuthControllers/cntrlUser.swift
  4. +11
    -13
      Sources/App/Controllers/BaseControllers/ChildControllers/cntrlResponseType.swift
  5. +11
    -13
      Sources/App/Controllers/BaseControllers/ChildControllers/cntrlUnit.swift
  6. +11
    -15
      Sources/App/Controllers/BaseControllers/cntrlCategory.swift
  7. +12
    -14
      Sources/App/Controllers/BaseControllers/cntrlComparisonType.swift
  8. +12
    -14
      Sources/App/Controllers/BaseControllers/cntrlContactType.swift
  9. +11
    -22
      Sources/App/Controllers/BaseControllers/cntrlDataType.swift
  10. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlDivision.swift
  11. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlEquipmentType.swift
  12. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlFluid.swift
  13. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlFuel.swift
  14. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlGate.swift
  15. +8
    -13
      Sources/App/Controllers/BaseControllers/cntrlIncompleteReason.swift
  16. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlInputType.swift
  17. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlJobSite.swift
  18. +10
    -12
      Sources/App/Controllers/BaseControllers/cntrlLevel.swift
  19. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlLocation.swift
  20. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlNoteType.swift
  21. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlPart.swift
  22. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlPriority.swift
  23. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlReason.swift
  24. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlRepairType.swift
  25. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlSMSCCode.swift
  26. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlSignatureType.swift
  27. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlState.swift
  28. +11
    -13
      Sources/App/Controllers/BaseControllers/cntrlStatus.swift
  29. +11
    -22
      Sources/App/Controllers/BaseControllers/cntrlValueType.swift
  30. +11
    -3
      Sources/App/Controllers/BaseControllers/cntrlViscosity.swift
  31. +11
    -13
      Sources/App/Controllers/CompartmentControllers/cntrlCompartment.swift
  32. +11
    -3
      Sources/App/Controllers/CompartmentControllers/cntrlCompartmentLocation.swift
  33. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlContact.swift
  34. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlContactInfo.swift
  35. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlCustomer.swift
  36. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlEquipment.swift
  37. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlMake.swift
  38. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlModel.swift
  39. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlObjectProperty.swift
  40. +11
    -13
      Sources/App/Controllers/CustomerControllers/cntrlProduct.swift
  41. +11
    -13
      Sources/App/Controllers/ItemControllers/cntrlItem.swift
  42. +11
    -13
      Sources/App/Controllers/ItemControllers/cntrlItemResponseType.swift
  43. +11
    -13
      Sources/App/Controllers/LabControllers/cntrlLabSetting.swift
  44. +11
    -13
      Sources/App/Controllers/LinkingControllers/cntrlXFluidViscosity.swift
  45. +11
    -13
      Sources/App/Controllers/LinkingControllers/cntrlXUserRole.swift
  46. +11
    -13
      Sources/App/Controllers/OilSampleControllers/cntrlOilSample.swift
  47. +11
    -13
      Sources/App/Controllers/SpecControllers/cntrlSpec.swift
  48. +11
    -13
      Sources/App/Controllers/SpecControllers/cntrlSpecItem.swift
  49. +11
    -13
      Sources/App/Controllers/SpecControllers/cntrlSpecItemValue.swift
  50. +11
    -13
      Sources/App/Controllers/TemplateControllers/cntrlTemplate.swift
  51. +11
    -13
      Sources/App/Controllers/TemplateControllers/cntrlTemplateCategory.swift
  52. +11
    -13
      Sources/App/Controllers/TemplateControllers/cntrlTemplateItemSpec.swift
  53. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Attachments/cntrlWorkOrderAttachment.swift
  54. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Consumptions/cntrlConsumption.swift
  55. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspection.swift
  56. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionCategory.swift
  57. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItem.swift
  58. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemResponse.swift
  59. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpec.swift
  60. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpecItem.swift
  61. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpecItemTest.swift
  62. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpecItemValue.swift
  63. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionLevel.swift
  64. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionType.swift
  65. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Notes/cntrlNote.swift
  66. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/Parts/cntrlWorkOrderPart.swift
  67. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/SignatureControllers/cntrlSignature.swift
  68. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/cntrlWorkOrder.swift
  69. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/cntrlWorkOrderFlow.swift
  70. +11
    -13
      Sources/App/Controllers/WorkOrderControllers/cntrlWorkOrderSegment.swift
  71. +31
    -0
      Sources/App/Models/AuthTables/mdlRole.swift
  72. +30
    -0
      Sources/App/Models/AuthTables/mdlSegment.swift
  73. +35
    -1
      Sources/App/Models/AuthTables/mdlUser.swift
  74. +32
    -0
      Sources/App/Models/BaseTables/ChildTables/mdlResponseType.swift
  75. +31
    -0
      Sources/App/Models/BaseTables/ChildTables/mdlUnit.swift
  76. +32
    -0
      Sources/App/Models/BaseTables/mdlCategory.swift
  77. +30
    -0
      Sources/App/Models/BaseTables/mdlComparisonType.swift
  78. +30
    -0
      Sources/App/Models/BaseTables/mdlContactType.swift
  79. +31
    -0
      Sources/App/Models/BaseTables/mdlDataType.swift
  80. +31
    -0
      Sources/App/Models/BaseTables/mdlDivision.swift
  81. +30
    -0
      Sources/App/Models/BaseTables/mdlEquipmentType.swift
  82. +30
    -0
      Sources/App/Models/BaseTables/mdlFluid.swift
  83. +31
    -0
      Sources/App/Models/BaseTables/mdlFuel.swift
  84. +31
    -0
      Sources/App/Models/BaseTables/mdlGate.swift
  85. +31
    -0
      Sources/App/Models/BaseTables/mdlIncompleteReason.swift
  86. +31
    -0
      Sources/App/Models/BaseTables/mdlInputType.swift
  87. +30
    -0
      Sources/App/Models/BaseTables/mdlJobSite.swift
  88. +30
    -0
      Sources/App/Models/BaseTables/mdlLevel.swift
  89. +34
    -0
      Sources/App/Models/BaseTables/mdlLocation.swift
  90. +31
    -0
      Sources/App/Models/BaseTables/mdlNoteType.swift
  91. +31
    -0
      Sources/App/Models/BaseTables/mdlPart.swift
  92. +31
    -0
      Sources/App/Models/BaseTables/mdlPriority.swift
  93. +31
    -0
      Sources/App/Models/BaseTables/mdlReason.swift
  94. +31
    -0
      Sources/App/Models/BaseTables/mdlRepairType.swift
  95. +31
    -0
      Sources/App/Models/BaseTables/mdlSMSCCode.swift
  96. +31
    -0
      Sources/App/Models/BaseTables/mdlSignatureType.swift
  97. +31
    -0
      Sources/App/Models/BaseTables/mdlState.swift
  98. +31
    -0
      Sources/App/Models/BaseTables/mdlStatus.swift
  99. +31
    -0
      Sources/App/Models/BaseTables/mdlValueType.swift
  100. +31
    -0
      Sources/App/Models/BaseTables/mdlViscosity.swift

+ 11
- 14
Sources/App/Controllers/AuthControllers/cntrlRole.swift 查看文件

@@ -12,33 +12,30 @@ struct cntrlRole: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("roles")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { todo in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}

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 {
let obj = try req.content.decode(mdlRole.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlRole.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/AuthControllers/cntrlSegment.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSegment: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("segments")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSegment.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSegment.find(req.parameters.get("id"), on: req.db) else {


+ 12
- 54
Sources/App/Controllers/AuthControllers/cntrlUser.swift 查看文件

@@ -15,59 +15,29 @@ struct cntrlUser: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("users")
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.put(use: update)
rts.group(":id") { todo in
rts.group(":x") { todo in
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{
return Environment.get("API_KEY")!
}
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] {
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 {
@@ -78,22 +48,10 @@ struct cntrlUser: RouteCollection {
try await obj.save(on: req.db)
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 {
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)
}
try await obj.delete(on: req.db)


+ 11
- 13
Sources/App/Controllers/BaseControllers/ChildControllers/cntrlResponseType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlResponseType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("responsetypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlResponseType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlResponseType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/ChildControllers/cntrlUnit.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlUnit: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("units")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlUnit.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlUnit.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 15
Sources/App/Controllers/BaseControllers/cntrlCategory.swift 查看文件

@@ -5,34 +5,30 @@ struct cntrlCategory: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("categories")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { todo in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}

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 {
let obj = try req.content.decode(mdlCategory.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
return obj
}
func update(req: Request) async throws -> mdlCategory{
let obj = try req.content.decode(mdlCategory.self)
let dbobj = try await mdlCategory.query(on: req.db).filter(\.$id == obj.id!).first()!
dbobj.description = obj.description
dbobj.name = obj.name
dbobj.updatedate = Date()
dbobj.isactive = obj.isactive
dbobj.updateuserid = -1
try await dbobj.update(on: req.db)
return dbobj
}

func delete(req: Request) async throws -> HTTPStatus {
guard let obj = try await mdlCategory.find(req.parameters.get("id"), on: req.db) else {


+ 12
- 14
Sources/App/Controllers/BaseControllers/cntrlComparisonType.swift 查看文件

@@ -10,34 +10,32 @@ import Vapor

struct cntrlComparisonType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("comparisonTypes")
let rts = routes.grouped("comparisontypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlComparisonType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlComparisonType.find(req.parameters.get("id"), on: req.db) else {


+ 12
- 14
Sources/App/Controllers/BaseControllers/cntrlContactType.swift 查看文件

@@ -10,34 +10,32 @@ import Vapor

struct cntrlContactType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("contactTypes")
let rts = routes.grouped("contacttypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlContactType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlContactType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 22
Sources/App/Controllers/BaseControllers/cntrlDataType.swift 查看文件

@@ -3,43 +3,32 @@ import Vapor

struct cntrlDataTypes: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("dataTypes")
let rts = routes.grouped("datatypes")
rts.get(use: index)
rts.get(":id", use: search)
rts.get(":x", use: read)
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] {
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 {
let obj = try req.content.decode(mdlDataType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlDataType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlDivision.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlDivision: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("divisions")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlDivision.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlDivision.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlEquipmentType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlEquipmentType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("equipmenttypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlEquipmentType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlEquipmentType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlFluid.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlFluid: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("fluids")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlFluid.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlFluid.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlFuel.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlFuel: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("fuels")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlFuel.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlFuel.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlGate.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlGate: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("gates")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlGate.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlGate.find(req.parameters.get("id"), on: req.db) else {


+ 8
- 13
Sources/App/Controllers/BaseControllers/cntrlIncompleteReason.swift 查看文件

@@ -12,15 +12,20 @@ struct cntrlIncompleteReason: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("incompletereasons")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
@@ -28,16 +33,6 @@ struct cntrlIncompleteReason: RouteCollection {
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlIncompleteReason.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlInputType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInputType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inputtypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInputType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInputType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlJobSite.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlJobSite: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("jobsites")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlJobSite.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlJobSite.find(req.parameters.get("id"), on: req.db) else {


+ 10
- 12
Sources/App/Controllers/BaseControllers/cntrlLevel.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlLevel: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("levels")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
func index(req: Request) async throws -> [mdlLevel] {
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 {
let obj = try req.content.decode(mdlLevel.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlLevel.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlLocation.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlLocation: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("locations")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlLocation.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlLocation.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlNoteType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlNoteType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("notetypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlNoteType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlNoteType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlPart.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlPart: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("parts")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlPart.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlPart.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlPriority.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlPriority: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("priorities")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlPriority.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlPriority.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlReason.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlReason: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("reasons")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlReason.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlReason.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlRepairType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlRepairType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("repairtypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlRepairType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlRepairType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlSMSCCode.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSMSCCode: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("smsccodes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSMSCCode.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSMSCCode.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlSignatureType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSignatureType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("signaturetypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSignatureType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSignatureType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlState.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlState: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("states")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlState.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlState.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/BaseControllers/cntrlStatus.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlStatus: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("statuses")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlStatus.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlStatus.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 22
Sources/App/Controllers/BaseControllers/cntrlValueType.swift 查看文件

@@ -3,43 +3,32 @@ import Vapor

struct cntrlValueType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("valueTypes")
let rts = routes.grouped("valuetypes")
rts.get(use: index)
rts.get(":id", use: search)
rts.get(":x", use: read)
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] {
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 {
let obj = try req.content.decode(mdlValueType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlValueType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 3
Sources/App/Controllers/BaseControllers/cntrlViscosity.swift 查看文件

@@ -12,19 +12,27 @@ struct cntrlViscosity: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("viscosities")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlViscosity.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
return obj
}


+ 11
- 13
Sources/App/Controllers/CompartmentControllers/cntrlCompartment.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlCompartment: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("compartments")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlCompartment.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlCompartment.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 3
Sources/App/Controllers/CompartmentControllers/cntrlCompartmentLocation.swift 查看文件

@@ -12,19 +12,27 @@ struct cntrlCompartmentLocation: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("compartmentlocations")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlCompartmentLocation.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
return obj
}


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlContact.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlContact: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("contacts")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlContact.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlContact.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlContactInfo.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlContactInfo: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("contactinfos")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlContactInfo.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlContactInfo.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlCustomer.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlCustomer: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("customers")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlCustomer.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlCustomer.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlEquipment.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlEquipment: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("equipments")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlEquipment.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlEquipment.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlMake.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlMake: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("makes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlMake.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlMake.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlModel.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlModel: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("models")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlModel.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlModel.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlObjectProperty.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlObjProperty: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("objproperties")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlObjProperty.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlObjProperty.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/CustomerControllers/cntrlProduct.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlProduct: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("products")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlProduct.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlProduct.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/ItemControllers/cntrlItem.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlItem: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("items")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlItem.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlItem.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/ItemControllers/cntrlItemResponseType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlItemResponseType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("itemresponsetypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlItemResponseType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlItemResponseType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/LabControllers/cntrlLabSetting.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlLabSetting: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("labsettings")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlLabSetting.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlLabSetting.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/LinkingControllers/cntrlXFluidViscosity.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlXFluidViscosity: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("xfluidviscosities")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlXFluidViscosity.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlXFluidViscosity.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/LinkingControllers/cntrlXUserRole.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlXUserRole: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("xuserroles")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlXUserRole.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlXUserRole.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/OilSampleControllers/cntrlOilSample.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlOilSample: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("oilsamples")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlOilSample.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlOilSample.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/SpecControllers/cntrlSpec.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSpec: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("specs")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSpec.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSpec.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/SpecControllers/cntrlSpecItem.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSpecItem: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("specitems")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSpecItem.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSpecItem.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/SpecControllers/cntrlSpecItemValue.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSpecItemValue: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("specitemvalues")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSpecItemValue.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSpecItemValue.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/TemplateControllers/cntrlTemplate.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlTemplate: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("templates")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlTemplate.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlTemplate.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/TemplateControllers/cntrlTemplateCategory.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlTemplateCategory: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("templatecategories")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlTemplateCategory.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlTemplateCategory.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/TemplateControllers/cntrlTemplateItemSpec.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlTemplateItemSpec: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("templateitemspecs")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlTemplateItemSpec.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlTemplateItemSpec.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Attachments/cntrlWorkOrderAttachment.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlWorkOrderAttachment: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("workorderattachments")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlWorkOrderAttachment.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlWorkOrderAttachment.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Consumptions/cntrlConsumption.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlConsumption: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("consumptions")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlConsumption.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlConsumption.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspection.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspection: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspections")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspection.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspection.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionCategory.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionCategory: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectioncategories")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionCategory.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionCategory.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItem.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionItem: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionitems")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionItem.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionItem.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemResponse.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionItemResponse: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionitemresponses")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionItemResponse.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionItemResponse.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpec.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionItemSpec: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionitemspecs")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionItemSpec.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionItemSpec.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpecItem.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionItemSpecItem: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionitemspecitems")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionItemSpecItem.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionItemSpecItem.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpecItemTest.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionItemSpecItemTest: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionitemspecitemtests")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionItemSpecItemTest.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionItemSpecItemTest.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionItemSpecItemValue.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionItemSpecItemValue: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionitemspecitemvalues")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionItemSpecItemValue.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionItemSpecItemValue.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionLevel.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionLevel: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectionlevels")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionLevel.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionLevel.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Inspections/cntrlInspectionType.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlInspectionType: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("inspectiontypes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlInspectionType.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlInspectionType.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Notes/cntrlNote.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlNote: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("notes")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlNote.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlNote.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/Parts/cntrlWorkOrderPart.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlWorkOrderPart: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("workorderparts")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlWorkOrderPart.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlWorkOrderPart.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/SignatureControllers/cntrlSignature.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlSignature: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("signatures")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlSignature.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlSignature.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/cntrlWorkOrder.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlWorkOrder: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("workorders")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlWorkOrder.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlWorkOrder.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/cntrlWorkOrderFlow.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlWorkorderFlow: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("workorderflows")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlWorkOrderFlow.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlWorkOrderFlow.find(req.parameters.get("id"), on: req.db) else {


+ 11
- 13
Sources/App/Controllers/WorkOrderControllers/cntrlWorkOrderSegment.swift 查看文件

@@ -12,32 +12,30 @@ struct cntrlWorkOrderSegment: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let rts = routes.grouped("workordersegments")
rts.get(use: index)
rts.get(":x", use: read)
rts.post(use: create)
rts.put(use: update)
rts.group(":id") { rt in
rts.group(":x") { rt in
rts.delete(use: delete)
}
///Add custom routes here
}
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 {
let obj = try req.content.decode(mdlWorkOrderSegment.self)
if(obj.id != nil){
obj._$idExists = true
}
try await obj.save(on: req.db)
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 {
guard let obj = try await mdlWorkOrderSegment.find(req.parameters.get("id"), on: req.db) else {


+ 31
- 0
Sources/App/Models/AuthTables/mdlRole.swift 查看文件

@@ -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
}
}
}




+ 30
- 0
Sources/App/Models/AuthTables/mdlSegment.swift 查看文件

@@ -78,6 +78,36 @@ extension mdlSegment{
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
}
}
}




+ 35
- 1
Sources/App/Models/AuthTables/mdlUser.swift 查看文件

@@ -84,7 +84,41 @@ extension mdlUser{
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
}
}
}




+ 32
- 0
Sources/App/Models/BaseTables/ChildTables/mdlResponseType.swift 查看文件

@@ -77,6 +77,38 @@ extension mdlResponseType{
.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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/ChildTables/mdlUnit.swift 查看文件

@@ -61,6 +61,37 @@ extension mdlUnit{
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
}
}
}




+ 32
- 0
Sources/App/Models/BaseTables/mdlCategory.swift 查看文件

@@ -58,4 +58,36 @@ extension mdlCategory{
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
}
}
}

+ 30
- 0
Sources/App/Models/BaseTables/mdlComparisonType.swift 查看文件

@@ -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
}
}
}


+ 30
- 0
Sources/App/Models/BaseTables/mdlContactType.swift 查看文件

@@ -75,6 +75,36 @@ extension mdlContactType{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlDataType.swift 查看文件

@@ -76,4 +76,35 @@ extension mdlDataType{
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
}
}
}

+ 31
- 0
Sources/App/Models/BaseTables/mdlDivision.swift 查看文件

@@ -60,6 +60,37 @@ extension mdlDivision{
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
}
}
}




+ 30
- 0
Sources/App/Models/BaseTables/mdlEquipmentType.swift 查看文件

@@ -71,4 +71,34 @@ extension mdlEquipmentType{
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
}
}
}

+ 30
- 0
Sources/App/Models/BaseTables/mdlFluid.swift 查看文件

@@ -60,6 +60,36 @@ extension mdlFluid{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlFuel.swift 查看文件

@@ -62,6 +62,37 @@ extension mdlFuel{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlGate.swift 查看文件

@@ -59,6 +59,37 @@
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlIncompleteReason.swift 查看文件

@@ -59,6 +59,37 @@ extension mdlIncompleteReason{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlInputType.swift 查看文件

@@ -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
}
}
}

+ 30
- 0
Sources/App/Models/BaseTables/mdlJobSite.swift 查看文件

@@ -74,5 +74,35 @@ extension mdlJobSite{
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
}
}
}


+ 30
- 0
Sources/App/Models/BaseTables/mdlLevel.swift 查看文件

@@ -60,6 +60,36 @@ extension mdlLevel{
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
}
}
}




+ 34
- 0
Sources/App/Models/BaseTables/mdlLocation.swift 查看文件

@@ -112,6 +112,40 @@ extension mdlLocation{
.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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlNoteType.swift 查看文件

@@ -59,6 +59,37 @@ extension mdlNoteType{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlPart.swift 查看文件

@@ -57,6 +57,37 @@ extension mdlPart{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlPriority.swift 查看文件

@@ -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
}
}
}



+ 31
- 0
Sources/App/Models/BaseTables/mdlReason.swift 查看文件

@@ -59,6 +59,37 @@ extension mdlReason{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlRepairType.swift 查看文件

@@ -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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlSMSCCode.swift 查看文件

@@ -57,6 +57,37 @@ extension mdlSMSCCode{
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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlSignatureType.swift 查看文件

@@ -72,6 +72,37 @@ extension mdlSignatureType{
.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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlState.swift 查看文件

@@ -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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlStatus.swift 查看文件

@@ -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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlValueType.swift 查看文件

@@ -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
}
}
}




+ 31
- 0
Sources/App/Models/BaseTables/mdlViscosity.swift 查看文件

@@ -57,6 +57,37 @@ extension mdlViscosity{
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
}
}
}




部分文件因文件數量過多而無法顯示

Loading…
取消
儲存