用户修改头像、昵称、绑定手机号、获取用户详细信息
This commit is contained in:
26
internal/controller/user/user_v1_bind_phone.go
Normal file
26
internal/controller/user/user_v1_bind_phone.go
Normal file
@ -0,0 +1,26 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BindPhone(ctx context.Context, req *v1.BindPhoneReq) (res *v1.BindPhoneRes, err error) {
|
||||
|
||||
id := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
|
||||
out, err := service.User().BindPhone(ctx, &model.UserBindPhoneIn{
|
||||
PhoneCode: req.Code,
|
||||
Phone: req.Phone,
|
||||
Id: id,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BindPhoneRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/user/user_v1_get_phone_code.go
Normal file
24
internal/controller/user/user_v1_get_phone_code.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) GetPhoneCode(ctx context.Context, req *v1.GetPhoneCodeReq) (res *v1.GetPhoneCodeRes, err error) {
|
||||
|
||||
id := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.User().Code(ctx, &model.GetPhoneCodeIn{
|
||||
Phone: req.Phone,
|
||||
Id: id,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.GetPhoneCodeRes{Success: out.Success}, nil
|
||||
}
|
||||
35
internal/controller/user/user_v1_info.go
Normal file
35
internal/controller/user/user_v1_info.go
Normal file
@ -0,0 +1,35 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
|
||||
|
||||
id := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.User().Info(ctx, &model.UserInfoIn{
|
||||
OpenId: req.OpenId,
|
||||
Id: int(id),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.InfoRes{
|
||||
Avatar: out.Avatar,
|
||||
Email: out.Email,
|
||||
Id: int(out.Id),
|
||||
Nickname: out.Nickname,
|
||||
PhoneNumber: out.PhoneNumber,
|
||||
QQPopenId: out.QQPopenId,
|
||||
RoleId: int(out.RoleId),
|
||||
Username: out.Username,
|
||||
WxOpenId: out.WxOpenId,
|
||||
WxPopenId: out.WxPopenId,
|
||||
}, nil
|
||||
}
|
||||
24
internal/controller/user/user_v1_update.go
Normal file
24
internal/controller/user/user_v1_update.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) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
|
||||
|
||||
id := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.User().Update(ctx, &model.UserUpdateIn{
|
||||
Id: id,
|
||||
Nickname: req.Nickname,
|
||||
Avatar: req.Avatar,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UpdateRes{Success: out.Success}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user