This commit is contained in:
2026-03-14 19:45:08 -03:00
parent 9ac83ad823
commit 74adc35b53
23 changed files with 1082 additions and 150 deletions
@@ -46,6 +46,9 @@ pub struct LabelQuery {
pub width_mm: u32,
#[serde(default = "default_height_mm")]
pub height_mm: u32,
/// Campos a incluir, separados por vírgula: color,name,material_brand,net_weight,print_temp,qrcode
/// Se ausente, inclui todos.
pub fields: Option<String>,
}
fn default_width_mm() -> u32 { 50 }
@@ -286,6 +289,30 @@ pub async fn get_qrcode_handler(
))
}
pub async fn export_label_pdf_handler(
State(state): State<AppState>,
Extension(user): Extension<CurrentUser>,
Path(id): Path<Uuid>,
Query(query): Query<LabelQuery>,
) -> Result<impl IntoResponse, AppError> {
let pdf = state
.filament_service
.generate_label_pdf(id, user.id, query.width_mm, query.height_mm, query.fields.as_deref())
.await?;
let filename = format!("meowspool-label-{id}.pdf");
Ok((
[
(header::CONTENT_TYPE, "application/pdf".to_string()),
(
header::CONTENT_DISPOSITION,
format!("attachment; filename=\"{filename}\""),
),
],
pdf,
))
}
pub async fn export_label_handler(
State(state): State<AppState>,
Extension(user): Extension<CurrentUser>,
@@ -294,7 +321,7 @@ pub async fn export_label_handler(
) -> Result<impl IntoResponse, AppError> {
let svg = state
.filament_service
.generate_label_svg(id, user.id, query.width_mm, query.height_mm)
.generate_label_svg(id, user.id, query.width_mm, query.height_mm, query.fields.as_deref())
.await?;
let filename = format!("meowspool-label-{id}.svg");