审查视图

pkg/infrastructure/pg/models/company.go 974 字节
唐旭辉 authored
1 2
package models
唐旭辉 authored
3 4 5 6 7 8
import (
	"context"
	"time"

	"github.com/go-pg/pg/v10"
)
唐旭辉 authored
9 10 11 12 13

// 公司信息
type Company struct {
	tableName struct{} `pg:"company"`
	//	唯一标识
唐旭辉 authored
14
	Id int64 `pg:",pk"`
唐旭辉 authored
15 16
	//	名称
	Name string
唐旭辉 authored
17 18
	//简称
	Abbreviation string
唐旭辉 authored
19 20 21 22 23 24 25 26 27
	//	手机号码
	Phone string
	//	公司logo
	Logo string
	//	备注
	Remarks string
	//	总后台的公司id
	AdminCompanyId int
	//	状态 1正常 2禁用
唐旭辉 authored
28
	//Status int8
唐旭辉 authored
29 30 31 32 33 34 35 36 37
	//是否开启机会模块,是否有效【1:有效】【2:无效】
	Enable int8
	//	创建时间
	CreateAt time.Time
	//	更新时间
	UpdateAt time.Time
	//	删除时间
	DeleteAt time.Time
}
唐旭辉 authored
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

var _ pg.BeforeUpdateHook = (*Company)(nil)

func (c *Company) BeforeUpdate(ctx context.Context) (context.Context, error) {
	c.UpdateAt = time.Now()
	return ctx, nil
}

var _ pg.BeforeInsertHook = (*Company)(nil)

func (c *Company) BeforeInsert(ctx context.Context) (context.Context, error) {
	c.CreateAt = time.Now()
	c.UpdateAt = time.Now()
	return ctx, nil
}