package service_user import ( "context" "nixcn-cms/data" "nixcn-cms/internal/exception" "nixcn-cms/service/shared" "github.com/google/uuid" ) type UserInfoData struct { UserId uuid.UUID `json:"user_id"` Email string `json:"email"` Username string `json:"username"` Nickname string `json:"nickname"` Subtitle string `json:"subtitle"` Avatar string `json:"avatar"` Bio string `json:"bio"` PermissionLevel uint `json:"permission_level"` AllowPublic bool `json:"allow_public"` } type UserInfoPayload struct { Context context.Context UserId uuid.UUID Data *UserInfoData } type UserInfoResult struct { Common shared.CommonResult Data *UserInfoData } // GetUserInfo func (self *UserServiceImpl) GetUserInfo(payload *UserInfoPayload) (result *UserInfoResult) { var err error userData, err := new(data.User). GetByUserId( payload.Context, &payload.UserId, ) if err != nil { exception := new(exception.Builder). SetStatus(exception.StatusUser). SetService(exception.ServiceUser). SetEndpoint(exception.EndpointUserServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUserNotFound). SetError(err). Throw(payload.Context) result = &UserInfoResult{ Common: shared.CommonResult{ HttpCode: 404, Exception: exception, }, Data: nil, } return } exception := new(exception.Builder). SetStatus(exception.StatusUser). SetService(exception.ServiceUser). SetEndpoint(exception.EndpointUserServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). SetError(nil). Throw(payload.Context) result = &UserInfoResult{ Common: shared.CommonResult{ HttpCode: 200, Exception: exception, }, Data: &UserInfoData{ UserId: userData.UserId, Email: userData.Email, Username: userData.Username, Nickname: userData.Nickname, Subtitle: userData.Subtitle, Avatar: userData.Avatar, Bio: userData.Bio, PermissionLevel: userData.PermissionLevel, AllowPublic: userData.AllowPublic, }, } return }