package task import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/routers/response" "code.gitea.io/gitea/services/task" "net/http" ) func GetTaskConfigList(ctx *context.Context) { r, err := task.GetTaskConfigWithLimitList() if err != nil { ctx.JSON(http.StatusOK, response.ServerError(err.Error())) return } ctx.JSON(http.StatusOK, response.SuccessWithData(r)) } func AddTaskConfig(ctx *context.Context, config models.TaskConfigWithLimit) { err := task.AddTaskConfig(config, ctx.User) if err != nil { ctx.JSON(http.StatusOK, response.ServerError(err.Error())) return } ctx.JSON(http.StatusOK, response.Success()) } func BatchAddTaskConfig(ctx *context.Context, list models.BatchLimitConfigVO) { successCount := 0 failCount := 0 for _, config := range list.ConfigList { err := task.AddTaskConfig(config, ctx.User) if err != nil { failCount++ } else { successCount++ } } r := make(map[string]int, 2) r["successCount"] = successCount r["failCount"] = failCount ctx.JSON(http.StatusOK, response.SuccessWithData(r)) }