package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)

type WpChatroom struct {
	ent.Schema
}

func (WpChatroom) Fields() []ent.Field {
	return []ent.Field{
		field.String("wx_wxid").Default("").
			Default("").
			Annotations(entsql.WithComments(true)).
			Comment("所属微信id"),
		field.String("chatroom_id").Default("").
			Annotations(entsql.WithComments(true)).
			Comment("群id"),
		field.String("nickname").Default("").
			Annotations(entsql.WithComments(true)).
			Comment("群昵称"),
		field.String("owner").Default("").
			Annotations(entsql.WithComments(true)).
			Comment("群主"),
		field.String("avatar").Default("").
			Annotations(entsql.WithComments(true)).
			Comment("群头像"),
		field.JSON("member_list", []string{}).
			Annotations(entsql.WithComments(true)).
			Comment("群成员"),
	}
}

func (WpChatroom) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixins.IDMixin{},
		mixins.StatusMixin{},
	}
}

func (WpChatroom) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("wx_wxid", "chatroom_id"),
	}
}

func (WpChatroom) Edges() []ent.Edge { return []ent.Edge{} }

func (WpChatroom) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		entsql.Annotation{Table: "wp_chatroom"},
	}
}
