-
Notifications
You must be signed in to change notification settings - Fork 0
/
permission.go
44 lines (36 loc) · 1.22 KB
/
permission.go
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
package models
import (
"github.com/duc-cnzj/execit-client/rbac"
"github.com/duc-cnzj/execit/internal/utils/date"
"time"
"gorm.io/gorm"
)
type State uint8
type UserPermission struct {
ID int `json:"id" gorm:"primaryKey;"`
Username string `json:"username"`
Email string `json:"email" gorm:"not null;index;"`
Permission rbac.Permission `json:"permission" gorm:"index;"`
SubjectID int64 `json:"subject_id"`
State rbac.State `json:"state" gorm:"index;"`
Reason string `json:"reason"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"deleted_at"`
}
func (p *UserPermission) ProtoTransform() *rbac.UserPermission {
return &rbac.UserPermission{
Id: int64(p.ID),
Username: p.Username,
Email: p.Email,
Permission: p.Permission,
State: p.State,
Reason: p.Reason,
SubjectId: p.SubjectID,
Description: p.Description,
CreatedAt: date.ToRFC3339DatetimeString(&p.CreatedAt),
UpdatedAt: date.ToRFC3339DatetimeString(&p.UpdatedAt),
DeletedAt: date.ToRFC3339DatetimeString(&p.DeletedAt.Time),
}
}