Added settings override fields to article.
This commit is contained in:
@@ -17,6 +17,10 @@ pub struct Article {
|
||||
pub ingredients: Option<String>,
|
||||
pub default_unit: Unit,
|
||||
pub variants: Vec<Variant>,
|
||||
pub mhd: Option<String>,
|
||||
pub bio_origin: Option<String>,
|
||||
pub allergens_text: Option<String>,
|
||||
pub bio_info: Option<String>,
|
||||
}
|
||||
|
||||
fn from_postgres_row_small(row: PgRow) -> Article {
|
||||
@@ -29,6 +33,10 @@ fn from_postgres_row_small(row: PgRow) -> Article {
|
||||
ingredients: row.get(5),
|
||||
default_unit: row.get(6),
|
||||
variants: vec![],
|
||||
mhd: row.get(7),
|
||||
bio_origin: row.get(8),
|
||||
allergens_text: row.get(9),
|
||||
bio_info: row.get(10),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +63,10 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article {
|
||||
ingredients: row.get(5),
|
||||
default_unit: row.get(6),
|
||||
variants: variants,
|
||||
mhd: row.get(7),
|
||||
bio_origin: row.get(8),
|
||||
allergens_text: row.get(9),
|
||||
bio_info: row.get(10),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +133,13 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
|
||||
args.add(&article.description);
|
||||
args.add(&article.ingredients);
|
||||
args.add(&article.default_unit);
|
||||
args.add(&article.mhd);
|
||||
args.add(&article.bio_origin);
|
||||
args.add(&article.allergens_text);
|
||||
args.add(&article.bio_info);
|
||||
|
||||
let statement = format!(
|
||||
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id) VALUES ($1, $2, $3, $4, $5, $6) RETURNING *",
|
||||
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *",
|
||||
"article",
|
||||
);
|
||||
|
||||
@@ -156,9 +172,13 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
|
||||
args.add(&article.description);
|
||||
args.add(&article.ingredients);
|
||||
args.add(&article.default_unit);
|
||||
args.add(&article.mhd);
|
||||
args.add(&article.bio_origin);
|
||||
args.add(&article.allergens_text);
|
||||
args.add(&article.bio_info);
|
||||
|
||||
let statement = format!(
|
||||
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7 WHERE id = $1 RETURNING *",
|
||||
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11 WHERE id = $1 RETURNING *",
|
||||
"article",
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user