| Required role: | super-admin |
| GET | /document-reference/search |
|---|
import Foundation
import ServiceStack
public class SearchDocumentReferenceRequest : PagingRequest
{
public var documentCode:String
public var parentDocumentId:Int?
public var title:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case documentCode
case parentDocumentId
case title
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
documentCode = try container.decodeIfPresent(String.self, forKey: .documentCode)
parentDocumentId = try container.decodeIfPresent(Int.self, forKey: .parentDocumentId)
title = try container.decodeIfPresent(String.self, forKey: .title)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if documentCode != nil { try container.encode(documentCode, forKey: .documentCode) }
if parentDocumentId != nil { try container.encode(parentDocumentId, forKey: .parentDocumentId) }
if title != nil { try container.encode(title, forKey: .title) }
}
}
public class PagingRequest : Codable
{
public var page:Int
public var limit:Int
required public init(){}
}
public class PageResponse<AuditLog : Codable> : IResponseRequest, Codable
{
public var code:Int
public var message:String
public var data:[AuditLog] = []
public var pagination:Pagination
required public init(){}
}
public class AuditLog : MongoObject, IEntityId, ICreated, IUpdate
{
public var userName:String
public var userId:Int?
public var documentId:Int
public var action:String
public var Description:String
public var createdDate:Date
public var updatedDate:Date
public var ipAddress:String
public var userAgent:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case userName
case userId
case documentId
case action
case Description
case createdDate
case updatedDate
case ipAddress
case userAgent
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
userName = try container.decodeIfPresent(String.self, forKey: .userName)
userId = try container.decodeIfPresent(Int.self, forKey: .userId)
documentId = try container.decodeIfPresent(Int.self, forKey: .documentId)
action = try container.decodeIfPresent(String.self, forKey: .action)
Description = try container.decodeIfPresent(String.self, forKey: .Description)
createdDate = try container.decodeIfPresent(Date.self, forKey: .createdDate)
updatedDate = try container.decodeIfPresent(Date.self, forKey: .updatedDate)
ipAddress = try container.decodeIfPresent(String.self, forKey: .ipAddress)
userAgent = try container.decodeIfPresent(String.self, forKey: .userAgent)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if userName != nil { try container.encode(userName, forKey: .userName) }
if userId != nil { try container.encode(userId, forKey: .userId) }
if documentId != nil { try container.encode(documentId, forKey: .documentId) }
if action != nil { try container.encode(action, forKey: .action) }
if Description != nil { try container.encode(Description, forKey: .Description) }
if createdDate != nil { try container.encode(createdDate, forKey: .createdDate) }
if updatedDate != nil { try container.encode(updatedDate, forKey: .updatedDate) }
if ipAddress != nil { try container.encode(ipAddress, forKey: .ipAddress) }
if userAgent != nil { try container.encode(userAgent, forKey: .userAgent) }
}
}
public class MongoObject : IMongoModel, Codable
{
public var id:String
required public init(){}
}
public class Pagination : Codable
{
public var total:Int
public var pages:Int
public var offset:Int
public var limit:Int
public var currentPage:Int
required public init(){}
}
Swift SearchDocumentReferenceRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /document-reference/search HTTP/1.1 Host: etc-api.vsmlab.vn Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"code":0,"message":"String","data":[{"id":0,"parentDocumentId":0,"title":"String","documentCode":"String","referenceUrl":"String","description":"String"}],"pagination":null}