You've already forked AstralRinth
forked from didirus/AstralRinth
Mod Creation (#34)
* Inital creation stuff * File Reader * Upload bodies * Major rework: * Finish Multiple Files * Proper Error Handling * Switch to database models * Run formatter * Make dependencies dependent on Versions over mods * Fixes * Fix clippy * Run lint one last time * Update src/models/mods.rs Co-authored-by: AppleTheGolden <scotsbox@protonmail.com> Co-authored-by: AppleTheGolden <scotsbox@protonmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
mod mod_item;
|
||||
mod team_item;
|
||||
mod version_item;
|
||||
|
||||
use crate::database::DatabaseError::NotFound;
|
||||
@@ -8,7 +9,11 @@ use bson::doc;
|
||||
use bson::Document;
|
||||
pub use mod_item::Mod;
|
||||
use mongodb::Database;
|
||||
pub use team_item::Team;
|
||||
pub use team_item::TeamMember;
|
||||
pub use version_item::FileHash;
|
||||
pub use version_item::Version;
|
||||
pub use version_item::VersionFile;
|
||||
|
||||
#[async_trait]
|
||||
pub trait Item {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::database::models::team_item::Team;
|
||||
use crate::database::models::Item;
|
||||
use crate::database::Result;
|
||||
use bson::{Bson, Document};
|
||||
@@ -5,15 +6,23 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Mod {
|
||||
/// The ID for the mod, must be serializable to base62
|
||||
pub id: i32,
|
||||
//Todo: Move to own table
|
||||
/// The team that owns the mod
|
||||
pub team: Team,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub body_url: String,
|
||||
pub published: String,
|
||||
pub author: String,
|
||||
pub downloads: i32,
|
||||
pub categories: Vec<String>,
|
||||
pub body_path: String,
|
||||
pub icon_path: String,
|
||||
///A vector of Version IDs specifying the mod version of a dependency
|
||||
pub version_ids: Vec<i32>,
|
||||
pub icon_url: Option<String>,
|
||||
pub issues_url: Option<String>,
|
||||
pub source_url: Option<String>,
|
||||
pub wiki_url: Option<String>,
|
||||
}
|
||||
impl Item for Mod {
|
||||
fn get_collection() -> &'static str {
|
||||
|
||||
20
src/database/models/team_item.rs
Normal file
20
src/database/models/team_item.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A team of users who control a mod
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Team {
|
||||
/// The id of the team
|
||||
pub id: i32,
|
||||
/// A list of the members of the team
|
||||
pub members: Vec<TeamMember>,
|
||||
}
|
||||
|
||||
/// A member of a team
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct TeamMember {
|
||||
/// The ID of the user associated with the member
|
||||
pub user_id: i32,
|
||||
/// The name of the user
|
||||
pub name: String,
|
||||
pub role: String,
|
||||
}
|
||||
@@ -3,19 +3,39 @@ use crate::database::Result;
|
||||
use bson::{Bson, Document};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
//TODO: Files should probably be moved to their own table
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Version {
|
||||
///The unqiue VersionId of this version
|
||||
pub version_id: i32,
|
||||
/// The ModId of the mod that this version belongs to
|
||||
pub mod_id: i32,
|
||||
pub title: String,
|
||||
pub changelog_path: String,
|
||||
pub files_path: Vec<String>,
|
||||
pub name: String,
|
||||
pub number: String,
|
||||
pub changelog_url: Option<String>,
|
||||
pub date_published: String,
|
||||
pub author: String,
|
||||
pub downloads: i32,
|
||||
pub dependencies: Vec<String>,
|
||||
pub files: Vec<VersionFile>,
|
||||
pub dependencies: Vec<i32>,
|
||||
pub game_versions: Vec<String>,
|
||||
pub loaders: Vec<String>,
|
||||
pub version_type: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct VersionFile {
|
||||
pub game_versions: Vec<String>,
|
||||
pub hashes: Vec<FileHash>,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
/// A hash of a mod's file
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct FileHash {
|
||||
pub algorithm: String,
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
impl Item for Version {
|
||||
fn get_collection() -> &'static str {
|
||||
"versions"
|
||||
|
||||
Reference in New Issue
Block a user