notice_personal.go 2.7 KB
package domain

import "time"

const (
	NoticePersonalIsNotRead = 1
	NoticePersonalIsRead    = 2
)

// 个人消息通知内容
type NoticePersonal struct {
	// 编号id
	NoticePersonalId int64 `json:"noticePersonalId"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 发送通知时的扩展参数
	Extend string `json:"extend"`
	// 公司id
	CompanyId int64 `json:"companyId"`
	// 内容模板
	Content string `json:"content"`
	// 是否已读【1:未读】【2:已读】
	IsRead int `json:"isRead"`
	// 消息对应的业务模块
	Module string `json:"module"`
	// 业务环节
	ModuleAction string `json:"moduleAction"`
	//账号id
	UserBaseId int64 `json:"userBaseId"`
	// 组织id
	OrgId int64 `json:"orgId"`
	// 接收方用户id
	UserId int64 `json:"userId"`
}

type NoticePersonalRepository interface {
	Save(noticePersonal *NoticePersonal) (*NoticePersonal, error)
	Remove(noticePersonal *NoticePersonal) (*NoticePersonal, error)
	FindOne(queryOptions map[string]interface{}) (*NoticePersonal, error)
	Find(queryOptions map[string]interface{}) (int64, []*NoticePersonal, error)
}

func (noticePersonal *NoticePersonal) Identify() interface{} {
	if noticePersonal.NoticePersonalId == 0 {
		return nil
	}
	return noticePersonal.NoticePersonalId
}

func (noticePersonal *NoticePersonal) Update(data map[string]interface{}) error {
	if createdAt, ok := data["createdAt"]; ok {
		noticePersonal.CreatedAt = createdAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		noticePersonal.DeletedAt = deletedAt.(time.Time)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		noticePersonal.UpdatedAt = updatedAt.(time.Time)
	}
	if extend, ok := data["extend"]; ok {
		noticePersonal.Extend = extend.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		noticePersonal.CompanyId = companyId.(int64)
	}
	if content, ok := data["content"]; ok {
		noticePersonal.Content = content.(string)
	}
	if isRead, ok := data["isRead"]; ok {
		noticePersonal.IsRead = isRead.(int)
	}
	if module, ok := data["module"]; ok {
		noticePersonal.Module = module.(string)
	}
	if moduleAction, ok := data["moduleAction"]; ok {
		noticePersonal.ModuleAction = moduleAction.(string)
	}
	if noticePersonalId, ok := data["noticePersonalId"]; ok {
		noticePersonal.NoticePersonalId = noticePersonalId.(int64)
	}
	if organizationId, ok := data["organizationId"]; ok {
		noticePersonal.OrgId = organizationId.(int64)
	}

	if userId, ok := data["userId"]; ok {
		noticePersonal.UserId = userId.(int64)
	}
	if userId, ok := data["userBaseId"]; ok {
		noticePersonal.UserBaseId = userId.(int64)
	}
	return nil
}