sys_user.go
1.7 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
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/tool"
"gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction"
)
type SysUser struct {
Id int64 `json:",omitempty"` // 唯一标识
Name string `json:",omitempty"` // 姓名
Phone string `json:",omitempty"` // 手机号码
Avatar string `json:",omitempty"` // 头像
Password string `json:",omitempty"` // 密码
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
//Email string `json:",omitempty"` // 邮箱
//Sex int `json:",omitempty"` // 0:女 1:男
EmployeeId int64 `json:"-"`
}
type SysUserRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *SysUser) (*SysUser, error)
Update(ctx context.Context, conn transaction.Conn, dm *SysUser) (*SysUser, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *SysUser) (*SysUser, error)
Delete(ctx context.Context, conn transaction.Conn, dm *SysUser) (*SysUser, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*SysUser, error)
FindOneByPhone(ctx context.Context, conn transaction.Conn, phone string) (*SysUser, error)
FindOneUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*SysUser, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*SysUser, error)
}
func NewDomainSysUser(phone string, name string, password string) *SysUser {
if password == "" {
password = "123456"
}
if name == "" {
name = "用户" + tool.Krand(6, tool.KC_RAND_KIND_NUM)
}
return &SysUser{
Phone: phone,
Name: name,
Password: tool.Md5ByString(password),
}
}