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