| GET | /users/head-of-department |
|---|
import Foundation
import ServiceStack
public class GetHeadOfDeparment : Codable
{
public var isParty:Bool
required public init(){}
}
public class AllUserResponse : Codable
{
public var users:[UserProfile] = []
public var code:Int
public var message:String
public var totalCount:Int
required public init(){}
}
public class UserProfile : UserLogin
{
public var id:Int
public var fullName:String
public var email:String
public var departmentId:Int?
public var partyGroupId:Int?
public var avatar:String
public var telephone:String
public var birthday:Date?
public var createdAt:Date?
public var updatedAt:Date?
public var failedLoginCount:Int
// @Ignore()
public var roles:[Int] = []
public var lastLoginDate:Date?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case fullName
case email
case departmentId
case partyGroupId
case avatar
case telephone
case birthday
case createdAt
case updatedAt
case failedLoginCount
case roles
case lastLoginDate
}
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)
fullName = try container.decodeIfPresent(String.self, forKey: .fullName)
email = try container.decodeIfPresent(String.self, forKey: .email)
departmentId = try container.decodeIfPresent(Int.self, forKey: .departmentId)
partyGroupId = try container.decodeIfPresent(Int.self, forKey: .partyGroupId)
avatar = try container.decodeIfPresent(String.self, forKey: .avatar)
telephone = try container.decodeIfPresent(String.self, forKey: .telephone)
birthday = try container.decodeIfPresent(Date.self, forKey: .birthday)
createdAt = try container.decodeIfPresent(Date.self, forKey: .createdAt)
updatedAt = try container.decodeIfPresent(Date.self, forKey: .updatedAt)
failedLoginCount = try container.decodeIfPresent(Int.self, forKey: .failedLoginCount)
roles = try container.decodeIfPresent([Int].self, forKey: .roles) ?? []
lastLoginDate = try container.decodeIfPresent(Date.self, forKey: .lastLoginDate)
}
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 fullName != nil { try container.encode(fullName, forKey: .fullName) }
if email != nil { try container.encode(email, forKey: .email) }
if departmentId != nil { try container.encode(departmentId, forKey: .departmentId) }
if partyGroupId != nil { try container.encode(partyGroupId, forKey: .partyGroupId) }
if avatar != nil { try container.encode(avatar, forKey: .avatar) }
if telephone != nil { try container.encode(telephone, forKey: .telephone) }
if birthday != nil { try container.encode(birthday, forKey: .birthday) }
if createdAt != nil { try container.encode(createdAt, forKey: .createdAt) }
if updatedAt != nil { try container.encode(updatedAt, forKey: .updatedAt) }
if failedLoginCount != nil { try container.encode(failedLoginCount, forKey: .failedLoginCount) }
if roles.count > 0 { try container.encode(roles, forKey: .roles) }
if lastLoginDate != nil { try container.encode(lastLoginDate, forKey: .lastLoginDate) }
}
}
public class UserLogin : Codable
{
// @Required()
public var name:String?
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /users/head-of-department HTTP/1.1 Host: etc-api.vsmlab.vn Accept: text/jsonl
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"users":[{"id":0,"fullName":"String","email":"String","departmentId":0,"partyGroupId":0,"avatar":"String","telephone":"String","birthday":"0001-01-01T00:00:00.0000000+07:06","createdAt":"0001-01-01T00:00:00.0000000+07:06","updatedAt":"0001-01-01T00:00:00.0000000+07:06","failedLoginCount":0,"roles":[0],"lastLoginDate":"0001-01-01T00:00:00.0000000+07:06","name":"String"}],"code":0,"message":"String","totalCount":0}