Add project and data model

This commit is contained in:
2024-10-30 03:52:26 +01:00
parent ea4942bda1
commit c83c0e7ec4
16 changed files with 234 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "data")]
pub struct Model {
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
#[sea_orm(primary_key)]
pub id: i32,
pub file_url: String,
pub protected: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

View File

@@ -19,4 +19,4 @@ pub struct Model {
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
pub enum Relation {}

View File

@@ -2,6 +2,8 @@
pub mod prelude;
pub mod data;
pub mod jobs;
pub mod projects;
pub mod skills;
pub mod users;

View File

@@ -1,5 +1,7 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
pub use super::data::Entity as Data;
pub use super::jobs::Entity as Jobs;
pub use super::projects::Entity as Projects;
pub use super::skills::Entity as Skills;
pub use super::users::Entity as Users;

View File

@@ -0,0 +1,24 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "projects")]
pub struct Model {
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
#[sea_orm(primary_key)]
pub id: i32,
pub name: String,
pub technology: String,
pub short_description: String,
pub description: Option<String>,
pub category: String,
pub github_url: Option<String>,
pub download_url: Option<String>,
pub visit_url: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

7
src/models/data.rs Normal file
View File

@@ -0,0 +1,7 @@
use sea_orm::entity::prelude::*;
use super::_entities::data::{ActiveModel, Entity};
pub type Data = Entity;
impl ActiveModelBehavior for ActiveModel {
// extend activemodel below (keep comment for generators)
}

View File

@@ -2,3 +2,5 @@ pub mod _entities;
pub mod users;
pub mod skills;
pub mod jobs;
pub mod projects;
pub mod data;

21
src/models/projects.rs Normal file
View File

@@ -0,0 +1,21 @@
use super::_entities::projects::{ActiveModel, Entity};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
pub type Projects = Entity;
impl ActiveModelBehavior for ActiveModel {
// extend activemodel below (keep comment for generators)
}
#[derive(Clone, Debug, Serialize, Deserialize)]
struct ProjectWithTechnologies {
pub id: i32,
pub name: String,
pub technologies: Vec<String>,
pub short_description: String,
pub description: Option<String>,
pub category: String,
pub github_url: Option<String>,
pub download_url: Option<String>,
pub visit_url: Option<String>,
}

View File

@@ -1,7 +1,7 @@
use loco_rs::prelude::*;
use crate::models::{
_entities::jobs::{ActiveModel, Entity, Model},
_entities::jobs::{Entity, Model},
jobs::{get_technologies_from_string, JobWithTechnologies},
};

View File

@@ -1,6 +1,6 @@
use loco_rs::prelude::*;
use crate::models::_entities::skills::{ActiveModel, Entity, Model};
use crate::models::_entities::skills::{Entity, Model};
pub async fn get_all_skills(ctx: &AppContext) -> Result<Vec<Model>> {
let skills = Entity::find().all(&ctx.db).await?;