Use model's TableName() in Cols for dynamic table names

This commit is contained in:
2026-03-29 15:43:42 +02:00
parent 97e6f82737
commit f6506584d1
5 changed files with 36 additions and 40 deletions

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package dbmodel
import "git.ma-al.com/goc_marek/gormcol"
const TableNamePsAccess = "ps_access"
// PsAccess mapped from table <ps_access>
type PsAccess struct {
IDProfile int32 `gorm:"column:id_profile;primaryKey" json:"id_profile"`
IDAuthorizationRole int32 `gorm:"column:id_authorization_role;primaryKey" json:"id_authorization_role"`
}
// TableName PsAccess's table name
func (*PsAccess) TableName() string {
return TableNamePsAccess
}
var PsAccessCols = struct {
IDProfile gormcol.Field
IDAuthorizationRole gormcol.Field
}{
IDProfile: gormcol.Field{Column: "id_profile"},
IDAuthorizationRole: gormcol.Field{Column: "id_authorization_role"},
}

View File

@@ -0,0 +1,31 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package dbmodel
import "git.ma-al.com/goc_marek/gormcol"
const TableNamePsModuleShop = "ps_module_shop"
// PsModuleShop mapped from table <ps_module_shop>
type PsModuleShop struct {
IDModule int32 `gorm:"column:id_module;primaryKey" json:"id_module"`
IDShop int32 `gorm:"column:id_shop;primaryKey;index:id_shop,priority:1" json:"id_shop"`
EnableDevice bool `gorm:"column:enable_device;not null;default:7" json:"enable_device"`
}
// TableName PsModuleShop's table name
func (*PsModuleShop) TableName() string {
return TableNamePsModuleShop
}
var PsModuleShopCols = struct {
IDModule gormcol.Field
IDShop gormcol.Field
EnableDevice gormcol.Field
}{
IDModule: gormcol.Field{Table: (PsModuleShop{}).TableName(), Column: "id_module"},
IDShop: gormcol.Field{Table: (PsModuleShop{}).TableName(), Column: "id_shop"},
EnableDevice: gormcol.Field{Table: (PsModuleShop{}).TableName(), Column: "enable_device"},
}