refactor: serve static frontend with Go APIs

This commit is contained in:
brother7 committed 2026-08-16 20:47:45 +08:00
1 parent 763d2f0648
commit b14b4fced7
101 files changed
+963 -3928

No files matched your search

+18 -1
View File
@@ -74,9 +74,26 @@ func TestBillingAdminRoutesRequireSuperAdminAndValidateWrites(t *testing.T) {
if got := serveJSON(t, super, http.MethodPatch, "/api/admin/billing/account", map[string]any{"accountName": " Acme ", "bankName": " Bank ", "accountNumber": " 123 ", "contact": " Ops "}); got.Code != 200 || account.saved.AccountName != "Acme" {
t.Fatalf("account status=%d saved=%+v body=%s", got.Code, account.saved, got.Body.String())
}
if got := serveJSON(t, super, http.MethodPost, "/api/admin/billing/adjustments", map[string]any{"organizationId": "org", "amountYuan": 1.235, "direction": "debit", "note": " correction "}); got.Code != 200 || service.adjustment.AmountFen != 124 || service.adjustment.DeltaFen != -124 || service.adjustment.OperatorID != "root" {
got := serveJSON(t, super, http.MethodPost, "/api/admin/billing/adjustments", map[string]any{"organizationId": "org", "amountYuan": 1.235, "direction": "debit", "note": " correction "})
if got.Code != 200 || service.adjustment.AmountFen != 124 || service.adjustment.DeltaFen != -124 || service.adjustment.OperatorID != "root" {
t.Fatalf("adjustment status=%d got=%+v body=%s", got.Code, service.adjustment, got.Body.String())
}
var adjustmentResponse map[string]json.RawMessage
if err := json.Unmarshal(got.Body.Bytes(), &adjustmentResponse); err != nil {
t.Fatalf("decode adjustment response: %v", err)
}
if _, ok := adjustmentResponse["wallet"]; !ok {
t.Fatalf("adjustment response missing lowercase wallet: %s", got.Body.String())
}
if _, ok := adjustmentResponse["entry"]; !ok {
t.Fatalf("adjustment response missing lowercase entry: %s", got.Body.String())
}
if _, ok := adjustmentResponse["Wallet"]; ok {
t.Fatalf("adjustment response contains uppercase Wallet: %s", got.Body.String())
}
if _, ok := adjustmentResponse["Entry"]; ok {
t.Fatalf("adjustment response contains uppercase Entry: %s", got.Body.String())
}
if got := serveJSON(t, super, http.MethodPatch, "/api/admin/billing/prices/price-1", map[string]any{"standardUnitPriceFen": 1, "markupMultiplier": 2}); got.Code != 400 {
t.Fatalf("whitelist status=%d", got.Code)
}