Add keywords to transactions table
Keywords are now saved to the merchandise_list form_list when selling to the shop.
This commit is contained in:
parent
80345c3a6f
commit
a64caa4081
@ -49,6 +49,7 @@ CREATE TABLE "transactions" (
|
||||
"is_sell" BOOLEAN NOT NULL,
|
||||
"quantity" INTEGER NOT NULL,
|
||||
"amount" INTEGER NOT NULL,
|
||||
"keywords" TEXT[] NOT NULL DEFAULT '{}',
|
||||
"created_at" timestamp(3) NOT NULL,
|
||||
"updated_at" timestamp(3) NOT NULL
|
||||
);
|
||||
|
@ -142,6 +142,7 @@ pub async fn create(
|
||||
saved_transaction.is_food,
|
||||
saved_transaction.price,
|
||||
quantity_delta,
|
||||
&saved_transaction.keywords,
|
||||
)
|
||||
.await
|
||||
.map_err(reject_anyhow)?;
|
||||
|
@ -240,6 +240,7 @@ impl MerchandiseList {
|
||||
is_food: bool,
|
||||
price: i32,
|
||||
quantity_delta: i32,
|
||||
keywords: &[String],
|
||||
) -> Result<Self> {
|
||||
let add_item = json!([{
|
||||
"mod_name": mod_name,
|
||||
@ -249,6 +250,7 @@ impl MerchandiseList {
|
||||
"form_type": form_type,
|
||||
"is_food": is_food,
|
||||
"price": price,
|
||||
"keywords": keywords,
|
||||
}]);
|
||||
Ok(sqlx::query_as!(
|
||||
Self,
|
||||
|
@ -22,6 +22,7 @@ pub struct Transaction {
|
||||
pub is_sell: bool,
|
||||
pub quantity: i32,
|
||||
pub amount: i32,
|
||||
pub keywords: Vec<String>,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
}
|
||||
@ -39,6 +40,7 @@ pub struct PostedTransaction {
|
||||
pub is_sell: bool,
|
||||
pub quantity: i32,
|
||||
pub amount: i32,
|
||||
pub keywords: Vec<String>,
|
||||
}
|
||||
|
||||
impl Transaction {
|
||||
@ -71,8 +73,8 @@ impl Transaction {
|
||||
Self,
|
||||
"INSERT INTO transactions
|
||||
(shop_id, owner_id, mod_name, local_form_id, name, form_type, is_food, price,
|
||||
is_sell, quantity, amount, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, now(), now())
|
||||
is_sell, quantity, amount, keywords, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, now(), now())
|
||||
RETURNING *",
|
||||
transaction.shop_id,
|
||||
transaction.owner_id,
|
||||
@ -85,6 +87,7 @@ impl Transaction {
|
||||
transaction.is_sell,
|
||||
transaction.quantity,
|
||||
transaction.amount,
|
||||
&transaction.keywords,
|
||||
)
|
||||
.fetch_one(db)
|
||||
.await?)
|
||||
|
@ -9,7 +9,8 @@
|
||||
"quantity": 1,
|
||||
"form_type": 32,
|
||||
"is_food": false,
|
||||
"price": 1
|
||||
"price": 1,
|
||||
"keywords": ["VendorItemMisc"]
|
||||
},
|
||||
{
|
||||
"mod_name": "Skyrim.esm",
|
||||
@ -18,7 +19,8 @@
|
||||
"quantity": 2,
|
||||
"form_type": 23,
|
||||
"is_food": false,
|
||||
"price": 2
|
||||
"price": 2,
|
||||
"keywords": ["VendorItemScroll"]
|
||||
},
|
||||
{
|
||||
"mod_name": "Skyrim.esm",
|
||||
@ -27,7 +29,8 @@
|
||||
"quantity": 3,
|
||||
"form_type": 46,
|
||||
"is_food": true,
|
||||
"price": 3
|
||||
"price": 3,
|
||||
"keywords": ["VendorItemIngredient"]
|
||||
},
|
||||
{
|
||||
"mod_name": "Skyrim.esm",
|
||||
@ -36,7 +39,8 @@
|
||||
"quantity": 4,
|
||||
"form_type": 41,
|
||||
"is_food": false,
|
||||
"price": 4
|
||||
"price": 4,
|
||||
"keywords": ["VendorItemWeapon"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"price": 100,
|
||||
"is_sell": false,
|
||||
"quantity": 1,
|
||||
"amount": 100
|
||||
"amount": 100,
|
||||
"keywords": ["VendorItemMisc"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user