backend: working license controller

This commit is contained in:
Sphereso 2024-07-09 18:50:42 +02:00
parent e3a3c5bc78
commit cb9d3464e3
13 changed files with 252 additions and 2 deletions

View file

@ -2,4 +2,6 @@
pub mod prelude;
pub mod license;
pub mod license_group;
pub mod user;

View file

@ -0,0 +1,38 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "license")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
#[serde(skip_deserializing)]
pub id: Uuid,
pub name: String,
pub start: Option<DateTime>,
pub end: Option<DateTime>,
pub amount: Option<DateTime>,
pub key: String,
pub group_id: Uuid,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::license_group::Entity",
from = "Column::GroupId",
to = "super::license_group::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
LicenseGroup,
}
impl Related<super::license_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::LicenseGroup.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -0,0 +1,27 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "license_group")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
#[serde(skip_deserializing)]
pub id: Uuid,
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::license::Entity")]
License,
}
impl Related<super::license::Entity> for Entity {
fn to() -> RelationDef {
Relation::License.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -1,3 +1,5 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
pub use super::license::Entity as License;
pub use super::license_group::Entity as LicenseGroup;
pub use super::user::Entity as User;

View file

@ -1,11 +1,13 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "user")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
#[serde(skip_deserializing)]
pub id: Uuid,
pub name: String,
#[sea_orm(unique)]