@@ -5,11 +5,13 @@ import (
5
5
"github.com/coderi421/gframework/gmicro/registry"
6
6
"github.com/coderi421/gframework/gmicro/server/rpcserver"
7
7
"github.com/coderi421/gframework/gmicro/server/rpcserver/clientinterceptors"
8
+ itime "github.com/coderi421/gframework/pkg/common/time"
8
9
"github.com/coderi421/gframework/pkg/errors"
9
10
upbv1 "github.com/coderi421/goshop/api/user/v1"
10
11
"github.com/coderi421/goshop/app/pkg/code"
11
12
"github.com/coderi421/goshop/app/pkg/options"
12
13
"github.com/coderi421/goshop/app/shop/custom/internal/data"
14
+ "time"
13
15
)
14
16
15
17
const (
@@ -40,27 +42,63 @@ type users struct {
40
42
41
43
var _ data.UserData = & users {}
42
44
43
- func (u * users ) Create (ctx context.Context , user * data.User ) error {
44
- //TODO implement me
45
- panic ("implement me" )
45
+ func (u * users ) Create (ctx context.Context , user * data.User ) (int32 , error ) {
46
+ protoUser := & upbv1.CreateUserInfo {
47
+ NickName : user .NickName ,
48
+ PassWord : user .PassWord ,
49
+ Mobile : user .Mobile ,
50
+ }
51
+ resp , err := u .uc .CreateUser (ctx , protoUser )
52
+ return resp .Id , err
46
53
}
47
54
48
55
func (u * users ) Update (ctx context.Context , user * data.User ) error {
49
- //TODO implement me
50
- panic ("implement me" )
56
+ protoUser := & upbv1.UpdateUserInfo {
57
+ Id : user .ID ,
58
+ NickName : user .NickName ,
59
+ Gender : user .Gender ,
60
+ BirthDay : uint64 (user .Birthday .Unix ()),
61
+ }
62
+ _ , err := u .uc .UpdateUser (ctx , protoUser )
63
+ return err
51
64
}
52
65
53
- func (u * users ) Get (ctx context.Context , userID uint64 ) (data.User , error ) {
54
- //TODO implement me
55
- panic ("implement me" )
66
+ func (u * users ) Get (ctx context.Context , userID int32 ) (* data.User , error ) {
67
+ user , err := u .uc .GetUserById (ctx , & upbv1.IdRequest {Id : userID })
68
+ if err != nil {
69
+ return nil , err
70
+ }
71
+ return & data.User {
72
+ ID : user .Id ,
73
+ Mobile : user .Mobile ,
74
+ NickName : user .NickName ,
75
+ Birthday : itime.Time {time .Unix (int64 (user .BirthDay ), 0 )}.Time ,
76
+ Gender : user .Gender ,
77
+ Role : user .Role ,
78
+ PassWord : user .PassWord ,
79
+ }, nil
56
80
}
57
81
58
- func (u * users ) GetByMobile (ctx context.Context , mobile string ) (data.User , error ) {
59
- //TODO implement me
60
- panic ("implement me" )
82
+ func (u * users ) GetByMobile (ctx context.Context , mobile string ) (* data.User , error ) {
83
+ user , err := u .uc .GetUserByMobile (ctx , & upbv1.MobileRequest {Mobile : mobile })
84
+ if err != nil {
85
+ return nil , err
86
+ }
87
+ return & data.User {
88
+ ID : user .Id ,
89
+ Mobile : user .Mobile ,
90
+ NickName : user .NickName ,
91
+ Birthday : itime.Time {time .Unix (int64 (user .BirthDay ), 0 )}.Time ,
92
+ Gender : user .Gender ,
93
+ Role : user .Role ,
94
+ PassWord : user .PassWord ,
95
+ }, nil
61
96
}
62
97
63
- func (u * users ) CheckPassWord (ctx context.Context , password , encryptedPwd string ) error {
64
- //TODO implement me
65
- panic ("implement me" )
98
+ func (u * users ) CheckPassWord (ctx context.Context , password , encryptedPwd string ) (ok bool , err error ) {
99
+ cres , err := u .uc .CheckPassWord (ctx , & upbv1.PasswordCheckInfo {
100
+ Password : password ,
101
+ EncryptedPassword : encryptedPwd ,
102
+ })
103
+ return cres .Success , err
66
104
}
0 commit comments