feat: Add public user information retrieval endpoint
- Introduced a new endpoint to fetch public user information without authentication. - Implemented UserToPublicUserInfo function to format user data for the response. - Updated UserService interface and user service implementation to support fetching users by username. - Enhanced user handler to validate input parameters and check user status before responding.
This commit is contained in:
@@ -62,6 +62,19 @@ func UserToUserInfo(user *model.User) *types.UserInfo {
|
||||
}
|
||||
}
|
||||
|
||||
// UserToPublicUserInfo 将 User 模型转换为 PublicUserInfo 响应
|
||||
func UserToPublicUserInfo(user *model.User) *types.PublicUserInfo {
|
||||
return &types.PublicUserInfo{
|
||||
ID: user.ID,
|
||||
Username: user.Username,
|
||||
Avatar: user.Avatar,
|
||||
Points: user.Points,
|
||||
Role: user.Role,
|
||||
Status: user.Status,
|
||||
CreatedAt: user.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// ProfileToProfileInfo 将 Profile 模型转换为 ProfileInfo 响应
|
||||
func ProfileToProfileInfo(profile *model.Profile) *types.ProfileInfo {
|
||||
return &types.ProfileInfo{
|
||||
|
||||
Reference in New Issue
Block a user