mirror of
https://github.com/alvierahman90/rabbit.git
synced 2025-02-27 21:46:35 +00:00
34 lines
658 B
Rust
34 lines
658 B
Rust
use crate::models::Series;
|
|
use serde::{ Serialize, Deserialize };
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct Category {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub series: Vec<Series>,
|
|
}
|
|
|
|
impl Category {
|
|
pub fn new(id: i32, new: NewCategory) -> Category {
|
|
Category {
|
|
id,
|
|
name: new.name,
|
|
series: new.series,
|
|
}
|
|
}
|
|
|
|
pub fn add_series(&mut self, series: Series) {
|
|
self.series.push(series);
|
|
}
|
|
}
|
|
|
|
pub struct CategoryChangeset {
|
|
pub name: Option<String>,
|
|
pub series: Option<Vec<Series>>,
|
|
}
|
|
|
|
pub struct NewCategory {
|
|
pub name: String,
|
|
pub series: Vec<Series>,
|
|
}
|