mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-03 06:52:13 +08:00
chore: apply stashed changes
This commit is contained in:
@@ -64,6 +64,8 @@ type Group struct {
|
||||
ModelRoutingEnabled bool `json:"model_routing_enabled,omitempty"`
|
||||
// 是否注入 MCP XML 调用协议提示词(仅 antigravity 平台)
|
||||
McpXMLInject bool `json:"mcp_xml_inject,omitempty"`
|
||||
// 支持的模型系列:claude, gemini_text, gemini_image
|
||||
SupportedModelScopes []string `json:"supported_model_scopes,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the GroupQuery when eager-loading is set.
|
||||
Edges GroupEdges `json:"edges"`
|
||||
@@ -170,7 +172,7 @@ func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case group.FieldModelRouting:
|
||||
case group.FieldModelRouting, group.FieldSupportedModelScopes:
|
||||
values[i] = new([]byte)
|
||||
case group.FieldIsExclusive, group.FieldClaudeCodeOnly, group.FieldModelRoutingEnabled, group.FieldMcpXMLInject:
|
||||
values[i] = new(sql.NullBool)
|
||||
@@ -353,6 +355,14 @@ func (_m *Group) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.McpXMLInject = value.Bool
|
||||
}
|
||||
case group.FieldSupportedModelScopes:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field supported_model_scopes", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.SupportedModelScopes); err != nil {
|
||||
return fmt.Errorf("unmarshal field supported_model_scopes: %w", err)
|
||||
}
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -517,6 +527,9 @@ func (_m *Group) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mcp_xml_inject=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.McpXMLInject))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("supported_model_scopes=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.SupportedModelScopes))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ const (
|
||||
FieldModelRoutingEnabled = "model_routing_enabled"
|
||||
// FieldMcpXMLInject holds the string denoting the mcp_xml_inject field in the database.
|
||||
FieldMcpXMLInject = "mcp_xml_inject"
|
||||
// FieldSupportedModelScopes holds the string denoting the supported_model_scopes field in the database.
|
||||
FieldSupportedModelScopes = "supported_model_scopes"
|
||||
// EdgeAPIKeys holds the string denoting the api_keys edge name in mutations.
|
||||
EdgeAPIKeys = "api_keys"
|
||||
// EdgeRedeemCodes holds the string denoting the redeem_codes edge name in mutations.
|
||||
@@ -159,6 +161,7 @@ var Columns = []string{
|
||||
FieldModelRouting,
|
||||
FieldModelRoutingEnabled,
|
||||
FieldMcpXMLInject,
|
||||
FieldSupportedModelScopes,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -220,6 +223,8 @@ var (
|
||||
DefaultModelRoutingEnabled bool
|
||||
// DefaultMcpXMLInject holds the default value on creation for the "mcp_xml_inject" field.
|
||||
DefaultMcpXMLInject bool
|
||||
// DefaultSupportedModelScopes holds the default value on creation for the "supported_model_scopes" field.
|
||||
DefaultSupportedModelScopes []string
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Group queries.
|
||||
|
||||
@@ -334,6 +334,12 @@ func (_c *GroupCreate) SetNillableMcpXMLInject(v *bool) *GroupCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (_c *GroupCreate) SetSupportedModelScopes(v []string) *GroupCreate {
|
||||
_c.mutation.SetSupportedModelScopes(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
|
||||
func (_c *GroupCreate) AddAPIKeyIDs(ids ...int64) *GroupCreate {
|
||||
_c.mutation.AddAPIKeyIDs(ids...)
|
||||
@@ -511,6 +517,10 @@ func (_c *GroupCreate) defaults() error {
|
||||
v := group.DefaultMcpXMLInject
|
||||
_c.mutation.SetMcpXMLInject(v)
|
||||
}
|
||||
if _, ok := _c.mutation.SupportedModelScopes(); !ok {
|
||||
v := group.DefaultSupportedModelScopes
|
||||
_c.mutation.SetSupportedModelScopes(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -572,6 +582,9 @@ func (_c *GroupCreate) check() error {
|
||||
if _, ok := _c.mutation.McpXMLInject(); !ok {
|
||||
return &ValidationError{Name: "mcp_xml_inject", err: errors.New(`ent: missing required field "Group.mcp_xml_inject"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.SupportedModelScopes(); !ok {
|
||||
return &ValidationError{Name: "supported_model_scopes", err: errors.New(`ent: missing required field "Group.supported_model_scopes"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -691,6 +704,10 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(group.FieldMcpXMLInject, field.TypeBool, value)
|
||||
_node.McpXMLInject = value
|
||||
}
|
||||
if value, ok := _c.mutation.SupportedModelScopes(); ok {
|
||||
_spec.SetField(group.FieldSupportedModelScopes, field.TypeJSON, value)
|
||||
_node.SupportedModelScopes = value
|
||||
}
|
||||
if nodes := _c.mutation.APIKeysIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -1237,6 +1254,18 @@ func (u *GroupUpsert) UpdateMcpXMLInject() *GroupUpsert {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (u *GroupUpsert) SetSupportedModelScopes(v []string) *GroupUpsert {
|
||||
u.Set(group.FieldSupportedModelScopes, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateSupportedModelScopes sets the "supported_model_scopes" field to the value that was provided on create.
|
||||
func (u *GroupUpsert) UpdateSupportedModelScopes() *GroupUpsert {
|
||||
u.SetExcluded(group.FieldSupportedModelScopes)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
||||
// Using this option is equivalent to using:
|
||||
//
|
||||
@@ -1737,6 +1766,20 @@ func (u *GroupUpsertOne) UpdateMcpXMLInject() *GroupUpsertOne {
|
||||
})
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (u *GroupUpsertOne) SetSupportedModelScopes(v []string) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetSupportedModelScopes(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateSupportedModelScopes sets the "supported_model_scopes" field to the value that was provided on create.
|
||||
func (u *GroupUpsertOne) UpdateSupportedModelScopes() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateSupportedModelScopes()
|
||||
})
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (u *GroupUpsertOne) Exec(ctx context.Context) error {
|
||||
if len(u.create.conflict) == 0 {
|
||||
@@ -2403,6 +2446,20 @@ func (u *GroupUpsertBulk) UpdateMcpXMLInject() *GroupUpsertBulk {
|
||||
})
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (u *GroupUpsertBulk) SetSupportedModelScopes(v []string) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetSupportedModelScopes(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateSupportedModelScopes sets the "supported_model_scopes" field to the value that was provided on create.
|
||||
func (u *GroupUpsertBulk) UpdateSupportedModelScopes() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateSupportedModelScopes()
|
||||
})
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (u *GroupUpsertBulk) Exec(ctx context.Context) error {
|
||||
if u.create.err != nil {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/dialect/sql/sqljson"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/Wei-Shaw/sub2api/ent/account"
|
||||
"github.com/Wei-Shaw/sub2api/ent/apikey"
|
||||
@@ -462,6 +463,18 @@ func (_u *GroupUpdate) SetNillableMcpXMLInject(v *bool) *GroupUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (_u *GroupUpdate) SetSupportedModelScopes(v []string) *GroupUpdate {
|
||||
_u.mutation.SetSupportedModelScopes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AppendSupportedModelScopes appends value to the "supported_model_scopes" field.
|
||||
func (_u *GroupUpdate) AppendSupportedModelScopes(v []string) *GroupUpdate {
|
||||
_u.mutation.AppendSupportedModelScopes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
|
||||
func (_u *GroupUpdate) AddAPIKeyIDs(ids ...int64) *GroupUpdate {
|
||||
_u.mutation.AddAPIKeyIDs(ids...)
|
||||
@@ -891,6 +904,14 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if value, ok := _u.mutation.McpXMLInject(); ok {
|
||||
_spec.SetField(group.FieldMcpXMLInject, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.SupportedModelScopes(); ok {
|
||||
_spec.SetField(group.FieldSupportedModelScopes, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AppendedSupportedModelScopes(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, group.FieldSupportedModelScopes, value)
|
||||
})
|
||||
}
|
||||
if _u.mutation.APIKeysCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -1633,6 +1654,18 @@ func (_u *GroupUpdateOne) SetNillableMcpXMLInject(v *bool) *GroupUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (_u *GroupUpdateOne) SetSupportedModelScopes(v []string) *GroupUpdateOne {
|
||||
_u.mutation.SetSupportedModelScopes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AppendSupportedModelScopes appends value to the "supported_model_scopes" field.
|
||||
func (_u *GroupUpdateOne) AppendSupportedModelScopes(v []string) *GroupUpdateOne {
|
||||
_u.mutation.AppendSupportedModelScopes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
|
||||
func (_u *GroupUpdateOne) AddAPIKeyIDs(ids ...int64) *GroupUpdateOne {
|
||||
_u.mutation.AddAPIKeyIDs(ids...)
|
||||
@@ -2092,6 +2125,14 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
|
||||
if value, ok := _u.mutation.McpXMLInject(); ok {
|
||||
_spec.SetField(group.FieldMcpXMLInject, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.SupportedModelScopes(); ok {
|
||||
_spec.SetField(group.FieldSupportedModelScopes, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AppendedSupportedModelScopes(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, group.FieldSupportedModelScopes, value)
|
||||
})
|
||||
}
|
||||
if _u.mutation.APIKeysCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
||||
@@ -322,6 +322,7 @@ var (
|
||||
{Name: "model_routing", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}},
|
||||
{Name: "model_routing_enabled", Type: field.TypeBool, Default: false},
|
||||
{Name: "mcp_xml_inject", Type: field.TypeBool, Default: true},
|
||||
{Name: "supported_model_scopes", Type: field.TypeJSON, SchemaType: map[string]string{"postgres": "jsonb"}},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
|
||||
@@ -5542,6 +5542,8 @@ type GroupMutation struct {
|
||||
model_routing *map[string][]int64
|
||||
model_routing_enabled *bool
|
||||
mcp_xml_inject *bool
|
||||
supported_model_scopes *[]string
|
||||
appendsupported_model_scopes []string
|
||||
clearedFields map[string]struct{}
|
||||
api_keys map[int64]struct{}
|
||||
removedapi_keys map[int64]struct{}
|
||||
@@ -6843,6 +6845,57 @@ func (m *GroupMutation) ResetMcpXMLInject() {
|
||||
m.mcp_xml_inject = nil
|
||||
}
|
||||
|
||||
// SetSupportedModelScopes sets the "supported_model_scopes" field.
|
||||
func (m *GroupMutation) SetSupportedModelScopes(s []string) {
|
||||
m.supported_model_scopes = &s
|
||||
m.appendsupported_model_scopes = nil
|
||||
}
|
||||
|
||||
// SupportedModelScopes returns the value of the "supported_model_scopes" field in the mutation.
|
||||
func (m *GroupMutation) SupportedModelScopes() (r []string, exists bool) {
|
||||
v := m.supported_model_scopes
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldSupportedModelScopes returns the old "supported_model_scopes" field's value of the Group entity.
|
||||
// If the Group object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *GroupMutation) OldSupportedModelScopes(ctx context.Context) (v []string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldSupportedModelScopes is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldSupportedModelScopes requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldSupportedModelScopes: %w", err)
|
||||
}
|
||||
return oldValue.SupportedModelScopes, nil
|
||||
}
|
||||
|
||||
// AppendSupportedModelScopes adds s to the "supported_model_scopes" field.
|
||||
func (m *GroupMutation) AppendSupportedModelScopes(s []string) {
|
||||
m.appendsupported_model_scopes = append(m.appendsupported_model_scopes, s...)
|
||||
}
|
||||
|
||||
// AppendedSupportedModelScopes returns the list of values that were appended to the "supported_model_scopes" field in this mutation.
|
||||
func (m *GroupMutation) AppendedSupportedModelScopes() ([]string, bool) {
|
||||
if len(m.appendsupported_model_scopes) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
return m.appendsupported_model_scopes, true
|
||||
}
|
||||
|
||||
// ResetSupportedModelScopes resets all changes to the "supported_model_scopes" field.
|
||||
func (m *GroupMutation) ResetSupportedModelScopes() {
|
||||
m.supported_model_scopes = nil
|
||||
m.appendsupported_model_scopes = nil
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by ids.
|
||||
func (m *GroupMutation) AddAPIKeyIDs(ids ...int64) {
|
||||
if m.api_keys == nil {
|
||||
@@ -7201,7 +7254,7 @@ func (m *GroupMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *GroupMutation) Fields() []string {
|
||||
fields := make([]string, 0, 23)
|
||||
fields := make([]string, 0, 24)
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, group.FieldCreatedAt)
|
||||
}
|
||||
@@ -7271,6 +7324,9 @@ func (m *GroupMutation) Fields() []string {
|
||||
if m.mcp_xml_inject != nil {
|
||||
fields = append(fields, group.FieldMcpXMLInject)
|
||||
}
|
||||
if m.supported_model_scopes != nil {
|
||||
fields = append(fields, group.FieldSupportedModelScopes)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -7325,6 +7381,8 @@ func (m *GroupMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.ModelRoutingEnabled()
|
||||
case group.FieldMcpXMLInject:
|
||||
return m.McpXMLInject()
|
||||
case group.FieldSupportedModelScopes:
|
||||
return m.SupportedModelScopes()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -7380,6 +7438,8 @@ func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
||||
return m.OldModelRoutingEnabled(ctx)
|
||||
case group.FieldMcpXMLInject:
|
||||
return m.OldMcpXMLInject(ctx)
|
||||
case group.FieldSupportedModelScopes:
|
||||
return m.OldSupportedModelScopes(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown Group field %s", name)
|
||||
}
|
||||
@@ -7550,6 +7610,13 @@ func (m *GroupMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetMcpXMLInject(v)
|
||||
return nil
|
||||
case group.FieldSupportedModelScopes:
|
||||
v, ok := value.([]string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetSupportedModelScopes(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Group field %s", name)
|
||||
}
|
||||
@@ -7860,6 +7927,9 @@ func (m *GroupMutation) ResetField(name string) error {
|
||||
case group.FieldMcpXMLInject:
|
||||
m.ResetMcpXMLInject()
|
||||
return nil
|
||||
case group.FieldSupportedModelScopes:
|
||||
m.ResetSupportedModelScopes()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Group field %s", name)
|
||||
}
|
||||
|
||||
@@ -341,6 +341,10 @@ func init() {
|
||||
groupDescMcpXMLInject := groupFields[19].Descriptor()
|
||||
// group.DefaultMcpXMLInject holds the default value on creation for the mcp_xml_inject field.
|
||||
group.DefaultMcpXMLInject = groupDescMcpXMLInject.Default.(bool)
|
||||
// groupDescSupportedModelScopes is the schema descriptor for supported_model_scopes field.
|
||||
groupDescSupportedModelScopes := groupFields[20].Descriptor()
|
||||
// group.DefaultSupportedModelScopes holds the default value on creation for the supported_model_scopes field.
|
||||
group.DefaultSupportedModelScopes = groupDescSupportedModelScopes.Default.([]string)
|
||||
promocodeFields := schema.PromoCode{}.Fields()
|
||||
_ = promocodeFields
|
||||
// promocodeDescCode is the schema descriptor for code field.
|
||||
|
||||
@@ -115,6 +115,12 @@ func (Group) Fields() []ent.Field {
|
||||
field.Bool("mcp_xml_inject").
|
||||
Default(true).
|
||||
Comment("是否注入 MCP XML 调用协议提示词(仅 antigravity 平台)"),
|
||||
|
||||
// 支持的模型系列 (added by migration 046)
|
||||
field.JSON("supported_model_scopes", []string{}).
|
||||
Default([]string{"claude", "gemini_text", "gemini_image"}).
|
||||
SchemaType(map[string]string{dialect.Postgres: "jsonb"}).
|
||||
Comment("支持的模型系列:claude, gemini_text, gemini_image"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user