Skip to content

Commit

Permalink
Related changes in model for commit d6d1d1d
Browse files Browse the repository at this point in the history
  • Loading branch information
victorzhu30 committed Aug 6, 2024
1 parent 027caad commit 797e488
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 53 deletions.
58 changes: 21 additions & 37 deletions model/converter/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func ConvertUserPOToDomain(userPO po.UserPO) domain.User {

func ConvertUserProfilePOToDomain(userProfile po.UserProfilePO) domain.UserProfile {
return domain.UserProfile{
UserID: userProfile.UserID,
Avatar: userProfile.Avatar,
Department: userProfile.Department,
Type: userProfile.Type,
Major: userProfile.Major,
Degree: userProfile.Degree,
Grade: userProfile.Grade,
PersonalSignature: userProfile.PersonalSignature,
UserID: userProfile.UserID,
Avatar: userProfile.Avatar,
Department: userProfile.Department,
Type: userProfile.Type,
Major: userProfile.Major,
Degree: userProfile.Degree,
Grade: userProfile.Grade,
Bio: userProfile.Bio,
}
}

Expand All @@ -46,30 +46,15 @@ func ConvertUserDomainToReviewDTO(user domain.User) dto.UserInReviewDTO {
}
}

func ConvertToUserSummaryDTO(userPO *po.UserPO, userProfilePO *po.UserProfilePO) *dto.UserSummaryDTO {
func ConvertToUserDetailDTO(userPO *po.UserPO, userProfilePO *po.UserProfilePO) *dto.UserDetailDTO {
if userPO == nil {
return nil
}
return &dto.UserSummaryDTO{
return &dto.UserDetailDTO{
ID: int64(userPO.ID),
Username: userPO.Username,
Avatar: userProfilePO.Avatar,
Role: userPO.UserRole,
}
}

func ConvertToUserDetailsDTO(userPO *po.UserPO, userProfilePO *po.UserProfilePO) *dto.UserDetailsDTO {
if userPO == nil {
return nil
}
return &dto.UserDetailsDTO{
ID: int64(userPO.ID),
Username: userPO.Username,
Role: userPO.UserRole,
LastSeenAt: userPO.LastSeenAt,
Type: userPO.UserRole,
Avatar: userProfilePO.Avatar,
PersonalSignature: userProfilePO.PersonalSignature,
Bio: userProfilePO.Bio,
}
}

Expand All @@ -78,16 +63,15 @@ func ConvertToUserProfileDTO(userPO *po.UserPO, userProfilePO *po.UserProfilePO)
return nil
}
return &dto.UserProfileDTO{
ID: int64(userPO.ID),
UserID: userProfilePO.UserID,
Avatar: userProfilePO.Avatar,
Department: userProfilePO.Department,
Type: userProfilePO.Type,
Major: userProfilePO.Major,
Degree: userProfilePO.Degree,
Grade: userProfilePO.Grade,
PersonalSignature: userProfilePO.PersonalSignature,
Username: userPO.Username,
Role: userPO.UserRole,
ID: int64(userPO.ID),
UserID: userProfilePO.UserID,
Username: userPO.Username,
Bio: userProfilePO.Bio,
Email: userPO.Email,
Avatar: userProfilePO.Avatar,
Role: userPO.UserRole,
Department: userProfilePO.Department,
Major: userProfilePO.Major,
Grade: userProfilePO.Grade,
}
}
16 changes: 8 additions & 8 deletions model/domain/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ type User struct {
}

type UserProfile struct {
UserID int64
Avatar string
Department string
Type UserType // 用户在学校的身份
Major string
Degree string
Grade string
PersonalSignature string
UserID int64
Avatar string
Department string
Type UserType // 用户在学校的身份
Major string
Degree string
Grade string
Bio string
}

type UserFilter struct {
Expand Down
16 changes: 8 additions & 8 deletions model/po/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ func (po *UserPO) TableName() string {

type UserProfilePO struct {
gorm.Model
UserID int64
Avatar string
Department string
Type string // 用户在学校的身份
Major string
Degree string
Grade string
PersonalSignature string
UserID int64
Avatar string
Department string
Type string // 用户在学校的身份
Major string
Degree string
Grade string
Bio string
}

func (profile *UserProfilePO) TableName() string {
Expand Down

0 comments on commit 797e488

Please sign in to comment.