Skip to content

Commit

Permalink
fix(message): model defination issue
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Oct 4, 2023
1 parent c7dddbb commit 421710b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
4 changes: 1 addition & 3 deletions consumers/notification/v1/hitokotoPollFinished.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"github.com/cockroachdb/errors"
"github.com/golang-module/carbon/v2"
"github.com/hitokoto-osc/notification-worker/consumers/notification/v1/internal/model"
"github.com/hitokoto-osc/notification-worker/consumers/provider"
"github.com/hitokoto-osc/notification-worker/django"
Expand Down Expand Up @@ -57,7 +56,7 @@ func HitokotoPollFinishedEvent() *rabbitmq.ConsumerRegisterOptions {
html, err := django.RenderTemplate("email/poll_finished", django.Context{
"username": message.Username,
"poll_id": message.PollID,
"operated_at": carbon.Parse(message.UpdatedAt).Format("Y-m-d H:i:s"),
"operated_at": message.UpdatedAt.Format("Y-m-d H:i:s"),
"hitokoto": message.Hitokoto,
"from": message.From,
"from_who": message.FromWho,
Expand All @@ -66,7 +65,6 @@ func HitokotoPollFinishedEvent() *rabbitmq.ConsumerRegisterOptions {
"status": formatter.FormatPollStatus(message.Status),
"method": formatter.FormatPollMethod(message.Method),
"point": strconv.Itoa(message.Point),
"now": carbon.Now().Format("Y 年 n 月 j 日"),
})
if err != nil {
return errors.Wrap(err, "无法渲染模板")
Expand Down
20 changes: 9 additions & 11 deletions consumers/notification/v1/internal/model/hitokoto.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ type HitokotoReviewedMessage struct {
// PollCreatedMessage 投票创建消息
type PollCreatedMessage struct {
HitokotoBaseMessage
Username string `json:"user_name" validate:"required"` // 收信人
ID uint `json:"id" validate:"required"` // 投票标识
CreatedAt *vcarbon.Carbon `json:"created_at" validate:"required"` // 这里是投票创建时间, ISO 时间
Username string `json:"user_name" validate:"required"` // 收信人
ID uint `json:"id" validate:"required"` // 投票标识
}

// PollDailyReportMessage 每日审核员报告消息
Expand All @@ -65,7 +64,7 @@ type PollDailyReportMessage struct {
Accept int `json:"accept"` // 投批准票的投票数目
Reject int `json:"reject"` // 投拒绝票的投票数目
NeedEdited int `json:"need_edited"` // 投需要修改的投票数目
} `json:"polled"` // 用户参与了的投票数目(过去 24 小时)
} `json:"polled" validate:"required"` // 用户参与了的投票数目(过去 24 小时)
Waiting int `json:"waiting"` // 等待其他用户参与的投票数目(基于已投票的数目)
Accepted int `json:"accepted"` // 已入库的投票数目(基于已投票的数目)
Rejected int `json:"rejected"` // 已驳回的投票数目(基于已投票的数目)
Expand All @@ -77,12 +76,11 @@ type PollDailyReportMessage struct {
// PollFinishedMessage 投票完成消息
type PollFinishedMessage struct {
HitokotoBaseMessage
PollID int `json:"id"` // 投票 ID
UpdatedAt string `json:"updated_at"` // 投票更新时间,这里也是结束时间
Username string `json:"user_name"` // 审核员名字
CreatedAt string `json:"created_at"` // 投票创建时间
Status consts.PollStatus `json:"status"` // 投票结果: 200 入库,201 驳回,202 需要修改
Method consts.PollMethod `json:"method"` // 审核员投票方式: 1 入库,2 驳回,3 需要修改
Point int `json:"point"` // 审核员投的票数
PollID int `json:"id" validate:"required"` // 投票 ID
UpdatedAt *vcarbon.Carbon `json:"updated_at" validate:"required"` // 投票更新时间,这里也是结束时间
Username string `json:"user_name" validate:"required"` // 审核员名字
Status consts.PollStatus `json:"status" validate:"required"` // 投票结果: 200 入库,201 驳回,202 需要修改
Method consts.PollMethod `json:"method" validate:"required"` // 审核员投票方式: 1 入库,2 驳回,3 需要修改
Point int `json:"point" validate:"required"` // 审核员投的票数
// TODO: 加入审核员投票的意见标签?
}

0 comments on commit 421710b

Please sign in to comment.