| 820 | var topUpLock = sync.Mutex{} |
| 821 | |
| 822 | func TopUp(c *gin.Context) { |
| 823 | topUpLock.Lock() |
| 824 | defer topUpLock.Unlock() |
| 825 | req := topUpRequest{} |
| 826 | err := c.ShouldBindJSON(&req) |
| 827 | if err != nil { |
| 828 | common.ApiError(c, err) |
| 829 | return |
| 830 | } |
| 831 | id := c.GetInt("id") |
| 832 | quota, err := model.Redeem(req.Key, id) |
| 833 | if err != nil { |
| 834 | common.ApiError(c, err) |
| 835 | return |
| 836 | } |
| 837 | c.JSON(http.StatusOK, gin.H{ |
| 838 | "success": true, |
| 839 | "message": "", |
| 840 | "data": quota, |
| 841 | }) |
| 842 | return |
| 843 | } |
| 844 | |
| 845 | type UpdateUserSettingRequest struct { |
| 846 | QuotaWarningType string `json:"notify_type"` |