支持管理员配置上游错误如何返回给客户端: - 新增 ErrorPassthroughRule 数据模型和 Ent Schema - 实现规则的 CRUD API(/admin/error-passthrough-rules) - 支持按错误码、关键词匹配,支持 any/all 匹配模式 - 支持按平台过滤(anthropic/openai/gemini/antigravity) - 支持透传或自定义响应状态码和错误消息 - 实现两级缓存(Redis + 本地内存)和多实例同步 - 集成到 gateway_handler 的错误处理流程 - 新增前端管理界面组件 - 新增单元测试覆盖核心匹配逻辑 优化: - 移除 refreshLocalCache 中的冗余排序(数据库已排序) - 后端 Validate() 增加匹配条件非空校验
162 lines
6.0 KiB
Go
162 lines
6.0 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package errorpassthroughrule
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
const (
|
|
// Label holds the string label denoting the errorpassthroughrule type in the database.
|
|
Label = "error_passthrough_rule"
|
|
// FieldID holds the string denoting the id field in the database.
|
|
FieldID = "id"
|
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
|
FieldCreatedAt = "created_at"
|
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
|
FieldUpdatedAt = "updated_at"
|
|
// FieldName holds the string denoting the name field in the database.
|
|
FieldName = "name"
|
|
// FieldEnabled holds the string denoting the enabled field in the database.
|
|
FieldEnabled = "enabled"
|
|
// FieldPriority holds the string denoting the priority field in the database.
|
|
FieldPriority = "priority"
|
|
// FieldErrorCodes holds the string denoting the error_codes field in the database.
|
|
FieldErrorCodes = "error_codes"
|
|
// FieldKeywords holds the string denoting the keywords field in the database.
|
|
FieldKeywords = "keywords"
|
|
// FieldMatchMode holds the string denoting the match_mode field in the database.
|
|
FieldMatchMode = "match_mode"
|
|
// FieldPlatforms holds the string denoting the platforms field in the database.
|
|
FieldPlatforms = "platforms"
|
|
// FieldPassthroughCode holds the string denoting the passthrough_code field in the database.
|
|
FieldPassthroughCode = "passthrough_code"
|
|
// FieldResponseCode holds the string denoting the response_code field in the database.
|
|
FieldResponseCode = "response_code"
|
|
// FieldPassthroughBody holds the string denoting the passthrough_body field in the database.
|
|
FieldPassthroughBody = "passthrough_body"
|
|
// FieldCustomMessage holds the string denoting the custom_message field in the database.
|
|
FieldCustomMessage = "custom_message"
|
|
// FieldDescription holds the string denoting the description field in the database.
|
|
FieldDescription = "description"
|
|
// Table holds the table name of the errorpassthroughrule in the database.
|
|
Table = "error_passthrough_rules"
|
|
)
|
|
|
|
// Columns holds all SQL columns for errorpassthroughrule fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldCreatedAt,
|
|
FieldUpdatedAt,
|
|
FieldName,
|
|
FieldEnabled,
|
|
FieldPriority,
|
|
FieldErrorCodes,
|
|
FieldKeywords,
|
|
FieldMatchMode,
|
|
FieldPlatforms,
|
|
FieldPassthroughCode,
|
|
FieldResponseCode,
|
|
FieldPassthroughBody,
|
|
FieldCustomMessage,
|
|
FieldDescription,
|
|
}
|
|
|
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
|
func ValidColumn(column string) bool {
|
|
for i := range Columns {
|
|
if column == Columns[i] {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
var (
|
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
|
DefaultCreatedAt func() time.Time
|
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
|
DefaultUpdatedAt func() time.Time
|
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
|
UpdateDefaultUpdatedAt func() time.Time
|
|
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
|
NameValidator func(string) error
|
|
// DefaultEnabled holds the default value on creation for the "enabled" field.
|
|
DefaultEnabled bool
|
|
// DefaultPriority holds the default value on creation for the "priority" field.
|
|
DefaultPriority int
|
|
// DefaultMatchMode holds the default value on creation for the "match_mode" field.
|
|
DefaultMatchMode string
|
|
// MatchModeValidator is a validator for the "match_mode" field. It is called by the builders before save.
|
|
MatchModeValidator func(string) error
|
|
// DefaultPassthroughCode holds the default value on creation for the "passthrough_code" field.
|
|
DefaultPassthroughCode bool
|
|
// DefaultPassthroughBody holds the default value on creation for the "passthrough_body" field.
|
|
DefaultPassthroughBody bool
|
|
)
|
|
|
|
// OrderOption defines the ordering options for the ErrorPassthroughRule queries.
|
|
type OrderOption func(*sql.Selector)
|
|
|
|
// ByID orders the results by the id field.
|
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByCreatedAt orders the results by the created_at field.
|
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUpdatedAt orders the results by the updated_at field.
|
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByName orders the results by the name field.
|
|
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldName, opts...).ToFunc()
|
|
}
|
|
|
|
// ByEnabled orders the results by the enabled field.
|
|
func ByEnabled(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldEnabled, opts...).ToFunc()
|
|
}
|
|
|
|
// ByPriority orders the results by the priority field.
|
|
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldPriority, opts...).ToFunc()
|
|
}
|
|
|
|
// ByMatchMode orders the results by the match_mode field.
|
|
func ByMatchMode(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldMatchMode, opts...).ToFunc()
|
|
}
|
|
|
|
// ByPassthroughCode orders the results by the passthrough_code field.
|
|
func ByPassthroughCode(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldPassthroughCode, opts...).ToFunc()
|
|
}
|
|
|
|
// ByResponseCode orders the results by the response_code field.
|
|
func ByResponseCode(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldResponseCode, opts...).ToFunc()
|
|
}
|
|
|
|
// ByPassthroughBody orders the results by the passthrough_body field.
|
|
func ByPassthroughBody(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldPassthroughBody, opts...).ToFunc()
|
|
}
|
|
|
|
// ByCustomMessage orders the results by the custom_message field.
|
|
func ByCustomMessage(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldCustomMessage, opts...).ToFunc()
|
|
}
|
|
|
|
// ByDescription orders the results by the description field.
|
|
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldDescription, opts...).ToFunc()
|
|
}
|