2024-12-01 18:04:02 +08:00
|
|
|
package impl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"gitlab.com/go-course-project/go17/vblog/apps/user"
|
|
|
|
)
|
|
|
|
|
|
|
|
var UserService user.Service = &UserServiceImpl{}
|
|
|
|
|
|
|
|
// 定义一个struct, 用于实现 UserService就是刚才定义的接口
|
|
|
|
// 怎么才能判断这个结构体没有实现这个接口
|
|
|
|
type UserServiceImpl struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// DescribeUser implements user.Service.
|
|
|
|
func (u *UserServiceImpl) DescribeUser(context.Context, *user.DescribeUserRequest) (*user.User, error) {
|
|
|
|
panic("unimplemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Registry implements user.Service.
|
2024-12-08 10:10:37 +08:00
|
|
|
func (u *UserServiceImpl) Registry(ctx context.Context, in *user.RegistryRequest) (*user.User, error) {
|
|
|
|
ins, err := user.New(in)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// 无事务的模式
|
|
|
|
// datasource.DB().Transaction(func(tx *gorm.DB) error {
|
|
|
|
// ctx := datasource.WithTransactionCtx(ctx)
|
|
|
|
// // 1.
|
|
|
|
// svcA.Call(ctx)
|
|
|
|
// // 2.
|
|
|
|
// svcB.Call(ctx)
|
|
|
|
// // 3.
|
|
|
|
// svcC.Call(ctx)
|
|
|
|
// })
|
|
|
|
|
|
|
|
return ins, nil
|
2024-12-01 18:04:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ResetPassword implements user.Service.
|
|
|
|
func (u *UserServiceImpl) ResetPassword(context.Context, *user.ResetPasswordRequest) error {
|
|
|
|
panic("unimplemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnRegistry implements user.Service.
|
2024-12-08 10:10:37 +08:00
|
|
|
func (u *UserServiceImpl) UnRegistry(ctx context.Context, in *user.UnRegistryRequest) {
|
|
|
|
// datasource.GetTransactionFromCtx(ctx)
|
|
|
|
// datasource.DB()
|
|
|
|
// datasource.DBFromCtx()
|
2024-12-01 18:04:02 +08:00
|
|
|
panic("unimplemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdatePassword implements user.Service.
|
|
|
|
func (u *UserServiceImpl) UpdatePassword(context.Context, *user.UpdatePasswordRequest) error {
|
|
|
|
panic("unimplemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateProfile implements user.Service.
|
|
|
|
func (u *UserServiceImpl) UpdateProfile(context.Context, *user.UpdateProfileRequest) (*user.User, error) {
|
|
|
|
panic("unimplemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateUserStatus implements user.Service.
|
|
|
|
func (u *UserServiceImpl) UpdateUserStatus(context.Context, *user.UpdateUserStatusRequest) (*user.User, error) {
|
|
|
|
panic("unimplemented")
|
|
|
|
}
|