171 lines
8.4 KiB
Go
171 lines
8.4 KiB
Go
|
package models
|
|||
|
|
|||
|
import (
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
const (
|
|||
|
AnnouncementMessageType = 1 // 公告消息
|
|||
|
|
|||
|
TargetTypeByAll = 1 // 接收对象类型:1=全员
|
|||
|
TargetTypeByRole = 2 // 接收对象类型:2=角色
|
|||
|
TargetTypeByUser = 3 // 接收对象类型:3=用户
|
|||
|
|
|||
|
MessageStatusOnDraft = 0 // 草稿
|
|||
|
MessageStatusOnStart = 1 // 启用
|
|||
|
MessageStatusOnDisable = 2 // 禁用
|
|||
|
MessageStatusOnExpire = 3 // 已过期
|
|||
|
|
|||
|
MessageStart = 1 // 启用
|
|||
|
MessageStop = 2 // 禁用
|
|||
|
)
|
|||
|
|
|||
|
// SystemMessageConfig 消息配置主表(公告 + 业务统一)
|
|||
|
type SystemMessageConfig struct {
|
|||
|
Model
|
|||
|
|
|||
|
MessageType uint8 `json:"message_type"` // 消息类型:1=公告,2=业务
|
|||
|
Title string `json:"title"` // 消息标题
|
|||
|
ContentTemplate string `json:"content_template"` // 消息模板内容,支持{{变量}}
|
|||
|
Level uint8 `json:"level"` // 消息等级:1=普通,2=重要,3=紧急
|
|||
|
DisplayMode uint8 `json:"display_mode"` // 展示方式:1=弹窗,2=滚动,3=弹窗+滚动
|
|||
|
StartTime *time.Time `json:"start_time,omitempty"` // 公告生效时间
|
|||
|
EndTime *time.Time `json:"end_time,omitempty"` // 公告失效时间
|
|||
|
BizType string `json:"biz_type,omitempty"` // 业务类型
|
|||
|
Event string `json:"event,omitempty"` // 事件类型
|
|||
|
Status uint8 `json:"status"` // 状态:0=草稿,1=启用,2=禁用,3=已过期
|
|||
|
}
|
|||
|
|
|||
|
// SystemMessageTarget 接收对象配置表(支持角色/部门/用户/全员)
|
|||
|
type SystemMessageTarget struct {
|
|||
|
Model
|
|||
|
|
|||
|
MessageConfigID uint `json:"message_config_id"` // 对应消息配置 ID
|
|||
|
TargetType uint8 `json:"target_type"` // 接收对象类型:1=全员,2=角色,3=用户
|
|||
|
TargetID int64 `json:"target_id,omitempty"` // 对象ID(角色ID/用户ID)
|
|||
|
}
|
|||
|
|
|||
|
// SystemEventRegistry 业务事件注册表(用于事件枚举管理)
|
|||
|
type SystemEventRegistry struct {
|
|||
|
Model
|
|||
|
|
|||
|
BizType string `json:"biz_type"` // 业务类型
|
|||
|
Event string `json:"event"` // 事件名
|
|||
|
BizName string `json:"biz_name"` // 业务名称(展示用)
|
|||
|
EventName string `json:"event_name"` // 事件名称(展示用)
|
|||
|
Description string `json:"description"` // 说明
|
|||
|
TemplateVariables string `json:"template_variables"` // 可用变量 JSON 字符串
|
|||
|
IsEnabled bool `json:"is_enabled"` // 是否启用
|
|||
|
}
|
|||
|
|
|||
|
// SystemUserMessage 用户收到的消息记录表(实际发送记录)
|
|||
|
type SystemUserMessage struct {
|
|||
|
Model
|
|||
|
|
|||
|
UserID int64 `json:"user_id"` // 接收用户ID
|
|||
|
MessageConfigID uint `json:"message_config_id"` // 对应消息配置ID,可为空(被删时保留记录)
|
|||
|
MessageType uint8 `json:"message_type"` // 消息类型:1=公告,2=业务
|
|||
|
Title string `json:"title"` // 消息标题快照
|
|||
|
Content string `json:"content"` // 渲染后内容
|
|||
|
IsRead bool `json:"is_read"` // 是否阅读
|
|||
|
ReadTime *time.Time `json:"read_time,omitempty"` // 阅读时间
|
|||
|
IsVisible bool `json:"is_visible"` // 是否展示给用户
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageCreateReq 新增公告请求结构体
|
|||
|
type SysMessageCreateReq struct {
|
|||
|
Title string `json:"title" binding:"required"` // 消息标题
|
|||
|
ContentTemplate string `json:"content_template" binding:"required"` // 消息内容
|
|||
|
Level uint8 `json:"level" binding:"required,oneof=1 2 3"` // 消息等级:1=普通,2=重要,3=紧急
|
|||
|
DisplayMode uint8 `json:"display_mode" binding:"required,oneof=1 2 3"` // 展示方式:1=弹窗,2=滚动,3=弹窗+滚动
|
|||
|
StartTime string `json:"start_time,omitempty"` // 公告生效时间
|
|||
|
EndTime string `json:"end_time,omitempty"` // 公告失效时间
|
|||
|
Status uint8 `json:"status" binding:"required,oneof=0 1"` // 状态:0=草稿,1=启用
|
|||
|
TargetType uint8 `json:"target_type" binding:"required,oneof=1 2 3"` // 接收对象类型:1=全员,2=角色,3=用户
|
|||
|
TargetID int64 `json:"target_id,omitempty"` // 对象ID(角色ID/用户ID)
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageCreateResp 创建成功响应
|
|||
|
type SysMessageCreateResp struct {
|
|||
|
ID uint32 `json:"id"`
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageEditReq 编辑公告消息-入参
|
|||
|
type SysMessageEditReq struct {
|
|||
|
ID uint `json:"id" binding:"required"` // 公告ID(必须)
|
|||
|
Title string `json:"title" binding:"required"` // 标题
|
|||
|
ContentTemplate string `json:"content_template" binding:"required"` // 内容模板
|
|||
|
Level uint8 `json:"level" binding:"required,oneof=1 2 3"` // 重要等级
|
|||
|
DisplayMode uint8 `json:"display_mode" binding:"required,oneof=1 2 3"` // 展示模式
|
|||
|
StartTime string `json:"start_time"` // 生效时间(可空)
|
|||
|
EndTime string `json:"end_time"` // 失效时间(可空)
|
|||
|
Status uint8 `json:"status" binding:"required,oneof=0 1"` // 状态:0 草稿、1 启用
|
|||
|
TargetType uint8 `json:"target_type" binding:"required,oneof=1 2 3"` // 接收对象类型:1=全员,2=角色,3=用户
|
|||
|
TargetID int64 `json:"target_id,omitempty"` // 接收对象ID
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageListReq 公告消息列表-入参
|
|||
|
type SysMessageListReq struct {
|
|||
|
Title string `form:"title"` // 消息标题
|
|||
|
Level uint8 `form:"level"` // 消息等级:1=普通,2=重要,3=紧急
|
|||
|
DisplayMode uint8 `form:"display_mode"` // 展示方式:1=弹窗,2=滚动,3=弹窗+滚动
|
|||
|
Status uint8 `form:"status"` // 状态:0=草稿,1=启用,2=禁用,3=已过期
|
|||
|
TargetType uint8 `form:"target_type"` // 从接收对象配置表中筛选
|
|||
|
Page int `form:"page,default=1"` // 页码
|
|||
|
PageSize int `form:"page_size,default=10"` // 每页条数
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageListResp 公告消息列表-出参
|
|||
|
type SysMessageListResp struct {
|
|||
|
List []SysAnnouncementItem `json:"list"`
|
|||
|
Total int64 `json:"total"` // 总条数
|
|||
|
Page int `json:"page"` // 页码
|
|||
|
PageSize int `json:"page_size"` // 每页条数
|
|||
|
}
|
|||
|
|
|||
|
// SysAnnouncementItem 公告消息展示结构体
|
|||
|
type SysAnnouncementItem struct {
|
|||
|
ID uint32 `json:"id"`
|
|||
|
CreatedAt time.Time `json:"created_at"`
|
|||
|
UpdatedAt time.Time `json:"updated_at"`
|
|||
|
Title string `json:"title"` // 消息标题
|
|||
|
ContentTemplate string `json:"content_template"` // 消息内容
|
|||
|
Level uint8 `json:"level"` // 消息等级:1=普通,2=重要,3=紧急
|
|||
|
DisplayMode uint8 `json:"display_mode"` // 展示方式:1=弹窗,2=滚动,3=弹窗+滚动
|
|||
|
StartTime *time.Time `json:"start_time,omitempty"` // 公告生效时间
|
|||
|
EndTime *time.Time `json:"end_time,omitempty"` // 公告失效时间
|
|||
|
Status uint8 `json:"status"` // 状态:0=草稿,1=启用,2=禁用,3=已过期
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageSetStatusReq 设置公告消息状态
|
|||
|
type SysMessageSetStatusReq struct {
|
|||
|
ID uint `json:"id" binding:"required"`
|
|||
|
Status uint8 `json:"status" binding:"required"` // 目标状态:1=启用,2=禁用
|
|||
|
}
|
|||
|
|
|||
|
// SysMessageDeleteReq 删除公告消息
|
|||
|
type SysMessageDeleteReq struct {
|
|||
|
ID uint `json:"id" binding:"required"`
|
|||
|
}
|
|||
|
|
|||
|
// UserMessageListReq 用户消息列表-入参
|
|||
|
type UserMessageListReq struct {
|
|||
|
IsRead int `json:"is_read"` // 0-未读;1-已读
|
|||
|
Page int `json:"page"` // 页码
|
|||
|
PageSize int `json:"page_size"` // 每页数量
|
|||
|
}
|
|||
|
|
|||
|
// UserMessageListResp 用户消息列表-出参
|
|||
|
type UserMessageListResp struct {
|
|||
|
List []SystemUserMessage `json:"list"`
|
|||
|
Total int64 `json:"total"`
|
|||
|
Page int `json:"page"`
|
|||
|
PageSize int `json:"page_size"`
|
|||
|
}
|
|||
|
|
|||
|
// UserMessageSetStatusReq 用户阅读消息-入参
|
|||
|
type UserMessageSetStatusReq struct {
|
|||
|
ID uint `json:"id"` // 消息ID(可选,read_all 为 false 时必传)
|
|||
|
ReadAll bool `json:"read_all"` // 是否设为全部已读
|
|||
|
}
|