79 lines
2.9 KiB
Go
79 lines
2.9 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// MessagePushLog 消息推送记录模型
|
|
type MessagePushLog struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
Title string `gorm:"type:varchar(255);not null;default:'';comment:消息标题" json:"title"`
|
|
Content string `gorm:"type:text;not null;comment:消息内容" json:"content"`
|
|
TargetUsers string `gorm:"type:json;not null;comment:目标用户ID列表" json:"target_users"` // 存储JSON字符串
|
|
SenderID int `gorm:"not null;comment:发送人ID" json:"sender_id"`
|
|
SenderName string `gorm:"type:varchar(100);not null;comment:发送人姓名" json:"sender_name"`
|
|
Status int `gorm:"type:tinyint;default:0;comment:发送状态 0=待发送 1=发送中 2=发送成功 3=发送失败" json:"status"`
|
|
SuccessCount int `gorm:"default:0;comment:成功数量" json:"success_count"`
|
|
FailCount int `gorm:"default:0;comment:失败数量" json:"fail_count"`
|
|
ErrorMessage string `gorm:"type:text;comment:错误信息" json:"error_message"`
|
|
SentAt *time.Time `gorm:"comment:发送时间" json:"sent_at"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
}
|
|
|
|
// TableName 指定数据库表名
|
|
func (MessagePushLog) TableName() string {
|
|
return "admin_message_push_logs"
|
|
}
|
|
|
|
// MessagePushRequest 消息推送请求
|
|
type MessagePushRequest struct {
|
|
Title string `json:"title" validate:"required,min=1,max=100"`
|
|
Content string `json:"content" validate:"required,min=1,max=2000"`
|
|
UserIDs []int `json:"user_ids" validate:"required,min=1"`
|
|
}
|
|
|
|
// MessagePushResponse 消息推送响应
|
|
type MessagePushResponse struct {
|
|
LogID int64 `json:"log_id"`
|
|
SuccessCount int `json:"success_count"`
|
|
FailCount int `json:"fail_count"`
|
|
}
|
|
|
|
// MessagePushListRequest 推送记录列表请求
|
|
type MessagePushListRequest struct {
|
|
Page int `form:"page,default=1"`
|
|
PageSize int `form:"page_size,default=10"`
|
|
Status *int `form:"status"` // 0=待发送, 1=发送中, 2=发送成功, 3=发送失败
|
|
SenderID *int `form:"sender_id"`
|
|
StartTime string `form:"start_time"`
|
|
EndTime string `form:"end_time"`
|
|
}
|
|
|
|
// MessagePushListResponse 推送记录列表响应
|
|
type MessagePushListResponse struct {
|
|
List []MessagePushLog `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
}
|
|
|
|
// UserSearchRequest 用户搜索请求
|
|
type UserSearchRequest struct {
|
|
Keyword string `form:"keyword" validate:"required,min=1"`
|
|
Limit int `form:"limit,default=20"`
|
|
}
|
|
|
|
// UserSearchResponse 用户搜索响应
|
|
type UserSearchResponse struct {
|
|
Users []UserSearchItem `json:"users"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
// UserSearchItem 用户搜索项
|
|
type UserSearchItem struct {
|
|
ID int `json:"id"`
|
|
Username string `json:"username"`
|
|
Email string `json:"email"`
|
|
}
|