add: products api
This commit is contained in:
parent
3c4ce1fae5
commit
df5eaf24f7
29 changed files with 1022 additions and 110 deletions
|
@ -4,16 +4,17 @@ pub mod auth;
|
|||
pub mod channels;
|
||||
pub mod communities;
|
||||
pub mod domains;
|
||||
pub mod economy;
|
||||
pub mod journals;
|
||||
pub mod letters;
|
||||
pub mod notes;
|
||||
pub mod notifications;
|
||||
pub mod products;
|
||||
pub mod reactions;
|
||||
pub mod reports;
|
||||
pub mod requests;
|
||||
pub mod services;
|
||||
pub mod stacks;
|
||||
pub mod transfers;
|
||||
pub mod uploads;
|
||||
pub mod util;
|
||||
|
||||
|
@ -30,6 +31,7 @@ use tetratto_core::model::{
|
|||
PollOption, PostContext,
|
||||
},
|
||||
communities_permissions::CommunityPermission,
|
||||
economy::ProductFulfillmentMethod,
|
||||
journals::JournalPrivacyPermission,
|
||||
littleweb::{DomainData, DomainTld, ServiceFsEntry},
|
||||
oauth::AppScope,
|
||||
|
@ -706,8 +708,27 @@ pub fn routes() -> Router {
|
|||
.route("/letters/{id}/read", post(letters::add_read_request))
|
||||
.route("/letters/sent", get(letters::list_sent_request))
|
||||
.route("/letters/received", get(letters::list_received_request))
|
||||
// economy
|
||||
.route("/transfers", post(economy::create_request))
|
||||
// transfers
|
||||
.route("/transfers", post(transfers::create_request))
|
||||
// products
|
||||
.route("/products", post(products::create_request))
|
||||
.route("/products/{id}", delete(products::delete_request))
|
||||
.route("/products/{id}/buy", post(products::buy_request))
|
||||
.route("/products/{id}/title", post(products::update_title_request))
|
||||
.route(
|
||||
"/products/{id}/description",
|
||||
post(products::update_description_request),
|
||||
)
|
||||
.route(
|
||||
"/products/{id}/on_sale",
|
||||
post(products::update_on_sale_request),
|
||||
)
|
||||
.route("/products/{id}/price", post(products::update_price_request))
|
||||
.route(
|
||||
"/products/{id}/method",
|
||||
post(products::update_method_request),
|
||||
)
|
||||
.route("/products/{id}/stock", post(products::update_stock_request))
|
||||
}
|
||||
|
||||
pub fn lw_routes() -> Router {
|
||||
|
@ -1214,6 +1235,8 @@ pub struct CreateLetter {
|
|||
pub subject: String,
|
||||
pub content: String,
|
||||
pub replying_to: String,
|
||||
#[serde(default)]
|
||||
pub transfer_id: usize,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -1221,3 +1244,39 @@ pub struct CreateCoinTransfer {
|
|||
pub receiver: usize,
|
||||
pub amount: i32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct CreateProduct {
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateProductTitle {
|
||||
pub title: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateProductDescription {
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateProductOnSale {
|
||||
pub on_sale: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateProductPrice {
|
||||
pub price: i32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateProductMethod {
|
||||
pub method: ProductFulfillmentMethod,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateProductStock {
|
||||
pub stock: i32,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue