123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package schema
- import (
- "wechat-api/ent/schema/localmixin"
- "entgo.io/ent"
- "entgo.io/ent/dialect/entsql"
- "entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
- "entgo.io/ent/schema/field"
- "entgo.io/ent/schema/index"
- "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
- )
- type Wx struct {
- ent.Schema
- }
- func (Wx) Fields() []ent.Field {
- return []ent.Field{
- field.Uint64("server_id").Optional().Default(0).
- Annotations(entsql.WithComments(true)).
- Comment("服务器id"),
- field.String("port").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("端口号"),
- field.String("process_id").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("进程号"),
- field.String("callback").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("回调地址"),
- field.String("wxid").Default("").
- Default("").
- Annotations(entsql.WithComments(true)).
- Comment("微信id"),
- field.String("account").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("微信账号"),
- field.String("nickname").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("微信昵称"),
- field.String("tel").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("手机号"),
- field.String("head_big").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("微信头像"),
- field.Uint64("organization_id").Optional().Default(1).
- Comment("机构 ID").
- Annotations(entsql.WithComments(true)),
- field.Uint64("agent_id").Default(0).
- Comment("模式ID").
- Annotations(entsql.WithComments(true)),
- field.String("api_base").Optional().Default("").
- Annotations(entsql.WithComments(true)).
- Comment("大模型服务地址"),
- field.String("api_key").Optional().Default("").
- Annotations(entsql.WithComments(true)).
- Comment("大模型服务密钥"),
- field.JSON("allow_list", []string{}).
- Annotations(entsql.WithComments(true)).
- Comment("白名单"),
- field.JSON("group_allow_list", []string{}).
- Annotations(entsql.WithComments(true)).
- Comment("群白名单"),
- field.JSON("block_list", []string{}).
- Annotations(entsql.WithComments(true)).
- Comment("黑名单"),
- field.JSON("group_block_list", []string{}).
- Annotations(entsql.WithComments(true)).
- Comment("群黑名单"),
- }
- }
- func (Wx) Mixin() []ent.Mixin {
- return []ent.Mixin{
- mixins.IDMixin{},
- mixins.StatusMixin{},
- localmixin.SoftDeleteMixin{},
- }
- }
- func (Wx) Indexes() []ent.Index {
- return []ent.Index{
- index.Fields("server_id", "port").Unique(),
- index.Fields("wxid").Unique(),
- index.Fields("account"),
- index.Fields("nickname"),
- index.Fields("tel"),
- }
- }
- func (Wx) Edges() []ent.Edge {
- return []ent.Edge{
- edge.From("server", Server.Type).Ref("wxs").Unique().Field("server_id"),
- edge.From("agent", Agent.Type).
- Ref("wx_agent").
- Unique().
- Field("agent_id").
- Required(),
- }
- }
- func (Wx) Annotations() []schema.Annotation {
- return []schema.Annotation{
- entsql.WithComments(true),
- entsql.Annotation{Table: "wx"},
- }
- }
|