You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

limit.go 1.0 kB

3 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. package point
  2. import (
  3. "code.gitea.io/gitea/models"
  4. "code.gitea.io/gitea/modules/context"
  5. "code.gitea.io/gitea/routers/response"
  6. "code.gitea.io/gitea/services/reward/limiter"
  7. "net/http"
  8. )
  9. func GetPointLimitConfigList(ctx *context.Context) {
  10. r, err := limiter.GetLimitConfigList(models.LimitTypeRewardPoint)
  11. if err != nil {
  12. ctx.JSON(http.StatusOK, response.ServerError(err.Error()))
  13. return
  14. }
  15. ctx.JSON(http.StatusOK, response.SuccessWithData(r))
  16. }
  17. func AddPointLimitConfig(ctx *context.Context, config models.LimitConfigVO) {
  18. err := limiter.AddLimitConfig(&config, ctx.User, models.LimitTypeRewardPoint)
  19. if err != nil {
  20. ctx.JSON(http.StatusOK, response.ServerError(err.Error()))
  21. return
  22. }
  23. ctx.JSON(http.StatusOK, response.Success())
  24. }
  25. func DeletePointLimitConfig(ctx *context.Context) {
  26. id := ctx.QueryInt64("id")
  27. err := limiter.DeleteLimitConfig(id, ctx.User)
  28. if err != nil {
  29. ctx.JSON(http.StatusOK, response.ServerError(err.Error()))
  30. return
  31. }
  32. ctx.JSON(http.StatusOK, response.Success())
  33. }