Skip to content

Commit d8d57b3

Browse files
committed
make voucher balance fixed
1 parent dcfeca3 commit d8d57b3

4 files changed

Lines changed: 3 additions & 12 deletions

File tree

server/app/user_handler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ type EmailInput struct {
6565

6666
// ApplyForVoucherInput struct for user to apply for voucher
6767
type ApplyForVoucherInput struct {
68-
Balance uint64 `json:"balance" binding:"required" validate:"min=0"`
69-
Reason string `json:"reason" binding:"required" validate:"nonzero"`
68+
Reason string `json:"reason" binding:"required" validate:"nonzero"`
7069
}
7170

7271
// AddVoucherInput struct for voucher applied by user
@@ -711,7 +710,7 @@ func (a *App) ApplyForVoucherHandler(req *http.Request) (interface{}, Response)
711710
voucher := models.Voucher{
712711
Voucher: v,
713712
UserID: userID,
714-
Balance: input.Balance,
713+
Balance: a.config.VoucherBalance,
715714
Reason: input.Reason,
716715
}
717716

server/docs/docs.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,14 +2712,9 @@ const docTemplate = `{
27122712
"app.ApplyForVoucherInput": {
27132713
"type": "object",
27142714
"required": [
2715-
"balance",
27162715
"reason"
27172716
],
27182717
"properties": {
2719-
"balance": {
2720-
"type": "integer",
2721-
"minimum": 0
2722-
},
27232718
"reason": {
27242719
"type": "string"
27252720
}

server/docs/swagger.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ definitions:
3535
type: object
3636
app.ApplyForVoucherInput:
3737
properties:
38-
balance:
39-
minimum: 0
40-
type: integer
4138
reason:
4239
type: string
4340
required:
44-
- balance
4541
- reason
4642
type: object
4743
app.ChangePasswordInput:

server/internal/config_parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Configuration struct {
2424
PricesPerMonth Prices `json:"prices"`
2525
Currency string `json:"currency" validate:"nonzero"`
2626
StripeSecret string `json:"stripe_secret" validate:"nonzero"`
27+
VoucherBalance uint64 `json:"voucher_balance" validate:"nonzero"`
2728
}
2829

2930
// Server struct to hold server's information

0 commit comments

Comments
 (0)