// Code generated by sql2gorm. DO NOT EDIT. package repo import ( "context" "time" "github.com/samber/do" "gorm.io/gorm" ) func init(){ do.Provide[UserOrganizationRepo](nil,NewUserOrganizationRepo) } // 用户组织表 type UserOrganization struct { ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id UserID uint `gorm:"column:user_id;NOT NULL"` // 用户id OrgID uint `gorm:"column:org_id;NOT NULL"` // 组织id Leader int `gorm:"column:leader;default:0"` // 是否是组织领导:一个组织只能有一个领导人 CreatedBy string `gorm:"column:created_by"` // 创建人 CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间 ModifiedBy string `gorm:"column:modified_by"` // 修改人 ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间 } func (m *UserOrganization) TableName() string { return "user_organization" } type UserOrganizationRepo interface{ Create(ctx context.Context,userOrgs []UserOrganization)error Delete(ctx context.Context,orgId uint,userIds []uint)error SearchOrgUser(ctx context.Context,orgId uint,query Query)([]User,error) } type userOrganizationRepo struct{ db *gorm.DB } func NewUserOrganizationRepo(i *do.Injector)(UserOrganizationRepo,error){ return &userOrganizationRepo{ db:do.MustInvoke[*gorm.DB](i), },nil } func (u *userOrganizationRepo)Create(ctx context.Context,userOrgs []UserOrganization)error{ return u.db.Create(userOrgs).Error } func (u *userOrganizationRepo)Delete(ctx context.Context,orgId uint,userIds []uint)error{ return u.db.Where("org_id = ? and user_id in ?",orgId,userIds).Delete(&UserOrganization{}).Error } func (u *userOrganizationRepo)SearchOrgUser(ctx context.Context,orgId uint,query Query)([]User,error){ return nil,nil }