package model

import (
	"time"

	"gorm.io/datatypes"
)

// WeComMember 是企业微信应用可见成员的本地选择快照，不承担组织模型职责。
type WeComMember struct {
	ID            uint           `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	ApplicationID uint           `gorm:"column:application_id;not null;uniqueIndex:uq_wecom_member_identity,priority:1" json:"application_id"`
	CorpID        string         `gorm:"column:corp_id;type:varchar(64);not null" json:"corp_id"`
	UserID        string         `gorm:"column:userid;type:varchar(64);not null;uniqueIndex:uq_wecom_member_identity,priority:2" json:"userid"`
	Name          string         `gorm:"column:name;type:varchar(100);not null" json:"name"`
	DepartmentIDs datatypes.JSON `gorm:"column:department_ids;type:jsonb;not null;default:'[]'" json:"department_ids"`
	Visible       bool           `gorm:"column:visible;not null;default:true;index" json:"visible"`
	SyncedAt      time.Time      `gorm:"column:synced_at;type:timestamptz;not null" json:"synced_at"`
	CreatedAt     time.Time      `gorm:"column:created_at;type:timestamptz;not null;autoCreateTime" json:"created_at"`
	UpdatedAt     time.Time      `gorm:"column:updated_at;type:timestamptz;not null;autoUpdateTime" json:"updated_at"`
}

// TableName 指定企业微信可见成员快照表名。
func (WeComMember) TableName() string {
	return "tb_wecom_member"
}
