// ========================================================================== // GFast自动生成model操作代码。 // 生成日期:2024-04-11 16:56:36 // 生成路径: internal/app/system/model/notifications.go // 生成人:gfast // desc:通知信息 // company:云南奇讯科技有限公司 // ========================================================================== package model import ( "strings" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/util/gmeta" "github.com/samber/lo" ) // NotificationsInfoRes is the golang structure for table notifications. type NotificationsInfoRes struct { gmeta.Meta `orm:"table:notifications"` Id uint `orm:"id,primary" json:"id"` // CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` // NotificationText string `orm:"notification_text" json:"notificationText"` // 通知正文 Route string `orm:"route" json:"route"` // 跳转的路由 NotificationTime string `orm:"notification_time" json:"notificationTime"` // 通知时间 Initiator int `orm:"initiator" json:"initiator"` // 发起人 ProjectId int `orm:"project_id" json:"projectId"` // 项目ID Title string `orm:"title" json:"title"` // 标题 // 消息发起者名 InitiatorName string `json:"initiatorName" orm:"initiator_nickname"` // recipients_nickname 收件人昵称 RecipientsNam string `json:"recipientsName" orm:"recipients_nickname"` // positions Position string `json:"positions" orm:"positions"` } func (m *NotificationsInfoRes) Positions() []string { return lo.Compact(strings.Split(m.Position, ",")) } func (m *NotificationsInfoRes) RecipientsName() []string { return lo.Compact(strings.Split(m.RecipientsNam, ",")) } type NotificationsListRes struct { Id uint `json:"id"` CreatedAt *gtime.Time `json:"createdAt"` NotificationText string `json:"notificationText"` Route string `json:"route"` NotificationTime string `json:"notificationTime"` Initiator int `json:"initiator"` ProjectId int `json:"projectId"` Title string `json:"title"` // 消息发起者名 InitiatorName string `json:"initiatorName" orm:"initiator_nickname"` RecipientsName []string `json:"recipientsName" orm:"recipients_nickname"` Positions []string `json:"positions" orm:"positions"` } // 用户详情 type NotificationsGetRes struct { Id uint `json:"id" orm:"recipient_id" dc:"用户ID"` // 用户ID Avatar string `json:"avatar" orm:"avatar" dc:"头像"` // 头像 Username string `json:"username" orm:"user_nickname" dc:"用户名"` // 用户名 OrmMobile string `orm:"mobile"` FacePhoto string `json:"facePhoto" orm:"pace_photo" dc:"实名人脸照"` ReadTime string `json:"readTime" orm:"read_time" dc:"已读时间"` // 已读时间 NotificationStatus int `json:"notificationStatus" orm:"notification_status" dc:"0 未读 | 1 已读"` // 0 未读 | 1 已读 } func (n *NotificationsGetRes) Avatars() string { // if n.FacePhoto != "" { // return n.FacePhoto // } // return n.Avatar return n.FacePhoto } // model 通知信息 type Notifications struct { Id string `p:"id" orm:"id"` // 消息ID Route string `p:"route" orm:"route"` // 跳转的路由 NotificationTitle string `p:"title" orm:"title"` // 标题 NotificationText string `p:"notificationText" orm:"notification_text"` // 通知正文 NotificationTime string `p:"notificationTime" orm:"notification_time"` // 通知时间 NotificationStatus string `p:"notification_status" orm:"notification_status"` // 通知状态 Initiator string `p:"initiator" orm:"user_nickname" dc:"发起人"` // 发起人 Files []FileInfo `p:"files" orm:"files"` // 附件 Users []NotificationsGetRes `p:"users" orm:"users"` // 通知人员 } type FileInfo struct { Name string `orm:"file_name" json:"name" dc:"文件名"` Url string `orm:"file_path" json:"url" dc:"文件路径"` FileType string `orm:"file_type" json:"fileType" dc:"文件类型"` Size uint64 `orm:"file_size" json:"size" dc:"文件大小"` }