Add new functionality for managing and synchronizing academic grades and exam schedules. This includes new models, repositories, services, and HTTP handlers, along with updated gRPC definitions and dependency injection configuration. Additionally, improve the reliability of unread message count tracking by implementing an atomic Lua script for Redis operations in the conversation cache.
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Grade struct {
|
|
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
|
UserID string `json:"user_id" gorm:"type:varchar(36);index;not null"`
|
|
Term string `json:"term" gorm:"type:varchar(30);not null"`
|
|
CourseCode string `json:"course_code" gorm:"type:varchar(30)"`
|
|
CourseName string `json:"course_name" gorm:"type:varchar(120);not null"`
|
|
Nature string `json:"nature" gorm:"type:varchar(30)"`
|
|
Category string `json:"category" gorm:"type:varchar(30)"`
|
|
Credit string `json:"credit" gorm:"type:varchar(10)"`
|
|
Score string `json:"score" gorm:"type:varchar(20)"`
|
|
GradePoint string `json:"grade_point" gorm:"type:varchar(10)"`
|
|
IsExam string `json:"is_exam" gorm:"type:varchar(10)"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (g *Grade) BeforeCreate(tx *gorm.DB) error {
|
|
SetUUIDIfEmpty(&g.ID)
|
|
return nil
|
|
}
|
|
|
|
func (Grade) TableName() string { return "grades" }
|
|
|
|
type GpaSummary struct {
|
|
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
|
UserID string `json:"user_id" gorm:"type:varchar(36);index;not null"`
|
|
Semester string `json:"semester" gorm:"type:varchar(30);not null"`
|
|
AverageGpa string `json:"average_gpa" gorm:"type:varchar(20)"`
|
|
Rank string `json:"rank" gorm:"type:varchar(30)"`
|
|
ExamTotalGpa string `json:"exam_total_gpa" gorm:"type:varchar(20)"`
|
|
ExamTotalCredits string `json:"exam_total_credits" gorm:"type:varchar(20)"`
|
|
FailCredits string `json:"fail_credits" gorm:"type:varchar(20)"`
|
|
Semesters string `json:"semesters" gorm:"type:varchar(20)"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (g *GpaSummary) BeforeCreate(tx *gorm.DB) error {
|
|
SetUUIDIfEmpty(&g.ID)
|
|
return nil
|
|
}
|
|
|
|
func (GpaSummary) TableName() string { return "gpa_summaries" }
|