From ce534bc77b2b7a986587a6d89e0d6cba1c17d2f6 Mon Sep 17 00:00:00 2001 From: ryoii Date: Thu, 6 Feb 2020 18:32:17 +0800 Subject: [PATCH] http-api make level-top function a constructor --- .../mamoe/mirai/api/http/dto/ContactDTO.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/ContactDTO.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/ContactDTO.kt index ce87ea576..812411c04 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/ContactDTO.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/ContactDTO.kt @@ -16,10 +16,11 @@ data class QQDTO( override val id: Long, val nickName: String, val remark: String -) : ContactDTO() +) : ContactDTO() { + // TODO: queryProfile.nickname & queryRemark.value not support now + constructor(qq: QQ) : this(qq.id, "", "") +} -// TODO: queryProfile.nickname & queryRemark.value not support now -suspend fun QQDTO(qq: QQ): QQDTO = QQDTO(qq.id, "", "") @Serializable data class MemberDTO( @@ -27,15 +28,17 @@ data class MemberDTO( val memberName: String = "", val permission: MemberPermission, val group: GroupDTO -) : ContactDTO() - -fun MemberDTO(member: Member, name: String = ""): MemberDTO = MemberDTO(member.id, name, member.permission, GroupDTO(member.group)) +) : ContactDTO() { + constructor(member: Member, name: String = "") : this ( + member.id, name, member.permission, GroupDTO(member.group) + ) +} @Serializable data class GroupDTO( override val id: Long, val name: String, val permission: MemberPermission -) : ContactDTO() - -fun GroupDTO(group: Group): GroupDTO = GroupDTO(group.id, group.name, group.botPermission) \ No newline at end of file +) : ContactDTO() { + constructor(group: Group) : this(group.id, group.name, group.botPermission) +}