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" "wechat-api/ent/custom_types" ) type UsageDetail struct { ent.Schema } func (UsageDetail) Fields() []ent.Field { return []ent.Field{ field.Int("type").Optional().Default(1). Annotations(entsql.WithComments(true)). Comment("1 微信 2 名片"), field.String("bot_id").Default(""). Annotations(entsql.WithComments(true)). Comment("微信或名片id"), field.String("receiver_id").Default(""). Annotations(entsql.WithComments(true)). Comment("微信id或open_id"), field.Int("app").Optional().Default(1). Annotations(entsql.WithComments(true)). Comment("1 cow-basic 2 cow-agent 3 cow-sop 4 mp-card 5 mp-employee"), field.Uint64("session_id").Optional().Default(1). Comment("名片会话id"). Annotations(entsql.WithComments(true)), field.String("request").Default(""). Annotations(entsql.WithComments(true)). Comment("请求内容"), field.String("response").Default(""). Annotations(entsql.WithComments(true)). Comment("响应内容"), field.JSON("original_data", custom_types.OriginalData{}). Annotations(entsql.WithComments(true)). Comment("原始数据"), field.Uint64("total_tokens").Optional().Default(0). Annotations(entsql.WithComments(true)). Comment("使用token总数"), field.Uint64("prompt_tokens").Optional().Default(0). Annotations(entsql.WithComments(true)). Comment("请求token数"), field.Uint64("completion_tokens").Optional().Default(0). Annotations(entsql.WithComments(true)). Comment("响应token数"), field.Uint64("organization_id").Optional().Default(1). Comment("机构 ID"). Annotations(entsql.WithComments(true)), } } func (UsageDetail) Mixin() []ent.Mixin { return []ent.Mixin{ mixins.IDMixin{}, mixins.StatusMixin{}, } } func (UsageDetail) Indexes() []ent.Index { return []ent.Index{ index.Fields("bot_id"), index.Fields("organization_id"), } } func (UsageDetail) Edges() []ent.Edge { return []ent.Edge{} } func (UsageDetail) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.WithComments(true), entsql.Annotation{Table: "usage_detail"}, } }