| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("master_company", "公司主数据表 - 存储法人实体信息,用于结算和管理").
- ID("id", 50).NotNull().Comment("公司ID").End().
- String("type", 30).NotNull().Default("'SUBSIDIARY'").Comment("公司类型: SUPPLIER供应商/SUBSIDIARY子公司/AGENT代理商/WHOLESALER批发商/GROUP集团/FRANCHISEE加盟商/CUSTOMER客户/LOGISTICS物流商").End().
- String("code", 50).NotNull().Comment("公司编码").End().
- String("name", 200).NotNull().Comment("公司名称").End().
- String("short_name", 100).Comment("公司简称").End().
- String("english_name", 200).Comment("英文名称").End().
- String("parent_id", 50).Comment("上级公司ID").End().
- Int("level").Comment("公司层级 1:集团 2:子公司 3:分公司").End().
- String("tax_id", 30).Comment("税号/统一社会信用代码").End().
- String("legal_representative", 50).Comment("法定代表人").End().
- String("contact_person", 50).Comment("联系人").End().
- String("contact_phone", 20).Comment("联系电话").End().
- String("email", 100).Comment("邮箱").End().
- String("address", 500).Comment("公司地址").End().
- String("bank_name", 100).Comment("开户银行").End().
- String("bank_account", 50).Comment("银行账号").End().
- String("account_holder", 100).Comment("账户持有人").End().
- String("status", 20).Comment("状态 ACTIVE/INACTIVE").End().
- Bool("is_active").Comment("是否激活").End().
- Text("remark").Comment("备注").End().
- JSON("extra_properties").Comment("扩展属性JSON").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
- DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End()
-
- tb.AddUniqueIndex("idx_code", "code")
- tb.AddIndex("idx_type", "type")
- tb.AddIndex("idx_parent_id", "parent_id")
- tb.AddIndex("idx_status", "status")
- tb.AddIndex("idx_level", "level")
- tb.AddIndex("idx_tax_id", "tax_id")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type MasterCompany struct {
- ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:公司ID"`
- Type string `gorm:"column:type;type:varchar(30);not null;default:SUBSIDIARY;comment:公司类型: SUPPLIER供应商/SUBSIDIARY子公司/AGENT代理商/WHOLESALER批发商/GROUP集团/FRANCHISEE加盟商/CUSTOMER客户/LOGISTICS物流商"`
- Code string `gorm:"column:code;type:varchar(50);not null;comment:公司编码"`
- Name string `gorm:"column:name;type:varchar(200);not null;comment:公司名称"`
- ShortName string `gorm:"column:short_name;type:varchar(100);comment:公司简称"`
- EnglishName string `gorm:"column:english_name;type:varchar(200);comment:英文名称"`
- ParentID string `gorm:"column:parent_id;type:varchar(50);comment:上级公司ID"`
- Level int32 `gorm:"column:level;type:int;comment:公司层级 1:集团 2:子公司 3:分公司"`
- TaxID string `gorm:"column:tax_id;type:varchar(30);comment:税号/统一社会信用代码"`
- LegalRepresentative string `gorm:"column:legal_representative;type:varchar(50);comment:法定代表人"`
- ContactPerson string `gorm:"column:contact_person;type:varchar(50);comment:联系人"`
- ContactPhone string `gorm:"column:contact_phone;type:varchar(20);comment:联系电话"`
- Email string `gorm:"column:email;type:varchar(100);comment:邮箱"`
- Address string `gorm:"column:address;type:varchar(500);comment:公司地址"`
- BankName string `gorm:"column:bank_name;type:varchar(100);comment:开户银行"`
- BankAccount string `gorm:"column:bank_account;type:varchar(50);comment:银行账号"`
- AccountHolder string `gorm:"column:account_holder;type:varchar(100);comment:账户持有人"`
- Status string `gorm:"column:status;type:varchar(20);comment:状态 ACTIVE/INACTIVE"`
- IsActive bool `gorm:"column:is_active;type:bool;comment:是否激活"`
- Remark string `gorm:"column:remark;type:text;comment:备注"`
- ExtraProperties string `gorm:"column:extra_properties;type:json;comment:扩展属性JSON"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
- }
-
- type MasterCompanyDB struct {
- ID string `db:"id" json:"id"`
- Type string `db:"type" json:"type"`
- Code string `db:"code" json:"code"`
- Name string `db:"name" json:"name"`
- ShortName string `db:"short_name" json:"shortName"`
- EnglishName string `db:"english_name" json:"englishName"`
- ParentID string `db:"parent_id" json:"parentID"`
- Level int32 `db:"level" json:"level"`
- TaxID string `db:"tax_id" json:"taxID"`
- LegalRepresentative string `db:"legal_representative" json:"legalRepresentative"`
- ContactPerson string `db:"contact_person" json:"contactPerson"`
- ContactPhone string `db:"contact_phone" json:"contactPhone"`
- Email string `db:"email" json:"email"`
- Address string `db:"address" json:"address"`
- BankName string `db:"bank_name" json:"bankName"`
- BankAccount string `db:"bank_account" json:"bankAccount"`
- AccountHolder string `db:"account_holder" json:"accountHolder"`
- Status string `db:"status" json:"status"`
- IsActive bool `db:"is_active" json:"isActive"`
- Remark string `db:"remark" json:"remark"`
- ExtraProperties string `db:"extra_properties" json:"extraProperties"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
- }
-
- func (MasterCompany) TableName() string {
- return "master_company"
- }
|