UPDATE: Change type response
All checks were successful
Build and Release / release (push) Successful in 1m7s
All checks were successful
Build and Release / release (push) Successful in 1m7s
This commit is contained in:
@@ -20,9 +20,26 @@ type UserEntity struct {
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
Roles []*RoleSimple `json:"roles"`
|
||||
}
|
||||
type UserSimpleEntity struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
DisplayName string `json:"display_name"`
|
||||
FullName string `json:"full_name"`
|
||||
AvatarUrl string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
func (u *UserSimpleEntity) ToResponse() *response.UserSimpleResponse {
|
||||
return &response.UserSimpleResponse{
|
||||
ID: u.ID,
|
||||
Email: u.Email,
|
||||
DisplayName: u.DisplayName,
|
||||
FullName: u.FullName,
|
||||
AvatarUrl: u.AvatarUrl,
|
||||
}
|
||||
}
|
||||
|
||||
func (u *UserEntity) ParseRoles(data []byte) error {
|
||||
if len(data) == 0 {
|
||||
if len(data) == 0 || string(data) == "null" {
|
||||
u.Roles = []*RoleSimple{}
|
||||
return nil
|
||||
}
|
||||
@@ -30,7 +47,7 @@ func (u *UserEntity) ParseRoles(data []byte) error {
|
||||
}
|
||||
|
||||
func (u *UserEntity) ParseProfile(data []byte) error {
|
||||
if len(data) == 0 {
|
||||
if len(data) == 0 || string(data) == "null" {
|
||||
u.Profile = &UserProfileSimple{}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
type UserVerificationEntity struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
User *UserSimpleEntity `json:"user"`
|
||||
VerifyType constants.VerifyType `json:"verify_type"`
|
||||
Content string `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
Status constants.StatusType `json:"status"`
|
||||
ReviewedBy string `json:"reviewed_by"`
|
||||
Reviewer *UserSimpleEntity `json:"reviewer"`
|
||||
ReviewNote string `json:"review_note"`
|
||||
ReviewedAt *time.Time `json:"reviewed_at"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
@@ -29,13 +29,29 @@ type UserVerificationStorageEntity struct {
|
||||
}
|
||||
|
||||
func (u *UserVerificationEntity) ParseMedia(data []byte) error {
|
||||
if len(data) == 0 {
|
||||
if len(data) == 0 || string(data) == "null" {
|
||||
u.Media = []*MediaSimpleEntity{}
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(data, &u.Media)
|
||||
}
|
||||
|
||||
func (u *UserVerificationEntity) ParseUser(data []byte) error {
|
||||
if len(data) == 0 || string(data) == "null" {
|
||||
u.User = nil
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(data, &u.User)
|
||||
}
|
||||
|
||||
func (u *UserVerificationEntity) ParseReviewer(data []byte) error {
|
||||
if len(data) == 0 || string(data) == "null" {
|
||||
u.Reviewer = nil
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(data, &u.Reviewer)
|
||||
}
|
||||
|
||||
func (u *UserVerificationEntity) ToResponse() *response.UserVerificationResponse {
|
||||
mediaResponses := make([]*response.MediaSimpleResponse, 0)
|
||||
for _, m := range u.Media {
|
||||
@@ -54,12 +70,12 @@ func (u *UserVerificationEntity) ToResponse() *response.UserVerificationResponse
|
||||
|
||||
res := &response.UserVerificationResponse{
|
||||
ID: u.ID,
|
||||
UserID: u.UserID,
|
||||
User: u.User.ToResponse(),
|
||||
VerifyType: u.VerifyType.String(),
|
||||
Content: u.Content,
|
||||
Status: u.Status.String(),
|
||||
ReviewNote: u.ReviewNote,
|
||||
ReviewedBy: u.ReviewedBy,
|
||||
Reviewer: u.Reviewer.ToResponse(),
|
||||
ReviewedAt: u.ReviewedAt,
|
||||
CreatedAt: u.CreatedAt,
|
||||
Medias: mediaResponses,
|
||||
|
||||
Reference in New Issue
Block a user