package repository import ( "context" "database/sql" "fmt" "github.com/muyuqingfeng/iloom/washing-service/internal/model" ) type CompletionRepo struct { db *sql.DB } func NewCompletionRepo(db *sql.DB) *CompletionRepo { return &CompletionRepo{db: db} } func (r *CompletionRepo) Create(ctx context.Context, tx *sql.Tx, c *model.WashingPlanCompletion) error { query := `INSERT INTO ilm_washing_completion (id, washing_plan_id, company_id, actual_shrinkage_rate, actual_washed_meters, actual_washing_cost, unit_cost, rolls, washing_date, notes, completed_by, completed_at, finished_product_id, auto_imported, warehouse_id, warehouse_location, created_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)` _, err := tx.ExecContext(ctx, query, c.ID, c.WashingPlanID, c.CompanyID, c.ActualShrinkageRate, c.ActualWashedMeters, c.ActualWashingCost, c.UnitCost, c.Rolls, c.WashingDate, c.Notes, c.CompletedBy, c.CompletedAt, c.FinishedProductID, c.AutoImported, c.WarehouseID, c.WarehouseLocation, c.CreatedAt, ) if err != nil { return fmt.Errorf("insert completion: %w", err) } return nil }