| GET | /document-template/bydocument |
|---|
import Foundation
import ServiceStack
public class GetTemplateByDocumentIdRequest : Codable
{
public var documentId:Int
required public init(){}
}
public class DocumentTemplateResponse : Codable
{
public var template:DocumentTemplateDto
public var insertedId:Int
public var code:Int
public var message:String
required public init(){}
}
public class DocumentTemplateDto : DocumentTemplate
{
public var elements:[DocumentElementDto] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case elements
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
elements = try container.decodeIfPresent([DocumentElementDto].self, forKey: .elements) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if elements.count > 0 { try container.encode(elements, forKey: .elements) }
}
}
public class DocumentTemplate : Codable
{
public var id:Int
// @Required()
public var title:String?
public var Description:String
public var isActive:Bool
// @Ignore()
public var documentIds:[Int] = []
// @Ignore()
public var documents:[Document] = []
required public init(){}
}
public class Document : BasicDocument
{
public var id:Int
// @StringLength(500)
public var reasonReturn:String
public var accountId:Int?
public var deletedAt:Date?
// @StringLength(500)
public var deletedBy:String
// @StringLength(500)
public var updatedBy:String
public var createdAt:Date?
// @StringLength(500)
public var createdBy:String
public var isParty:Bool?
public var isRevisionRequested:Bool
public var lastUpdatedAt:Date?
public var isPrivate:Bool?
public var departmentId:Int?
public var publicationDate:Date?
public var processStatusId:Int?
public var fullTextSearchContent:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case reasonReturn
case accountId
case deletedAt
case deletedBy
case updatedBy
case createdAt
case createdBy
case isParty
case isRevisionRequested
case lastUpdatedAt
case isPrivate
case departmentId
case publicationDate
case processStatusId
case fullTextSearchContent
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(Int.self, forKey: .id)
reasonReturn = try container.decodeIfPresent(String.self, forKey: .reasonReturn)
accountId = try container.decodeIfPresent(Int.self, forKey: .accountId)
deletedAt = try container.decodeIfPresent(Date.self, forKey: .deletedAt)
deletedBy = try container.decodeIfPresent(String.self, forKey: .deletedBy)
updatedBy = try container.decodeIfPresent(String.self, forKey: .updatedBy)
createdAt = try container.decodeIfPresent(Date.self, forKey: .createdAt)
createdBy = try container.decodeIfPresent(String.self, forKey: .createdBy)
isParty = try container.decodeIfPresent(Bool.self, forKey: .isParty)
isRevisionRequested = try container.decodeIfPresent(Bool.self, forKey: .isRevisionRequested)
lastUpdatedAt = try container.decodeIfPresent(Date.self, forKey: .lastUpdatedAt)
isPrivate = try container.decodeIfPresent(Bool.self, forKey: .isPrivate)
departmentId = try container.decodeIfPresent(Int.self, forKey: .departmentId)
publicationDate = try container.decodeIfPresent(Date.self, forKey: .publicationDate)
processStatusId = try container.decodeIfPresent(Int.self, forKey: .processStatusId)
fullTextSearchContent = try container.decodeIfPresent(String.self, forKey: .fullTextSearchContent)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
if reasonReturn != nil { try container.encode(reasonReturn, forKey: .reasonReturn) }
if accountId != nil { try container.encode(accountId, forKey: .accountId) }
if deletedAt != nil { try container.encode(deletedAt, forKey: .deletedAt) }
if deletedBy != nil { try container.encode(deletedBy, forKey: .deletedBy) }
if updatedBy != nil { try container.encode(updatedBy, forKey: .updatedBy) }
if createdAt != nil { try container.encode(createdAt, forKey: .createdAt) }
if createdBy != nil { try container.encode(createdBy, forKey: .createdBy) }
if isParty != nil { try container.encode(isParty, forKey: .isParty) }
if isRevisionRequested != nil { try container.encode(isRevisionRequested, forKey: .isRevisionRequested) }
if lastUpdatedAt != nil { try container.encode(lastUpdatedAt, forKey: .lastUpdatedAt) }
if isPrivate != nil { try container.encode(isPrivate, forKey: .isPrivate) }
if departmentId != nil { try container.encode(departmentId, forKey: .departmentId) }
if publicationDate != nil { try container.encode(publicationDate, forKey: .publicationDate) }
if processStatusId != nil { try container.encode(processStatusId, forKey: .processStatusId) }
if fullTextSearchContent != nil { try container.encode(fullTextSearchContent, forKey: .fullTextSearchContent) }
}
}
public class BasicDocument : Codable
{
// @Required()
public var title:String?
// @StringLength(4000)
public var Description:String
// @StringLength(500)
public var owner:String
public var documentPolicyId:Int?
public var updateDocumentId:Int?
public var effectBeginDate:Date?
public var effectEndDate:Date?
public var issuingAgencyId:Int?
public var documentTypeId:Int?
public var documentGroupId:Int?
public var subjectId:Int?
// @StringLength(500)
public var signBy:String
public var signDate:Date?
public var statusId:Int?
public var isInternal:Bool
public var documentNumber:String
public var documentCode:String
public var isUrgent:Bool?
public var scopeType:Int?
public var isActive:Bool?
required public init(){}
}
public class DocumentElementDto : DocumentElement
{
public var children:[DocumentElementDto] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case children
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
children = try container.decodeIfPresent([DocumentElementDto].self, forKey: .children) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if children.count > 0 { try container.encode(children, forKey: .children) }
}
}
public class DocumentElement : Codable
{
public var id:Int
public var templateId:Int
// @Required()
public var elementKey:String?
// @Required()
public var tag:String?
public var parentId:Int?
// @Required()
public var title:String?
public var Description:String
// @Required()
public var dataType:String?
public var templateType:String
public var orderIndex:Int
public var isRequired:Bool?
required public init(){}
}
Swift GetTemplateByDocumentIdRequest 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-template/bydocument HTTP/1.1 Host: etc-api.vsmlab.vn Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"template":{"elements":[{"children":[{"children":[{"children":null,"id":0,"templateId":0,"elementKey":"String","tag":"String","parentId":0,"title":"String","description":"String","dataType":"String","templateType":"String","orderIndex":0,"isRequired":false}],"id":0,"templateId":0,"elementKey":"String","tag":"String","parentId":0,"title":"String","description":"String","dataType":"String","templateType":"String","orderIndex":0,"isRequired":false}],"id":0,"templateId":0,"elementKey":"String","tag":"String","parentId":0,"title":"String","description":"String","dataType":"String","templateType":"String","orderIndex":0,"isRequired":false}],"id":0,"title":"String","description":"String","isActive":false,"documentIds":[0],"documents":[{"id":0,"reasonReturn":"String","accountId":0,"deletedAt":"0001-01-01T00:00:00.0000000+07:06","deletedBy":"String","updatedBy":"String","createdAt":"0001-01-01T00:00:00.0000000+07:06","createdBy":"String","isParty":false,"isRevisionRequested":false,"lastUpdatedAt":"0001-01-01T00:00:00.0000000+07:06","isPrivate":false,"departmentId":0,"publicationDate":"0001-01-01T00:00:00.0000000+07:06","processStatusId":0,"fullTextSearchContent":"String","title":"String","description":"String","owner":"String","documentPolicyId":0,"updateDocumentId":0,"effectBeginDate":"0001-01-01T00:00:00.0000000+07:06","effectEndDate":"0001-01-01T00:00:00.0000000+07:06","issuingAgencyId":0,"documentTypeId":0,"documentGroupId":0,"subjectId":0,"signBy":"String","signDate":"0001-01-01T00:00:00.0000000+07:06","statusId":0,"isInternal":false,"documentNumber":"String","documentCode":"String","isUrgent":false,"scopeType":0,"isActive":false}]},"insertedId":0,"code":0,"message":"String"}