Files
backend/internal/model/group_announcement.go
lafay 2f584c1f2c
All checks were successful
Build Backend / build (push) Successful in 5m10s
Build Backend / build-docker (push) Successful in 2m22s
This is a breaking change that renames the entire project from "Carrot BBS" to "WithYou".
The Go module name has been changed from `carrot_bbs` to `with_you`, which requires
all import paths to be updated throughout the codebase and by external consumers.

BREAKING CHANGE: Module name changed from carrot_bbs to with_you. All imports
and dependencies must be updated from carrot_bbs/* to with_you/*.
2026-04-22 16:01:59 +08:00

39 lines
938 B
Go

package model
import (
"strconv"
"time"
"with_you/internal/pkg/utils"
"gorm.io/gorm"
)
// GroupAnnouncement 群公告模型
type GroupAnnouncement struct {
ID string `gorm:"primaryKey;size:20" json:"id"`
GroupID string `gorm:"not null;index" json:"group_id"`
Content string `gorm:"type:text;not null" json:"content"`
AuthorID string `gorm:"type:varchar(36);not null" json:"author_id"`
IsPinned bool `gorm:"default:false" json:"is_pinned"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// BeforeCreate 创建前生成雪花算法ID
func (ga *GroupAnnouncement) BeforeCreate(tx *gorm.DB) error {
if ga.ID == "" {
id, err := utils.GetSnowflake().GenerateID()
if err != nil {
return err
}
ga.ID = strconv.FormatInt(id, 10)
}
return nil
}
// TableName 指定表名
func (GroupAnnouncement) TableName() string {
return "group_announcements"
}