use sea_orm::entity::prelude::*; #[derive(Copy, Clone, Default, Debug, DeriveEntity)] pub struct Entity; impl EntityName for Entity { fn table_name(&self) -> &str { "group_permission" } } #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)] pub struct Model { pub group_id: i32, pub permission_id: i32, } #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] pub enum Column { GroupId, PermissionId, } #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] pub enum PrimaryKey { GroupId, PermissionId, } impl PrimaryKeyTrait for PrimaryKey { type ValueType = (i32, i32); fn auto_increment() -> bool { false } } impl ColumnTrait for Column { type EntityName = Entity; fn def(&self) -> ColumnDef { match self { Self::GroupId => ColumnType::Integer.def(), Self::PermissionId => ColumnType::Integer.def(), } } } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm( belongs_to = "super::group::Entity", from = "Column::GroupId", to = "super::group::Column::Id" )] Group, #[sea_orm( belongs_to = "super::permission::Entity", from = "Column::PermissionId", to = "super::permission::Column::Id" )] Permission, } impl ActiveModelBehavior for ActiveModel {}