49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
|  | package model | ||
|  | 
 | ||
|  | import ( | ||
|  | 	"admin/apps/game/model/dto" | ||
|  | 	"admin/internal/db" | ||
|  | 	"gorm.io/gorm" | ||
|  | 	"time" | ||
|  | ) | ||
|  | 
 | ||
|  | func init() { | ||
|  | 	db.RegisterTableModels(RoleMail{}) | ||
|  | } | ||
|  | 
 | ||
|  | type MailAttachItem struct { | ||
|  | 	ID       int32 `json:"id"` | ||
|  | 	Num      int64 `json:"num"` | ||
|  | 	ItemType int   `json:"item_type"` | ||
|  | } | ||
|  | 
 | ||
|  | type RoleMail struct { | ||
|  | 	ID        int `gorm:"primarykey" readonly:"true"` | ||
|  | 	ProjectId string | ||
|  | 	RoleIDs   []string          `gorm:"type:json;serializer:json" name:"生效的角色id" required:"true"` | ||
|  | 	ServerID  string            `name:"所属区服" choices:"GetChoiceServers" multi_choice:"false"` | ||
|  | 	Title     string            `name:"邮件标题" required:"true"` | ||
|  | 	Content   string            `name:"邮件内容" required:"true"` | ||
|  | 	Attach    []*MailAttachItem `gorm:"type:json;serializer:json" name:"邮件附件" type:"items" choices:"GetChoiceItems"` | ||
|  | 
 | ||
|  | 	CreatedAt time.Time      `readonly:"true"` | ||
|  | 	UpdatedAt time.Time      `readonly:"true"` | ||
|  | 	DeletedAt gorm.DeletedAt `gorm:"index" readonly:"true"` | ||
|  | } | ||
|  | 
 | ||
|  | func (lm *RoleMail) TableName() string { | ||
|  | 	return "mail_role" | ||
|  | } | ||
|  | 
 | ||
|  | func (m *RoleMail) GetId() int { | ||
|  | 	return m.ID | ||
|  | } | ||
|  | 
 | ||
|  | func (m *RoleMail) GetChoiceServers(projectId string) []*dto.CommonDtoFieldChoice { | ||
|  | 	return getChoiceServers(projectId) | ||
|  | } | ||
|  | 
 | ||
|  | func (m *RoleMail) GetChoiceItems(projectId string) []*dto.CommonDtoFieldChoice { | ||
|  | 	return ProjectsAllItems[projectId] | ||
|  | } |