backend: working license controller
This commit is contained in:
parent
e3a3c5bc78
commit
cb9d3464e3
13 changed files with 252 additions and 2 deletions
|
@ -5,4 +5,5 @@ edition = "2021"
|
|||
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "*", features = ["derive"] }
|
||||
sea-orm = { version = "0.12" }
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod license;
|
||||
pub mod license_group;
|
||||
pub mod user;
|
||||
|
|
38
crates/entity/src/license.rs
Normal file
38
crates/entity/src/license.rs
Normal 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 {}
|
27
crates/entity/src/license_group.rs
Normal file
27
crates/entity/src/license_group.rs
Normal 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 {}
|
|
@ -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;
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue