mirror of
https://github.com/zzzzDev4/ias-tea-axum.git
synced 2025-04-21 07:41:21 +02:00
general improvements and bugfixes, endpoints tested and working
This commit is contained in:
parent
2c60c6c4dc
commit
30dc7571ca
4 changed files with 8 additions and 13 deletions
|
@ -1,9 +1,9 @@
|
|||
CREATE TABLE IF NOT EXISTS tea (
|
||||
id serial PRIMARY KEY,
|
||||
tea_name VARCHAR(128) NOT NULL,
|
||||
tea_name VARCHAR(128) NOT NULL DEFAULT 'Unnamed Tea',
|
||||
rfid_code VARCHAR(128) NOT NULL,
|
||||
tea_notes VARCHAR(512),
|
||||
water_temp INT,
|
||||
tea_notes VARCHAR(512) NOT NULL DEFAULT '',
|
||||
water_temp INT NOT NULL DEFAULT -1,
|
||||
steeping_seconds INT NOT NULL,
|
||||
registration_timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
|
|
@ -22,9 +22,7 @@ pub struct TeaSteepingTimeChange {
|
|||
|
||||
#[derive(Deserialize)]
|
||||
pub struct TeaNew {
|
||||
pub tea_name: String,
|
||||
pub rfid_code: String,
|
||||
pub water_temp: i32,
|
||||
pub steeping_seconds: i32,
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ pub async fn delete_tea_by_id(
|
|||
match sqlx::query_as::<_, Tea>(
|
||||
"
|
||||
DELETE FROM tea WHERE id = $1
|
||||
RETURNING id, teaname, rfidcode, tea_notes, water_temp, steeping_seconds, registration_timestamp
|
||||
RETURNING id, tea_name, rfid_code, tea_notes, water_temp, steeping_seconds, registration_timestamp
|
||||
",
|
||||
)
|
||||
.bind(id)
|
||||
|
|
|
@ -27,7 +27,6 @@ pub async fn update_config(
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: should be used by web-interface to update metadata
|
||||
pub async fn update_tea_meta_by_id(
|
||||
State(state): State<MyState>,
|
||||
Path(id): Path<i32>,
|
||||
|
@ -63,7 +62,7 @@ pub async fn update_tea_steeping_time_by_id(
|
|||
"
|
||||
UPDATE tea SET steeping_seconds = $1
|
||||
WHERE id = $2
|
||||
RETURNING id, tea_name, rfid_code, water_temp, steeping_seconds
|
||||
RETURNING id, tea_name, rfid_code, tea_notes, water_temp, steeping_seconds, registration_timestamp
|
||||
",
|
||||
)
|
||||
.bind(steeping_time_change.new_steeping_seconds)
|
||||
|
@ -99,14 +98,12 @@ pub async fn add_tea(
|
|||
) -> Result<impl IntoResponse, impl IntoResponse> {
|
||||
match sqlx::query_as::<_, Tea>(
|
||||
"
|
||||
INSERT INTO tea (tea_name, rfid_code, water_temp, steeping_seconds)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, tea_name, rfid_code, water_temp, steeping_seconds
|
||||
INSERT INTO tea (rfid_code, steeping_seconds)
|
||||
VALUES ($1, $2)
|
||||
RETURNING id, tea_name, rfid_code, tea_notes, water_temp, steeping_seconds, registration_timestamp
|
||||
",
|
||||
)
|
||||
.bind(&tea_new.tea_name)
|
||||
.bind(&tea_new.rfid_code)
|
||||
.bind(tea_new.water_temp)
|
||||
.bind(tea_new.steeping_seconds)
|
||||
.fetch_one(&state.pool)
|
||||
.await
|
||||
|
|
Loading…
Add table
Reference in a new issue