notice_setting.go 2.6 KB
package domain

import "time"

// 是否推送 【是:1】【否:2】
const (
	NoticeSettingIsPush    = 1
	NoticeSettingIsNotPush = 2
)

// 编排消息通知内容
type NoticeSetting struct {
	// 消息id
	NoticeSettingId int64 `json:"noticeSettingId"`
	// 公司id
	CompanyId int64 `json:"companyId"`
	// 内容模板
	Content string `json:"content"`
	// 是否推送 【是:1】【否:2】
	IsPush int `json:"isPush"`
	// 消息对应的业务模块
	Module     string `json:"module"`
	ModuleName string `json:"moduleName"`
	// 业务环节
	ModuleAction     string `json:"moduleAction"`
	ModuleActionName string `json:"moduleActionName"`
	// 组织id
	OrgId int64 `json:"orgId"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
}

//OrgId+ModuleAction 做唯一索引

type NoticeSettingRepository interface {
	Save(noticeSetting *NoticeSetting) (*NoticeSetting, error)
	Remove(noticeSetting *NoticeSetting) (*NoticeSetting, error)
	FindOne(queryOptions map[string]interface{}) (*NoticeSetting, error)
	Find(queryOptions map[string]interface{}) (int64, []*NoticeSetting, error)
}

func (noticeSetting *NoticeSetting) Identify() interface{} {
	if noticeSetting.NoticeSettingId == 0 {
		return nil
	}
	return noticeSetting.NoticeSettingId
}

func (noticeSetting *NoticeSetting) Update(data map[string]interface{}) error {
	if companyId, ok := data["companyId"]; ok {
		noticeSetting.CompanyId = companyId.(int64)
	}
	if content, ok := data["content"]; ok {
		noticeSetting.Content = content.(string)
	}
	if isPush, ok := data["isPush"]; ok {
		noticeSetting.IsPush = isPush.(int)
	}
	if module, ok := data["module"]; ok {
		noticeSetting.Module = module.(string)
	}
	if moduleName, ok := data["moduleName"]; ok {
		noticeSetting.ModuleName = moduleName.(string)
	}
	if moduleAction, ok := data["moduleAction"]; ok {
		noticeSetting.ModuleAction = moduleAction.(string)
	}
	if moduleActionName, ok := data["moduleActionName"]; ok {
		noticeSetting.ModuleActionName = moduleActionName.(string)
	}
	if noticeSettingId, ok := data["noticeSettingId"]; ok {
		noticeSetting.NoticeSettingId = noticeSettingId.(int64)
	}
	if organizationId, ok := data["orgId"]; ok {
		noticeSetting.OrgId = organizationId.(int64)
	}
	if createdAt, ok := data["createdAt"]; ok {
		noticeSetting.CreatedAt = createdAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		noticeSetting.DeletedAt = deletedAt.(time.Time)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		noticeSetting.UpdatedAt = updatedAt.(time.Time)
	}
	return nil
}