Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use gen not generation this relation #7383

Open
pdxrlj opened this issue Mar 7, 2025 · 2 comments
Open

use gen not generation this relation #7383

pdxrlj opened this issue Mar 7, 2025 · 2 comments
Assignees
Labels

Comments

@pdxrlj
Copy link

pdxrlj commented Mar 7, 2025

type Admin struct {
	ID       int         `gorm:"column:id;primaryKey;autoIncrement"`
	Username string      `gorm:"column:username;type:varchar(255);not null;unique"`
	Password string      `gorm:"column:password;type:varchar(255);not null"`
	Email    string      `gorm:"column:email;type:varchar(255);unique"`
	Phone    string      `gorm:"column:phone;type:varchar(255);unique"`
	Status   AdminStatus `gorm:"column:status;type:varchar(255);default:active"`
	Avatar   string      `gorm:"column:avatar;type:varchar(255);"`

	AdminRoles []*AdminRoles `gorm:"many2many:admin_association_roles;joinForeignKey:AdminID;joinReferences:RoleID;foreignKey:ID;references:ID"`

	// 组织关系
	Organizations []*OrganizationalManagement `gorm:"many2many:admin_association_organizations;joinForeignKey:AdminID;joinReferences:OrganizationID;foreignKey:ID;references:ID"`

	CreatedAt time.Time `gorm:"column:created_at;not null;default:now()"`
	UpdatedAt time.Time `gorm:"column:updated_at;not null;default:now()"`
}
type OrganizationalManagement struct {
	ID int `gorm:"column:id;primaryKey;autoIncrement"`
	// 组织名称
	OrganizationName string `gorm:"column:organization_name;comment:组织名称;type:varchar(255);"`
	// 组织编码
	OrganizationCode string `gorm:"column:organization_code;comment:组织编码;type:varchar(255);"`
	// 组织描述
	OrganizationDescription string `gorm:"column:organization_description;comment:组织描述;type:varchar(255);"`
	// 组织状态
	OrganizationStatus string `gorm:"column:organization_status;comment:组织状态 active=正常 inactive=禁用;type:varchar(255);default:active"`

	// 组织管理员
	OrganizationAdminID int `gorm:"column:organization_admin_id;comment:组织管理员ID;type:int;default:0"`

	// 组织管理员
	OrganizationAdmins []*Admin `gorm:"many2many:admin_association_organizations;joinForeignKey:OrganizationID;joinReferences:AdminID;foreignKey:ID;references:ID"`

	CreatedAt time.Time `gorm:"column:created_at;not null;default:now()"`
	UpdatedAt time.Time `gorm:"column:updated_at;not null;default:now()"`
}

why not found this relation

Image

Description

not generate this relation

@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Mar 7, 2025
Copy link

github-actions bot commented Mar 7, 2025

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

Copy link

github-actions bot commented Mar 7, 2025

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants