admin_user.go
934 字节
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
package models
import (
"context"
"time"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"github.com/go-pg/pg/v10"
)
type AdminUser struct {
tableName struct{} `pg:"admin_user"`
//id
Id int64 `pg:",pk"`
//用户账号
Account string `pg:",unique"`
//用户名称
AdminName string
//账号密码
Password string
//是否是默认账号
IsDefault bool `pg:",use_zero"`
//账号是否可用
IsUsable bool `pg:",use_zero"`
//用户的权限
Permission []domain.AdminPermissionBase
CreateAt time.Time
UpdateAt time.Time
}
var _ pg.BeforeUpdateHook = (*AdminUser)(nil)
func (user *AdminUser) BeforeUpdate(ctx context.Context) (context.Context, error) {
user.UpdateAt = time.Now()
return ctx, nil
}
var _ pg.BeforeInsertHook = (*AdminUser)(nil)
func (user *AdminUser) BeforeInsert(ctx context.Context) (context.Context, error) {
user.CreateAt = time.Now()
user.UpdateAt = time.Now()
return ctx, nil
}