package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("master_store", "店铺主数据表"). ChineseName("店铺主数据表").Aliases("店铺主数据"). ChineseName("店铺主数据表"). Aliases("店铺表", "门店表"). ID("stor_id", 50).NotNull().Comment("店铺ID").ChineseName("店铺标识").Aliases("店铺ID", "ID").End(). String("tenant_id", 50).NotNull().Comment("租户ID").ChineseName("租户标识").Aliases("租户ID").End(). String("stor_code", 50).NotNull().Comment("店铺编码").ChineseName("店铺编码").Aliases("编码", "店编码").End(). String("stor_name", 200).NotNull().Comment("店铺名称").ChineseName("店铺名称").Aliases("名称", "店名").End(). String("stor_short_name", 100).Comment("店铺简称").ChineseName("店铺简称").Aliases("店简称").End(). String("company_id", 50).NotNull().Comment("所属公司ID").ChineseName("公司标识").Aliases("公司ID").End(). String("store_ownership_type", 20).NotNull().Default("'DIRECT'").Comment("店铺所有权类型 DIRECT:直营 FRANCHISE:加盟").ChineseName("所有权类型").Aliases("经营类型", "所有类型").End(). BigInt("business_model_id").Comment("经营模式ID(关联master_store_dimension表,type='business_model')").ChineseName("经营模式标识").Aliases("模式ID", "经营模式ID").End(). BigInt("store_tier_id").Comment("店铺定位ID(关联master_store_dimension表,type='store_tier')").ChineseName("店铺定位标识").Aliases("定位ID", "店铺定位ID").End(). BigInt("retail_format_id").Comment("零售业态ID(关联master_store_dimension表,type='retail_format')").ChineseName("零售业态标识").Aliases("业态ID", "零售业态ID").End(). BigInt("market_tier_id").Comment("市场层级ID(关联master_store_dimension表,type='market_tier')").ChineseName("市场层级标识").Aliases("层级ID", "市场层级ID").End(). BigInt("sales_channel_id").Comment("销售渠道ID(关联master_store_dimension表,type='sales_channel')").ChineseName("销售渠道标识").Aliases("渠道ID", "销售渠道ID").End(). BigInt("region_id").Comment("区域ID(关联master_store_dimension表,type='region')").ChineseName("区域标识").Aliases("区域ID").End(). String("province", 100).Comment("省份").ChineseName("省份").End(). String("city", 100).Comment("城市").ChineseName("城市").End(). String("address", 100).Comment("详细地址").ChineseName("详细地址").End(). String("mall_code", 100).Comment("商场/商圈编码").ChineseName("商场编码").Aliases("商圈编码", "商场代码").End(). String("mall_name", 100).Comment("商场/商圈名称").ChineseName("商场名称").Aliases("商圈名称", "商场名").End(). Decimal("store_area", 12, 2).Comment("店铺面积(平方米)").ChineseName("店铺面积").End(). Date("opening_date").Comment("开业日期").ChineseName("开业日期").Aliases("开业时间").End(). String("manager_name", 100).Comment("店长姓名").ChineseName("店长姓名").Aliases("店长", "负责人").End(). String("contact_phone", 100).Comment("联系电话").ChineseName("联系电话").End(). Int("employee_count").Comment("员工人数").ChineseName("员工人数").Aliases("人数", "员工数").End(). Int("inventory_capacity").Comment("库存容量(件数或SKU数)").ChineseName("库存容量").Aliases("容量", "库存量").End(). String("stor_status", 100).Comment("店铺状态 (1营业中/2装修中/3停业/4关闭)").ChineseName("店铺状态").Aliases("营业状态").End(). Bool("is_active").Comment("是否激活").ChineseName("是否激活").Aliases("激活状态", "有效状态").End(). Text("remark").Comment("备注").ChineseName("备注").Aliases("说明", "注释").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").ChineseName("创建时间").Aliases("创建时间戳").End(). DateTime("updated_at").Comment("更新时间").ChineseName("更新时间").Aliases("更新时间戳").End(). Date("data_date").Comment("数据日期 (数据仓库快照)").ChineseName("数据日期").Aliases("快照日期").End() tb.AddUniqueIndex("idx_stor_code", "stor_code") tb.AddIndex("idx_tenant_id", "tenant_id") tb.AddIndex("idx_business_model_id", "business_model_id") tb.AddIndex("idx_store_tier_id", "store_tier_id") tb.AddIndex("idx_retail_format_id", "retail_format_id") tb.AddIndex("idx_market_tier_id", "market_tier_id") tb.AddIndex("idx_sales_channel_id", "sales_channel_id") tb.AddIndex("idx_region_id", "region_id") tb.AddIndex("idx_stor_status", "stor_status") tb.AddIndex("idx_business_region_status", "business_model_id", "region_id", "stor_status") tb.AddIndex("idx_company_id", "company_id") tb.AddIndex("idx_store_ownership_type", "store_ownership_type") r.RegisterTable(tb.Build()) }) } type MasterStore struct { StorID string `gorm:"column:stor_id;type:varchar(50);not null;primaryKey;comment:店铺ID"` TenantID string `gorm:"column:tenant_id;type:varchar(50);not null;comment:租户ID"` StorCode string `gorm:"column:stor_code;type:varchar(50);not null;comment:店铺编码"` StorName string `gorm:"column:stor_name;type:varchar(200);not null;comment:店铺名称"` StorShortName string `gorm:"column:stor_short_name;type:varchar(100);comment:店铺简称"` CompanyID string `gorm:"column:company_id;type:varchar(50);not null;comment:所属公司ID"` StoreOwnershipType string `gorm:"column:store_ownership_type;type:varchar(20);not null;default:DIRECT;comment:店铺所有权类型 DIRECT:直营 FRANCHISE:加盟"` BusinessModelID int64 `gorm:"column:business_model_id;type:bigint;comment:经营模式ID"` StoreTierID int64 `gorm:"column:store_tier_id;type:bigint;comment:店铺定位ID"` RetailFormatID int64 `gorm:"column:retail_format_id;type:bigint;comment:零售业态ID"` MarketTierID int64 `gorm:"column:market_tier_id;type:bigint;comment:市场层级ID"` SalesChannelID int64 `gorm:"column:sales_channel_id;type:bigint;comment:销售渠道ID"` RegionID int64 `gorm:"column:region_id;type:bigint;comment:区域ID"` Province string `gorm:"column:province;type:varchar(50);comment:省份"` City string `gorm:"column:city;type:varchar(50);comment:城市"` Address string `gorm:"column:address;type:varchar(500);comment:详细地址"` MallCode string `gorm:"column:mall_code;type:varchar(50);comment:商场/商圈编码"` MallName string `gorm:"column:mall_name;type:varchar(200);comment:商场/商圈名称"` StoreArea float64 `gorm:"column:store_area;type:decimal(10,2);comment:店铺面积(平方米)"` OpeningDate *time.Time `gorm:"column:opening_date;type:date;comment:开业日期"` ManagerName string `gorm:"column:manager_name;type:varchar(50);comment:店长姓名"` ContactPhone string `gorm:"column:contact_phone;type:varchar(20);comment:联系电话"` EmployeeCount int32 `gorm:"column:employee_count;type:int;comment:员工人数"` InventoryCapacity int32 `gorm:"column:inventory_capacity;type:int;comment:库存容量(件数或SKU数)"` StorStatus string `gorm:"column:stor_status;type:varchar(20);comment:店铺状态 (1营业中/2装修中/3停业/4关闭)"` IsActive bool `gorm:"column:is_active;type:bool;comment:是否激活"` Remark string `gorm:"column:remark;type:text;comment:备注"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` UpdatedAt *time.Time `gorm:"column:updated_at;comment:更新时间"` DataDate *time.Time `gorm:"column:data_date;type:date;comment:数据日期 (数据仓库快照)"` } type MasterStoreDB struct { StorID string `db:"stor_id" json:"storID"` TenantID string `db:"tenant_id" json:"tenantID"` StorCode string `db:"stor_code" json:"storCode"` StorName string `db:"stor_name" json:"storName"` StorShortName string `db:"stor_short_name" json:"storShortName"` CompanyID string `db:"company_id" json:"companyID"` StoreOwnershipType string `db:"store_ownership_type" json:"storeOwnershipType"` BusinessModelID int64 `db:"business_model_id" json:"businessModelID"` StoreTierID int64 `db:"store_tier_id" json:"storeTierID"` RetailFormatID int64 `db:"retail_format_id" json:"retailFormatID"` MarketTierID int64 `db:"market_tier_id" json:"marketTierID"` SalesChannelID int64 `db:"sales_channel_id" json:"salesChannelID"` RegionID int64 `db:"region_id" json:"regionID"` Province string `db:"province" json:"province"` City string `db:"city" json:"city"` Address string `db:"address" json:"address"` MallCode string `db:"mall_code" json:"mallCode"` MallName string `db:"mall_name" json:"mallName"` StoreArea float64 `db:"store_area" json:"storeArea"` OpeningDate *time.Time `db:"opening_date" json:"openingDate"` ManagerName string `db:"manager_name" json:"managerName"` ContactPhone string `db:"contact_phone" json:"contactPhone"` EmployeeCount int32 `db:"employee_count" json:"employeeCount"` InventoryCapacity int32 `db:"inventory_capacity" json:"inventoryCapacity"` StorStatus string `db:"stor_status" json:"storStatus"` IsActive bool `db:"is_active" json:"isActive"` Remark string `db:"remark" json:"remark"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt *time.Time `db:"updated_at" json:"updatedAt"` DataDate *time.Time `db:"data_date" json:"dataDate"` } func (MasterStore) TableName() string { return "master_store" }