Skip to content

Commit

Permalink
make voucher balance fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Feb 11, 2025
1 parent dcfeca3 commit d8d57b3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
5 changes: 2 additions & 3 deletions server/app/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ type EmailInput struct {

// ApplyForVoucherInput struct for user to apply for voucher
type ApplyForVoucherInput struct {
Balance uint64 `json:"balance" binding:"required" validate:"min=0"`
Reason string `json:"reason" binding:"required" validate:"nonzero"`
Reason string `json:"reason" binding:"required" validate:"nonzero"`
}

// AddVoucherInput struct for voucher applied by user
Expand Down Expand Up @@ -711,7 +710,7 @@ func (a *App) ApplyForVoucherHandler(req *http.Request) (interface{}, Response)
voucher := models.Voucher{
Voucher: v,
UserID: userID,
Balance: input.Balance,
Balance: a.config.VoucherBalance,
Reason: input.Reason,
}

Expand Down
5 changes: 0 additions & 5 deletions server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2712,14 +2712,9 @@ const docTemplate = `{
"app.ApplyForVoucherInput": {
"type": "object",
"required": [
"balance",
"reason"
],
"properties": {
"balance": {
"type": "integer",
"minimum": 0
},
"reason": {
"type": "string"
}
Expand Down
4 changes: 0 additions & 4 deletions server/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,9 @@ definitions:
type: object
app.ApplyForVoucherInput:
properties:
balance:
minimum: 0
type: integer
reason:
type: string
required:
- balance
- reason
type: object
app.ChangePasswordInput:
Expand Down
1 change: 1 addition & 0 deletions server/internal/config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Configuration struct {
PricesPerMonth Prices `json:"prices"`
Currency string `json:"currency" validate:"nonzero"`
StripeSecret string `json:"stripe_secret" validate:"nonzero"`
VoucherBalance uint64 `json:"voucher_balance" validate:"nonzero"`
}

// Server struct to hold server's information
Expand Down

0 comments on commit d8d57b3

Please sign in to comment.