package api import ( "github.com/gin-gonic/gin" "online_code/client" "online_code/core" "online_code/models/entity" ) type userApi struct{} func UserApi() *userApi { return &userApi{} } // GetUserInfo 获取用户详情 func (userApi) GetUserInfo(ctx *gin.Context) { // 获取用户信息 identity := ctx.Param("identity") if identity == "" { core.R(ctx).FailWithMessage("参数不能为空: identity") return } userData := entity.UserBasic{} err := client.MySQL.Omit("password").Where("identity = ?", identity).Take(&userData).Error if err != nil { core.R(ctx).FailWithMessage("获取用户信息失败: " + err.Error()) return } core.R(ctx).OkWithData(userData) }