user_auth.go
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package domain
import "time"
// 用户认证实体
type UserAuth struct {
// 用户认证编号
UserAuthId int64 `json:"userAuthId"`
// 用户id列表
Users []int64 `json:"users"`
// 手机认证
PhoneAuth *PhoneAuth `json:"phoneAuth"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
}
type UserAuthRepository interface {
Save(userAuth *UserAuth) (*UserAuth, error)
Remove(userAuth *UserAuth) (*UserAuth, error)
FindOne(queryOptions map[string]interface{}) (*UserAuth, error)
Find(queryOptions map[string]interface{}) (int64, []*UserAuth, error)
}
func (userAuth *UserAuth) Identify() interface{} {
if userAuth.UserAuthId == 0 {
return nil
}
return userAuth.UserAuthId
}
func (userAuth *UserAuth) Update(data map[string]interface{}) error {
if userAuthId, ok := data["userAuthId"]; ok {
userAuth.UserAuthId = userAuthId.(int64)
}
if users, ok := data["users"]; ok {
userAuth.Users = users.([]int64)
}
if phone, ok := data["phone"]; ok {
userAuth.PhoneAuth.Phone = phone.(string)
}
if password, ok := data["password"]; ok {
userAuth.PhoneAuth.Password = password.(string)
}
if createAt, ok := data["createAt"]; ok {
userAuth.CreateAt = createAt.(time.Time)
}
if updateAt, ok := data["updateAt"]; ok {
userAuth.UpdateAt = updateAt.(time.Time)
}
return nil
}