Skip to content

Commit

Permalink
feat(controller, poll): create new poll
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Aug 8, 2023
1 parent 80ac1c8 commit e81b3cb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion internal/controller/poll/poll_v1_get_poll_marks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,33 @@ package poll
import (
"context"

"github.com/hitokoto-osc/reviewer/internal/consts"
"github.com/hitokoto-osc/reviewer/internal/model"
"github.com/hitokoto-osc/reviewer/internal/service"
"github.com/hitokoto-osc/reviewer/utility/time"

"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"

v1 "github.com/hitokoto-osc/reviewer/api/poll/v1"
)

func (c *ControllerV1) GetPollMarks(ctx context.Context, req *v1.GetPollMarksReq) (res *v1.GetPollMarksRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
marks, err := service.Poll().GetPollMarkLabels(ctx)
if err != nil {
return nil, gerror.WrapCode(gcode.CodeOperationFailed, err, "获取投票标签失败")
}
pollMarks := make([]model.PollMark, len(marks))
for i, mark := range marks {
pollMarks[i] = model.PollMark{
ID: mark.Id,
Text: mark.Text,
Level: consts.PollMarkLevel(mark.Level),
Property: consts.PollMarkProperty(mark.Property),
UpdatedAt: (*time.Time)(mark.UpdatedAt),
CreatedAt: (*time.Time)(mark.CreatedAt),
}
}
r := v1.GetPollMarksRes(pollMarks)
return &r, nil
}

0 comments on commit e81b3cb

Please sign in to comment.