init: radio init commit

This commit is contained in:
Blizzard
2026-02-28 15:56:26 +08:00
parent fc585fa4df
commit d79beb4663
63 changed files with 2540 additions and 6399 deletions
+23
View File
@@ -0,0 +1,23 @@
package radio
import (
"sundynix-go/global"
"sundynix-go/model/system"
)
// RadioCategory 电台分类表
type RadioCategory struct {
global.BaseModel
Name string `gorm:"size:50" json:"name"` // 分类名称
Description string `gorm:"size:255" json:"description"` // 分类描述
IconId string `gorm:"size:50" json:"iconId"` // 图标OSS ID
Icon *system.Oss `gorm:"foreignKey:IconId" json:"icon"` // 图标OSS
CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID
Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS
Sort int `gorm:"default:0" json:"sort"` // 排序
Status int `gorm:"default:1" json:"status"` // 状态 0:禁用 1:启用
}
func (RadioCategory) TableName() string {
return "sundynix_radio_category"
}
+26
View File
@@ -0,0 +1,26 @@
package radio
import (
"sundynix-go/global"
"sundynix-go/model/system"
)
// RadioChannel 电台频道表
type RadioChannel struct {
global.BaseModel
CategoryId string `gorm:"size:50;index" json:"categoryId"` // 分类ID
Name string `gorm:"size:50" json:"name"` // 频道名称
Description string `gorm:"size:500" json:"description"` // 频道描述
Price int `gorm:"default:0;comment:价格,单位,分 " json:"price"` //价格 单位:分
CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID
Cover *system.Oss `gorm:"foreignKey:CoverId" json:"cover"` // 封面图OSS
Tags string `gorm:"size:255" json:"tags"` // 标签,逗号分隔
IsVipOnly int `gorm:"default:0" json:"isVipOnly"` // 是否VIP专享 0:否 1:是
Sort int `gorm:"default:0" json:"sort"` // 排序
Status int `gorm:"default:1" json:"status"` // 状态 0:禁用 1:启用
HasSubscribed int `gorm:"-" json:"hasSubscribed"` // 状态 0:未订阅 1:已订阅
}
func (RadioChannel) TableName() string {
return "sundynix_radio_channel"
}
+19
View File
@@ -0,0 +1,19 @@
package radio
import (
"sundynix-go/global"
)
// RadioComment 用户评论表
type RadioComment struct {
global.BaseModel
ProgramId string `gorm:"size:50;index" json:"programId"` // 节目ID
UserId string `gorm:"size:50;index" json:"userId"` // 用户ID
ParentId string `gorm:"size:50" json:"parentId"` // 父评论ID
Content string `gorm:"type:text" json:"content"` // 评论内容
LikeCount int `gorm:"default:0" json:"likeCount"` // 点赞数
}
func (RadioComment) TableName() string {
return "sundynix_radio_comment"
}
+16
View File
@@ -0,0 +1,16 @@
package radio
import (
"sundynix-go/global"
)
// RadioFavorite 用户收藏表
type RadioFavorite struct {
global.BaseModel
UserId string `gorm:"size:50;index" json:"userId"` // 用户ID
ProgramId string `gorm:"size:50;index" json:"programId"` // 节目ID
}
func (RadioFavorite) TableName() string {
return "sundynix_radio_favorite"
}
+18
View File
@@ -0,0 +1,18 @@
package radio
import (
"sundynix-go/global"
)
// RadioHistory 用户收听历史表
type RadioHistory struct {
global.BaseModel
UserId string `gorm:"size:50;index" json:"userId"` // 用户ID
ProgramId string `gorm:"size:50;index" json:"programId"` // 节目ID
Progress int `gorm:"default:0" json:"progress"` // 播放进度(秒)
Duration int `gorm:"default:0" json:"duration"` // 节目总时长(秒)
}
func (RadioHistory) TableName() string {
return "sundynix_radio_history"
}
+16
View File
@@ -0,0 +1,16 @@
package radio
import (
"sundynix-go/global"
)
// RadioLike 用户点赞表
type RadioLike struct {
global.BaseModel
UserId string `gorm:"size:50;index" json:"userId"` // 用户ID
ProgramId string `gorm:"size:50;index" json:"programId"` // 节目ID
}
func (RadioLike) TableName() string {
return "sundynix_radio_like"
}
+28
View File
@@ -0,0 +1,28 @@
package radio
import (
"sundynix-go/global"
"sundynix-go/model/system"
)
// RadioProgram 电台节目表
type RadioProgram struct {
global.BaseModel
ChannelId string `gorm:"size:50;index" json:"channelId"` // 频道ID
Title string `gorm:"size:100" json:"title"` // 节目标题
Description string `gorm:"size:500" json:"description"` // 节目描述
Content string `gorm:"type:text" json:"content"`
CoverId string `gorm:"size:50" json:"coverId"` // 封面图OSS ID
Cover *system.Oss `gorm:"foreignKey:CoverId" json:"coverUrl"` // 封面图OSS
AudioId string `gorm:"size:50" json:"audioId"` // 音频OSS ID
Audio *system.Oss `gorm:"foreignKey:AudioId" json:"audio"` // 音频OSS
Duration int `gorm:"default:0" json:"duration"` // 时长(秒)
Tags string `gorm:"size:255" json:"tags"` // 标签,逗号分隔
PlayCount int `gorm:"default:0" json:"playCount"` // 播放次数
LikeCount int `gorm:"default:0" json:"likeCount"` // 点赞次数
Status int `gorm:"default:1" json:"status"` // 状态 0:下架 1:上架
}
func (RadioProgram) TableName() string {
return "sundynix_radio_program"
}
+17
View File
@@ -0,0 +1,17 @@
package radio
import (
"sundynix-go/global"
)
// RadioSubscription 用户订阅表
type RadioSubscription struct {
global.BaseModel
UserId string `gorm:"size:50;index;not null;uniqueIndex:idx_user_channel" json:"userId"` // 用户ID
ChannelId string `gorm:"size:50;index;uniqueIndex:idx_user_channel" json:"channelId"` // 频道ID
Status int `gorm:"type:tinyint;default:1"` //1-订阅中,2-已取消
}
func (RadioSubscription) TableName() string {
return "sundynix_radio_subscription"
}
+29
View File
@@ -0,0 +1,29 @@
package radio
import (
"sundynix-go/global"
"sundynix-go/model/system"
)
// RadioUser 小程序用户信息表
type RadioUser struct {
global.BaseModel
UserId string `gorm:"size:50;uniqueIndex" json:"userId"` // 关联system用户ID
OpenId string `gorm:"size:80;uniqueIndex" json:"openId"` // 微信openid
UnionId string `gorm:"size:80" json:"unionId"` // 微信unionid
SessionKey string `gorm:"size:200" json:"sessionKey"` // 会话密钥
NickName string `gorm:"size:50" json:"nickName"` // 昵称
AvatarId string `gorm:"size:50" json:"avatarId"` // 头像OSS ID
Avatar *system.Oss `gorm:"foreignKey:AvatarId" json:"avatar"` // 头像OSS
Gender int `gorm:"default:0" json:"gender"` // 性别 0:未知 1:男 2:女
Country string `gorm:"size:50" json:"country"` // 国家
Province string `gorm:"size:50" json:"province"` // 省份
City string `gorm:"size:50" json:"city"` // 城市
Language string `gorm:"size:20" json:"language"` // 语言
IsVip int `gorm:"default:0" json:"isVip"` // 是否VIP 0:否 1:是
VipExpireAt *int64 `gorm:"type:bigint" json:"vipExpireAt"` // VIP过期时间
}
func (RadioUser) TableName() string {
return "sundynix_radio_user"
}
+32
View File
@@ -0,0 +1,32 @@
package request
import common "sundynix-go/model/commom/request"
// GetCategoryList 获取分类列表请求
type GetCategoryList struct {
common.PageInfo
Name string `json:"name" form:"name"` // 分类名称
Status int `json:"status" form:"status"` // 状态
}
// SaveCategory 保存分类请求
type SaveCategory struct {
Id string `json:"id" form:"id"` // 分类ID(更新时使用)
Name string `json:"name" binding:"required"` // 分类名称
Description string `json:"description"` // 分类描述
IconId string `json:"iconId"` // 图标URL
CoverId string `json:"coverId"` // 封面图URL
Sort int `json:"sort"` // 排序
Status int `json:"status"` // 状态
}
// UpdateCategory 更新分类请求
type UpdateCategory struct {
Id string `json:"id" binding:"required"` // 分类ID
Name string `json:"name"` // 分类名称
Description string `json:"description"` // 分类描述
IconId string `json:"iconId"` // 图标URL
CoverId string `json:"coverId"` // 封面图URL
Sort int `json:"sort"` // 排序
Status int `json:"status"` // 状态
}
+37
View File
@@ -0,0 +1,37 @@
package request
import common "sundynix-go/model/commom/request"
// GetChannelList 获取频道列表请求
type GetChannelList struct {
common.PageInfo
CategoryId string `json:"categoryId" form:"categoryId"` // 分类ID
Name string `json:"name" form:"name"` // 频道名称
Status int `json:"status" form:"status"` // 状态
}
// SaveChannel 保存频道请求
type SaveChannel struct {
Id string `json:"id" form:"id"` // 频道ID(更新时使用)
CategoryId string `json:"categoryId" binding:"required"` // 分类ID
Name string `json:"name" binding:"required"` // 频道名称
Description string `json:"description"` // 频道描述
CoverId string `json:"coverId"` // 封面图URL
Tags string `json:"tags"` // 标签
IsVipOnly int `json:"isVipOnly"` // 是否VIP专享
Sort int `json:"sort"` // 排序
Status int `json:"status"` // 状态
}
// UpdateChannel 更新频道请求
type UpdateChannel struct {
Id string `json:"id" binding:"required"` // 频道ID
CategoryId string `json:"categoryId"` // 分类ID
Name string `json:"name"` // 频道名称
Description string `json:"description"` // 频道描述
CoverId string `json:"coverId"` // 封面图URL
Tags string `json:"tags"` // 标签
IsVipOnly int `json:"isVipOnly"` // 是否VIP专享
Sort int `json:"sort"` // 排序
Status int `json:"status"` // 状态
}
+68
View File
@@ -0,0 +1,68 @@
package request
import common "sundynix-go/model/commom/request"
// SubscribeChannel 订阅频道请求
type SubscribeChannel struct {
ChannelId string `json:"channelId" binding:"required"` // 频道ID
}
// UnsubscribeChannel 退订频道请求
type UnsubscribeChannel struct {
ChannelId string `json:"channelId" binding:"required"` // 频道ID
}
// AddHistory 添加收听历史请求
type AddHistory struct {
ProgramId string `json:"programId" binding:"required"` // 节目ID
Progress int `json:"progress"` // 播放进度(秒)
Duration int `json:"duration"` // 节目总时长(秒)
}
// ToggleLike 切换点赞请求
type ToggleLike struct {
ProgramId string `json:"programId" binding:"required"` // 节目ID
}
// AddFavorite 添加收藏请求
type AddFavorite struct {
ProgramId string `json:"programId" binding:"required"` // 节目ID
}
// RemoveFavorite 移除收藏请求
type RemoveFavorite struct {
ProgramId string `json:"programId" binding:"required"` // 节目ID
}
// AddComment 添加评论请求
type AddComment struct {
ProgramId string `json:"programId" binding:"required"` // 节目ID
ParentId string `json:"parentId"` // 父评论ID
Content string `json:"content" binding:"required"` // 评论内容
}
// DeleteComment 删除评论请求
type DeleteComment struct {
CommentId string `json:"commentId" binding:"required"` // 评论ID
}
// GetHistoryList 获取收听历史列表请求
type GetHistoryList struct {
common.PageInfo
}
// GetFavoriteList 获取收藏列表请求
type GetFavoriteList struct {
common.PageInfo
}
// GetCommentList 获取评论列表请求
type GetCommentList struct {
common.PageInfo
ProgramId string `json:"programId" form:"programId"` // 节目ID
}
// GetSubscriptionList 获取订阅列表请求
type GetSubscriptionList struct {
common.PageInfo
}
+39
View File
@@ -0,0 +1,39 @@
package request
import common "sundynix-go/model/commom/request"
// GetProgramList 获取节目列表请求
type GetProgramList struct {
common.PageInfo
ChannelId string `json:"channelId" form:"channelId"` // 频道ID
Title string `json:"title" form:"title"` // 节目标题
Status int `json:"status" form:"status"` // 状态
}
// SaveProgram 保存节目请求
type SaveProgram struct {
Id string `json:"id" form:"id"` // 节目ID(更新时使用)
ChannelId string `json:"channelId" binding:"required"` // 频道ID
Title string `json:"title" binding:"required"` // 节目标题
Description string `json:"description"` // 节目描述
Content string `json:"content"`
CoverId string `json:"coverId"` // 封面图URL
AudioId string `json:"audioId"` // 音频URL
Duration int `json:"duration"` // 时长(秒)
Tags string `json:"tags"` // 标签
Status int `json:"status"` // 状态
}
// UpdateProgram 更新节目请求
type UpdateProgram struct {
Id string `json:"id" binding:"required"` // 节目ID
ChannelId string `json:"channelId"` // 频道ID
Title string `json:"title"` // 节目标题
Description string `json:"description"` // 节目描述
Content string `json:"content"`
CoverId string `json:"coverId"` // 封面图URL
AudioId string `json:"audioId"` // 音频URL
Duration int `json:"duration"` // 时长(秒)
Tags string `json:"tags"` // 标签
Status int `json:"status"` // 状态
}
+43
View File
@@ -0,0 +1,43 @@
package response
import "sundynix-go/model/radio"
// CategoryResponse 分类响应
type CategoryResponse struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
CoverUrl string `json:"coverUrl"`
Sort int `json:"sort"`
Status int `json:"status"`
}
// CategoryDetailResponse 分类详情响应
type CategoryDetailResponse struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
CoverUrl string `json:"coverUrl"`
Sort int `json:"sort"`
Status int `json:"status"`
}
// ToCategoryResponse 转换为分类响应
func ToCategoryResponse(category *radio.RadioCategory) CategoryResponse {
resp := CategoryResponse{
Id: category.Id,
Name: category.Name,
Description: category.Description,
Sort: category.Sort,
Status: category.Status,
}
if category.Icon != nil {
resp.Icon = category.Icon.Url
}
if category.Cover != nil {
resp.CoverUrl = category.Cover.Url
}
return resp
}
+29
View File
@@ -0,0 +1,29 @@
package response
// ChannelResponse 频道响应
type ChannelResponse struct {
Id string `json:"id"`
CategoryId string `json:"categoryId"`
Name string `json:"name"`
Description string `json:"description"`
CoverUrl string `json:"coverUrl"`
StreamUrl string `json:"streamUrl"`
Tags string `json:"tags"`
IsVipOnly int `json:"isVipOnly"`
Sort int `json:"sort"`
Status int `json:"status"`
}
// ChannelDetailResponse 频道详情响应
type ChannelDetailResponse struct {
Id string `json:"id"`
CategoryId string `json:"categoryId"`
Name string `json:"name"`
Description string `json:"description"`
CoverUrl string `json:"coverUrl"`
StreamUrl string `json:"streamUrl"`
Tags string `json:"tags"`
IsVipOnly int `json:"isVipOnly"`
Sort int `json:"sort"`
Status int `json:"status"`
}