From 53ed299eb9c08e5cd170a0346859ea9dc87010d3 Mon Sep 17 00:00:00 2001 From: Du Jiajun Date: Mon, 23 Sep 2024 22:26:36 +0800 Subject: [PATCH] feat: implement write review with frontend --- model/converter/review.go | 2 ++ model/dto/review.go | 1 + model/model/rating.go | 4 ++-- model/model/review.go | 1 + model/po/review.go | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/model/converter/review.go b/model/converter/review.go index a1cc3db..6cd83bc 100644 --- a/model/converter/review.go +++ b/model/converter/review.go @@ -21,6 +21,7 @@ func ConvertReviewFromPO(po po.ReviewPO) model.Review { IsAnonymous: po.IsAnonymous, CreatedAt: po.CreatedAt, UpdatedAt: po.UpdatedAt, + Grade: po.Grade, } } @@ -56,5 +57,6 @@ func ConvertReviewDTOToPO(dto dto.UpdateReviewDTO, userID int64) po.ReviewPO { Rating: dto.Rating, Semester: dto.Semester, IsAnonymous: dto.IsAnonymous, + Grade: dto.Grade, } } diff --git a/model/dto/review.go b/model/dto/review.go index 4e7b7b3..0046924 100644 --- a/model/dto/review.go +++ b/model/dto/review.go @@ -9,6 +9,7 @@ type UpdateReviewDTO struct { Comment string `json:"comment" binding:"required"` Semester string `json:"semester" binding:"required"` IsAnonymous bool `json:"is_anonymous"` + Grade string `json:"grade"` } type CreateReviewResponse struct { diff --git a/model/model/rating.go b/model/model/rating.go index d8c5730..0b296c2 100644 --- a/model/model/rating.go +++ b/model/model/rating.go @@ -15,8 +15,8 @@ type RatingInfoDistItemByID struct { } type RatingInfoDistItem struct { - Rating int64 - Count int64 + Rating int64 `json:"rating"` + Count int64 `json:"count"` } type RatingInfo struct { diff --git a/model/model/review.go b/model/model/review.go index cff9768..c3de72e 100644 --- a/model/model/review.go +++ b/model/model/review.go @@ -21,6 +21,7 @@ type Review struct { Rating int64 `json:"rating"` Semester string `json:"semester"` IsAnonymous bool `json:"is_anonymous"` + Grade string `json:"grade"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at,omitempty"` } diff --git a/model/po/review.go b/model/po/review.go index 9ed0330..1ce7bce 100644 --- a/model/po/review.go +++ b/model/po/review.go @@ -10,6 +10,7 @@ type ReviewPO struct { Rating int64 `gorm:"index"` Semester string `gorm:"index"` IsAnonymous bool + Grade string // 成绩 SearchIndex SearchIndex `gorm:"->:false;<-"` }