package models import ( "code.gitea.io/gitea/modules/timeutil" ) const ( TaskTypeNewIssue = "NEW_ISSUE" TaskTypeIssueChangeStatus = "ISSUE_CHANGE_STATUS" TaskTypeCreateIssueComment = "CREATE_ISSUE_COMMENT" TaskTypeNewPullRequest = "NEW_PULL_REQUEST" TaskTypeRenameRepository = "RENAME_REPOSITORY" TaskTypeAliasRepository = "ALIAS_REPOSITORY" TaskTypeTransferRepository = "TRANSFER_REPOSITORY" TaskTypeCreateRepository = "CREATE_REPOSITORY" TaskTypeCreatePublicRepository = "CREATE_PUBLIC_REPOSITORY" TaskTypeForkRepository = "FORK_REPOSITORY" TaskTypePullRequestReview = "PULL_REQUEST_REVIEW" TaskTypeCommentPull = "COMMENT_PULL" TaskTypeApprovePullRequest = "APPROVE_PULL_REQUEST" TaskTypeRejectPullRequest = "REJECT_PULL_REQUEST" TaskTypeMergePullRequest = "MERGE_PULL_REQUEST" TaskTypeSyncPushCommits = "SYNC_PUSH_COMMITS" TaskTypeSyncCreateRef = "SYNC_CREATE_REF" TaskTypeSyncDeleteRef = "SYNC_DELETE_REF" TaskTypeBindWechat = "BIND_WECHAT" TaskTypeUploadAttachment = "UPLOAD_ATTACHMENT" TaskTypeCreateCloudbrainTask = "CREATE_CLOUDBRAIN_TASK" TaskTypeDatasetRecommended = "DATASET_RECOMMENDED" TaskTypeCreateModel = "CREATE_MODEL" TaskTypeCreatePublicImage = "CREATE_PUBLIC_IMAGE" TaskTypeImageRecommend = "IMAGE_RECOMMEND" TaskTypeChangeUserAvatar = "CHANGE_USER_AVATAR" TaskTypePushCommits = "PUSH_COMMITS" ) const ( PeriodNotCycle = "NOT_CYCLE" PeriodDaily = "DAILY" ) //PointTaskConfig Only add and delete are allowed, edit is not allowed //so if you want to edit config for some task code,please delete first and add new one type TaskConfig struct { ID int64 `xorm:"pk autoincr"` TaskCode string `xorm:"NOT NULL"` Tittle string AwardType string `xorm:"NOT NULL"` AwardAmount int64 `xorm:"NOT NULL"` Creator int64 `xorm:"NOT NULL"` CreatedUnix timeutil.TimeStamp `xorm:"created"` DeletedAt timeutil.TimeStamp `xorm:"deleted"` } func getTaskConfig(t *TaskConfig) (*TaskConfig, error) { has, err := x.Get(t) if err != nil { return nil, err } else if !has { return nil, ErrRecordNotExist{} } return t, nil } func GetTaskConfigByTaskCode(taskCode string) (*TaskConfig, error) { t := &TaskConfig{ TaskCode: taskCode, } return getTaskConfig(t) }