|
|
package models
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"time"
|
|
|
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -31,3 +33,18 @@ type Users struct { |
|
|
UpdateAt time.Time
|
|
|
DeleteAt time.Time
|
|
|
}
|
|
|
|
|
|
var _ pg.BeforeUpdateHook = (*Users)(nil)
|
|
|
|
|
|
func (user *Users) BeforeUpdate(ctx context.Context) (context.Context, error) {
|
|
|
user.UpdateAt = time.Now()
|
|
|
return ctx, nil
|
|
|
}
|
|
|
|
|
|
var _ pg.BeforeInsertHook = (*Users)(nil)
|
|
|
|
|
|
func (user *Users) BeforeInsert(ctx context.Context) (context.Context, error) {
|
|
|
user.CreateAt = time.Now()
|
|
|
user.UpdateAt = time.Now()
|
|
|
return ctx, nil
|
|
|
} |
...
|
...
|
|