审查视图

pkg/infrastructure/pg/models/partner_info.go 1.2 KB
tangxvhui authored
1 2 3
package models

import (
tangxvhui authored
4
	"context"
tangxvhui authored
5 6
	"time"
tangxvhui authored
7
	"github.com/go-pg/pg/v10"
tangxvhui authored
8 9 10 11
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
)

type PartnerInfo struct {
唐旭辉 authored
12
	tableName struct{} `pg:"partner_info"`
tangxvhui authored
13 14 15 16 17 18 19 20 21
	// 合伙人ID
	Id int64 `pg:",pk"`
	// 合伙人姓名
	PartnerName string
	// 登录账号
	Account string
	// 登录密码
	Password string
	// 状态(1:启用或者0:禁用)
tangxvhui authored
22
	Status int `pg:",use_zero"`
.  
tangxvhui authored
23
	//所属区域信息
唐旭辉 authored
24
	RegionInfo domain.RegionInfo
tangxvhui authored
25 26 27 28
	//创建时间
	CreateAt time.Time
	//更新时间
	UpdateAt time.Time
.  
tangxvhui authored
29 30
	//合作时间
	CooperateTime time.Time
tangxvhui authored
31
	//关联业务员
32
	Salesman []domain.Salesman
唐旭辉 authored
33 34 35
	// 合伙类别 (1.研发合伙人 2.业务合伙人  3.事业)
	PartnerCategory int `pg:",default:1"` //partner_category
	//合伙类别
唐旭辉 authored
36
	PartnerCategoryInfos []domain.PartnerCategory
唐旭辉 authored
37 38
	//公司id
	CompanyId int64
tangxvhui authored
39
}
tangxvhui authored
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

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

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

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

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