write id_card test

This commit is contained in:
2025-08-15 10:50:54 +08:00
parent e0492e1d74
commit 02f1d7f850
8 changed files with 127 additions and 4 deletions

13
packages/model/Cargo.toml Normal file
View File

@@ -0,0 +1,13 @@
[package]
name = "model"
version = "0.1.0"
edition = "2024"
[lib]
name = "model"
path = "lib/mod.rs"
[dependencies]
serde.workspace = true
sea-orm.workspace = true
chrono.workspace = true

View File

@@ -0,0 +1,31 @@
use sea_orm::entity::prelude::*;
use sea_orm::{ActiveModelBehavior, DeriveActiveEnum, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EnumIter};
use serde::{Deserialize, Serialize};
#[derive(DeriveEntityModel, Clone, Debug, PartialEq, Serialize, Deserialize)]
#[sea_orm(table_name = "id_card")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: String,
pub name: String,
pub gender: Gender,
pub birth: String,
pub address: Option<String>,
pub nation: String,
pub create_at: DateTime,
}
pub type IDCardModel = Model;
#[derive(Debug, DeriveRelation, EnumIter)]
pub enum Relation {}
#[derive(Serialize, Deserialize, Debug, Clone, EnumIter, PartialEq, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "gender")]
pub enum Gender {
#[sea_orm(string_value = "female")]
Female,
#[sea_orm(string_value = "male")]
Male,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1 @@
pub mod id_card;