check_cron.go 673 B

12345678910111213141516171819202122232425262728293031
  1. package base
  2. import (
  3. "net/http"
  4. backend2 "github.com/ChineseSubFinder/ChineseSubFinder/pkg/types/backend"
  5. "github.com/gin-gonic/gin"
  6. "github.com/robfig/cron/v3"
  7. )
  8. func (cb *ControllerBase) CheckCronHandler(c *gin.Context) {
  9. var err error
  10. defer func() {
  11. // 统一的异常处理
  12. cb.ErrorProcess(c, "CheckCronHandler", err)
  13. }()
  14. checkCron := backend2.ReqCheckCron{}
  15. err = c.ShouldBindJSON(&checkCron)
  16. if err != nil {
  17. return
  18. }
  19. _, err2 := cron.ParseStandard(checkCron.ScanInterval)
  20. if err2 != nil {
  21. c.JSON(http.StatusOK, backend2.ReplyCommon{Message: err2.Error()})
  22. return
  23. } else {
  24. c.JSON(http.StatusOK, backend2.ReplyCommon{Message: "ok"})
  25. }
  26. }