Implement most of clans functionality; close #89

This commit is contained in:
NG (Graham) committed 2026-02-22 22:39:34 -05:00
1 parent e120b945c8
commit f0cca11d3c
43 files changed
+2605 -26

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "clans")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub creation_time: i64, // seconds since unix epoch
pub name: String,
pub description: String,
pub variant: ClanType,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::clan_member::Entity")]
ClanMember,
}
impl Related<super::clan_member::Entity> for Entity {
fn to() -> RelationDef {
Relation::ClanMember.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum ClanType {
Public,
Private,
Banned,
Abandoned,
}
+59
View File
@@ -0,0 +1,59 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "clan_members")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub creation_time: i64, // seconds since unix epoch
pub user_id: i32,
pub clan_id: i32,
pub rank: ClanMemberRank,
pub status: ClanMemberStatus,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id"
)]
User,
#[sea_orm(
belongs_to = "super::clan::Entity",
from = "Column::ClanId",
to = "super::clan::Column::Id"
)]
Clan,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::clan::Entity> for Entity {
fn to() -> RelationDef {
Relation::Clan.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum ClanMemberRank {
Member,
Officer,
Leader,
}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum ClanMemberStatus {
Invited,
Confirmed,
Deactivated,
}
+2
View File
@@ -13,6 +13,8 @@ pub mod multiplayer_game_score;
#[cfg(feature = "factory")]
pub mod factory;
pub mod friend;
pub mod clan;
pub mod clan_member;
pub fn parse_int_csv(s: &str) -> Vec<u32> {
s.split(',').filter_map(|i_as_s| {