2025-02-08 18:57:05 +08:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2025-02-14 10:43:28 +08:00
|
|
|
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user/internal/gen/dao/model"
|
|
|
|
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user/internal/svc"
|
|
|
|
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user/user"
|
2025-02-08 18:57:05 +08:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CreateEmptyUserLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCreateEmptyUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateEmptyUserLogic {
|
|
|
|
return &CreateEmptyUserLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-14 10:30:15 +08:00
|
|
|
func (l *CreateEmptyUserLogic) CreateEmptyUser(_ *user.Empty) (*user.UserId, error) {
|
2025-02-08 18:57:05 +08:00
|
|
|
userId, err := l.svcCtx.IDGen.NextID()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = l.svcCtx.Query.User.WithContext(l.ctx).Create(&model.User{
|
|
|
|
ID: userId,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2025-02-14 10:30:15 +08:00
|
|
|
return &user.UserId{UserId: userId}, nil
|
2025-02-08 18:57:05 +08:00
|
|
|
}
|