Files
junhong_cmp_fiber/internal/model/dto/notification_dto.go
2026-07-24 16:07:18 +08:00

95 lines
5.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package dto
import "time"
// NotificationUnreadCountResponse 是后台账号未读数投影。
type NotificationUnreadCountResponse struct {
Count int64 `json:"count" description:"未读通知数量"`
DisplayCount string `json:"display_count" description:"徽标显示文本,超过 99 时为 99+"`
}
// NotificationListRequest 是后台通知基础分页参数。
type NotificationListRequest struct {
Category string `json:"category" query:"category" validate:"omitempty,oneof=approval expiry sync system" enums:"approval,expiry,sync,system" description:"通知类别 (approval:审批, expiry:临期, sync:同步, system:系统)"`
Type string `json:"type" query:"type" validate:"omitempty,max=100" maxlength:"100" description:"稳定通知类型"`
Severity string `json:"severity" query:"severity" validate:"omitempty,oneof=info warning error critical" enums:"info,warning,error,critical" description:"通知级别 (info:提示, warning:警告, error:错误, critical:严重)"`
IsRead *bool `json:"is_read" query:"is_read" description:"已读状态;不传时查询全部"`
Page int `json:"page" query:"page" validate:"omitempty,min=1,max=10000" minimum:"1" maximum:"10000" description:"页码,默认 1最大 10000"`
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=50" minimum:"1" maximum:"50" description:"每页数量,默认 20最大 50"`
}
// NotificationItem 是后台账号可见的站内通知投影。
type NotificationItem struct {
ID uint `json:"id" description:"通知ID"`
Category string `json:"category" description:"通知类别 (approval:审批, expiry:临期, sync:同步, system:系统)"`
Type string `json:"type" description:"稳定通知类型"`
Severity string `json:"severity" description:"通知级别 (info:提示, warning:警告, error:错误, critical:严重)"`
Title string `json:"title" description:"纯文本标题"`
Body string `json:"body" description:"纯文本正文"`
RefType string `json:"ref_type" description:"受控资源类型"`
RefID string `json:"ref_id" description:"受控资源ID"`
RefKey string `json:"ref_key" description:"受控资源Key"`
IsRead bool `json:"is_read" description:"是否已读"`
ReadAt *time.Time `json:"read_at,omitempty" description:"首次已读时间ISO 8601"`
CreatedAt time.Time `json:"created_at" description:"创建时间ISO 8601"`
}
// NotificationListResponse 是后台通知基础分页结果。
type NotificationListResponse struct {
Items []NotificationItem `json:"items" description:"通知列表"`
Total int64 `json:"total" description:"总数量"`
Page int `json:"page" description:"页码"`
Size int `json:"size" description:"每页数量"`
}
// NotificationIDParams 是单条通知路径参数。
type NotificationIDParams struct {
ID uint `json:"id" path:"id" required:"true" description:"通知ID"`
}
// NotificationReadResponse 是单条通知幂等已读结果。
type NotificationReadResponse struct {
Success bool `json:"success" description:"请求是否成功;通知不存在、属于别人或已经已读也返回 true"`
}
// NotificationTargetResponse 是通知受控目标解析结果,不包含任意 URL。
type NotificationTargetResponse struct {
TargetType string `json:"target_type" description:"前端白名单目标类型;空表示不支持跳转"`
TargetID *uint `json:"target_id,omitempty" description:"受控数值目标ID"`
TargetKey string `json:"target_key,omitempty" description:"受控稳定目标Key"`
Available bool `json:"available" description:"当前账号是否仍可访问目标"`
}
// NotificationUnreadSummaryResponse 是后台账号未读通知的固定分类汇总。
type NotificationUnreadSummaryResponse struct {
Total int64 `json:"total" description:"未读通知总数"`
Approval int64 `json:"approval" description:"审批类未读数量"`
Expiry int64 `json:"expiry" description:"临期类未读数量"`
Sync int64 `json:"sync" description:"同步类未读数量"`
System int64 `json:"system" description:"系统类未读数量"`
}
// NotificationReadAllRequest 是后台批量已读请求。
type NotificationReadAllRequest struct {
Category string `json:"category" validate:"omitempty,oneof=approval expiry sync system" enums:"approval,expiry,sync,system" description:"可选通知类别 (approval:审批, expiry:临期, sync:同步, system:系统)"`
}
// NotificationReadAllResponse 是后台批量已读结果。
type NotificationReadAllResponse struct {
UpdatedCount int64 `json:"updated_count" description:"本次实际更新的通知数量"`
}
// PersonalNotificationListRequest 是个人客户通知的简化分页参数。
type PersonalNotificationListRequest struct {
Page int `json:"page" query:"page" validate:"omitempty,min=1,max=10000" minimum:"1" maximum:"10000" description:"页码,默认 1最大 10000"`
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=50" minimum:"1" maximum:"50" description:"每页数量,默认 20最大 50"`
}
// PersonalNotificationListResponse 是个人客户通知的简化分页结果。
type PersonalNotificationListResponse struct {
Items []NotificationItem `json:"items" description:"当前个人客户可见的业务通知列表"`
Total int64 `json:"total" description:"总数量"`
Page int `json:"page" description:"页码"`
Size int `json:"size" description:"每页数量"`
}