## 功能概述 在钱包旁边新增公告中心,用户可以查看平台通知、教程、规则和常见问题。 ## 主要变更 ### 后端 - 新增 announcement 模块(handler/service/repository) - 新增 announcements 数据库表 - 添加公告相关 API 端点(用户端和管理端) - 扩展 response 包,新增 NotFound 和 InternalServerError 方法 ### 前端 - 新增公告功能模块(/features/announcement) - 实现公告列表页和详情页 - 在顶部导航添加公告入口(钱包旁边) - 支持按分类筛选(通知、教程、规则、FAQ) - 支持置顶和重要标记显示 ### 数据库 - 迁移文件:000005_add_announcements.sql - 示例数据:000006_insert_sample_announcements.sql - 包含6条示例公告 ## 技术特点 - 遵循项目现有架构模式 - 响应式设计,支持移动端 - 自动统计浏览次数 - 支持富文本内容展示 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package announcement
|
|
|
|
import "time"
|
|
|
|
type AnnouncementDTO struct {
|
|
ID uint64 `json:"id"`
|
|
Title string `json:"title"`
|
|
Content string `json:"content"`
|
|
Category string `json:"category"`
|
|
Priority int `json:"priority"`
|
|
IsPinned bool `json:"is_pinned"`
|
|
IsImportant bool `json:"is_important"`
|
|
ViewCount int `json:"view_count"`
|
|
Status string `json:"status"`
|
|
PublishedAt *time.Time `json:"published_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type AnnouncementListQuery struct {
|
|
Category string
|
|
Status string
|
|
Page int
|
|
PageSize int
|
|
}
|
|
|
|
type PaginatedResult struct {
|
|
Items interface{} `json:"items"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
}
|
|
|
|
type CreateAnnouncementRequest struct {
|
|
Title string `json:"title" binding:"required,max=255"`
|
|
Content string `json:"content" binding:"required"`
|
|
Category string `json:"category" binding:"required,oneof=notice tutorial rule faq"`
|
|
Priority int `json:"priority"`
|
|
IsPinned bool `json:"is_pinned"`
|
|
IsImportant bool `json:"is_important"`
|
|
}
|
|
|
|
type UpdateAnnouncementRequest struct {
|
|
Title string `json:"title" binding:"max=255"`
|
|
Content string `json:"content"`
|
|
Category string `json:"category" binding:"omitempty,oneof=notice tutorial rule faq"`
|
|
Priority int `json:"priority"`
|
|
IsPinned bool `json:"is_pinned"`
|
|
IsImportant bool `json:"is_important"`
|
|
}
|