(c *gin.Context)
| 133 | } |
| 134 | |
| 135 | func UpdateRedemption(c *gin.Context) { |
| 136 | statusOnly := c.Query("status_only") |
| 137 | redemption := model.Redemption{} |
| 138 | err := c.ShouldBindJSON(&redemption) |
| 139 | if err != nil { |
| 140 | common.ApiError(c, err) |
| 141 | return |
| 142 | } |
| 143 | cleanRedemption, err := model.GetRedemptionById(redemption.Id) |
| 144 | if err != nil { |
| 145 | common.ApiError(c, err) |
| 146 | return |
| 147 | } |
| 148 | if statusOnly == "" { |
| 149 | if err := validateExpiredTime(redemption.ExpiredTime); err != nil { |
| 150 | c.JSON(http.StatusOK, gin.H{"success": false, "message": err.Error()}) |
| 151 | return |
| 152 | } |
| 153 | // If you add more fields, please also update redemption.Update() |
| 154 | cleanRedemption.Name = redemption.Name |
| 155 | cleanRedemption.Quota = redemption.Quota |
| 156 | cleanRedemption.ExpiredTime = redemption.ExpiredTime |
| 157 | } |
| 158 | if statusOnly != "" { |
| 159 | cleanRedemption.Status = redemption.Status |
| 160 | } |
| 161 | err = cleanRedemption.Update() |
| 162 | if err != nil { |
| 163 | common.ApiError(c, err) |
| 164 | return |
| 165 | } |
| 166 | c.JSON(http.StatusOK, gin.H{ |
| 167 | "success": true, |
| 168 | "message": "", |
| 169 | "data": cleanRedemption, |
| 170 | }) |
| 171 | return |
| 172 | } |
| 173 | |
| 174 | func DeleteInvalidRedemption(c *gin.Context) { |
| 175 | rows, err := model.DeleteInvalidRedemptions() |
nothing calls this directly
no test coverage detected