初始化项目框架,完成部分接口开发
This commit is contained in:
24
internal/controller/user/user_v1_user_info.go
Normal file
24
internal/controller/user/user_v1_user_info.go
Normal file
@ -0,0 +1,24 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserInfo(ctx context.Context, req *v1.UserInfoReq) (res *v1.UserInfoRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
info, err := service.User().Info(ctx, &model.UserInfoIn{UserId: userId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserInfoRes{
|
||||
Username: info.Username,
|
||||
Avatar: info.Avatar,
|
||||
Email: info.Email,
|
||||
Points: info.Points,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user