fusenapi/server/home-user-auth/internal/logic/usersavebasicinfologic.go
2023-06-15 16:08:43 +08:00

43 lines
1007 B
Go

package logic
import (
"context"
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/server/home-user-auth/internal/types"
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
)
type UserSaveBasicInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUserSaveBasicInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserSaveBasicInfoLogic {
return &UserSaveBasicInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoForm, userinfo *auth.UserInfo) (resp *basic.Response) {
if !userinfo.IsUser() {
return resp.SetStatus(basic.CodeUnAuth)
}
m := gmodel.NewFsUserModel(l.svcCtx.MysqlConn)
user, err := m.FindUserById(l.ctx, userinfo.UserId)
if err == gmodel.ErrRecordNotFound {
return resp.SetStatus(basic.CodeUserIdNotFoundErr)
}
return resp.SetStatus(basic.CodeOK)
}