diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-04-08 17:11:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 17:11:15 +0800 |
commit | 1dfa26e00e8e1ce6f6125335871da1d402a63466 (patch) | |
tree | d39414fb085ae52d6633ae9d064aabab2e7f75f8 /routers/api/v1/repo/milestone.go | |
parent | 84ceaa98bd731431c7d3a7f65e59e7ad076a540f (diff) | |
download | gitea-1dfa26e00e8e1ce6f6125335871da1d402a63466.tar.gz gitea-1dfa26e00e8e1ce6f6125335871da1d402a63466.zip |
Move milestone to models/issues/ (#19278)
* Move milestone to models/issues/
* Fix lint
* Fix test
* Fix lint
* Fix lint
Diffstat (limited to 'routers/api/v1/repo/milestone.go')
-rw-r--r-- | routers/api/v1/repo/milestone.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index 3b4b85158c..ce6aa7f46f 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - "code.gitea.io/gitea/models" + issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/convert" api "code.gitea.io/gitea/modules/structs" @@ -57,7 +57,7 @@ func ListMilestones(ctx *context.APIContext) { // "200": // "$ref": "#/responses/MilestoneList" - milestones, total, err := models.GetMilestones(models.GetMilestonesOption{ + milestones, total, err := issues_model.GetMilestones(issues_model.GetMilestonesOption{ ListOptions: utils.GetListOptions(ctx), RepoID: ctx.Repo.Repository.ID, State: api.StateType(ctx.FormString("state")), @@ -146,7 +146,7 @@ func CreateMilestone(ctx *context.APIContext) { form.Deadline = &defaultDeadline } - milestone := &models.Milestone{ + milestone := &issues_model.Milestone{ RepoID: ctx.Repo.Repository.ID, Name: form.Title, Content: form.Description, @@ -158,7 +158,7 @@ func CreateMilestone(ctx *context.APIContext) { milestone.ClosedDateUnix = timeutil.TimeStampNow() } - if err := models.NewMilestone(milestone); err != nil { + if err := issues_model.NewMilestone(milestone); err != nil { ctx.Error(http.StatusInternalServerError, "NewMilestone", err) return } @@ -218,7 +218,7 @@ func EditMilestone(ctx *context.APIContext) { milestone.IsClosed = *form.State == string(api.StateClosed) } - if err := models.UpdateMilestone(milestone, oldIsClosed); err != nil { + if err := issues_model.UpdateMilestone(milestone, oldIsClosed); err != nil { ctx.Error(http.StatusInternalServerError, "UpdateMilestone", err) return } @@ -255,7 +255,7 @@ func DeleteMilestone(ctx *context.APIContext) { return } - if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, m.ID); err != nil { + if err := issues_model.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, m.ID); err != nil { ctx.Error(http.StatusInternalServerError, "DeleteMilestoneByRepoID", err) return } @@ -263,23 +263,23 @@ func DeleteMilestone(ctx *context.APIContext) { } // getMilestoneByIDOrName get milestone by ID and if not available by name -func getMilestoneByIDOrName(ctx *context.APIContext) *models.Milestone { +func getMilestoneByIDOrName(ctx *context.APIContext) *issues_model.Milestone { mile := ctx.Params(":id") mileID, _ := strconv.ParseInt(mile, 0, 64) if mileID != 0 { - milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, mileID) + milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, mileID) if err == nil { return milestone - } else if !models.IsErrMilestoneNotExist(err) { + } else if !issues_model.IsErrMilestoneNotExist(err) { ctx.Error(http.StatusInternalServerError, "GetMilestoneByRepoID", err) return nil } } - milestone, err := models.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, mile) + milestone, err := issues_model.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, mile) if err != nil { - if models.IsErrMilestoneNotExist(err) { + if issues_model.IsErrMilestoneNotExist(err) { ctx.NotFound() return nil } |