1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| package model
|
| import (
| "apsClient/pkg/snowflake"
| "time"
| )
|
| type CommonModel struct {
| ID uint `gorm:"primary_key" json:"ID,string"`
| CreatedAt time.Time
| UpdatedAt time.Time
| DeletedAt *time.Time `sql:"index"`
| }
|
| func (c *CommonModel) BeforeCreate() {
| if c.ID == 0 {
| c.ID = uint(snowflake.GenerateID())
| }
| }
|
|