package types import ( "context" "gorm.io/gorm" "net/http" "time" ) const ( SceneCreate = "create" SceneUpdate = "update" SceneDelete = "delete" ) const ( ScenarioCreate = "create" ScenarioUpdate = "update" ScenarioDelete = "delete" ScenarioSearch = "search" ScenarioExport = "export" ScenarioImport = "import" ScenarioList = "list" ScenarioView = "view" ScenarioMapping = "mapping" ) const ( MatchExactly = "exactly" //精确匹配 MatchFuzzy = "fuzzy" //模糊匹配 ) const ( LiveTypeDropdown = "dropdown" LiveTypeCascader = "cascader" ) const ( TypeInteger = "integer" TypeFloat = "float" TypeBoolean = "boolean" TypeString = "string" ) const ( FormatInteger = "integer" FormatFloat = "float" FormatBoolean = "boolean" FormatString = "string" FormatText = "text" FormatDropdown = "dropdown" FormatDatetime = "datetime" FormatDate = "date" FormatTime = "time" FormatTimestamp = "timestamp" FormatPassword = "password" ) const ( OperatorEqual = "eq" OperatorGreaterThan = "gt" OperatorGreaterEqual = "ge" OperatorLessThan = "lt" OperatorLessEqual = "le" OperatorLike = "like" OperatorBetween = "between" ) const ( ErrImportFileNotExists = 1004 ErrImportFileUnavailable = 1005 ErrImportColumnNotMatch = 1006 ) const ( defaultPageSize = 15 defaultDomain = "localhost" ) const ( RequestDenied = 8005 RequestRecordNotFound = 8004 RequestPayloadInvalid = 8006 RequestCreateFailure = 8007 RequestUpdateFailure = 8008 RequestDeleteFailure = 8009 ) const ( FormatRaw = "raw" FormatBoth = "both" ) const ( FieldDomain = "domain" ) type ( // HttpWriter http 响应接口 HttpWriter interface { Success(w http.ResponseWriter, data any) Failure(w http.ResponseWriter, reason int, message string, data any) } // HttpRouter http 路由管理工具 HttpRouter interface { Handle(method string, uri string, handler http.HandlerFunc) } // TypeValue 键值对数据 TypeValue struct { Label any `json:"label"` Value any `json:"value"` } // NestedValue 层级数据 NestedValue struct { Label any `json:"label"` Value any `json:"value"` Children []*NestedValue `json:"children,omitempty"` } //ValueLookupFunc 查找域的函数 ValueLookupFunc func(column string, w http.ResponseWriter, r *http.Request) string //SchemaLookupFunc 查找schema的回调函数 SchemaLookupFunc func(ctx context.Context, db *gorm.DB, domain, module, table, scenario string) ([]*Schema, error) ) type ( multiValue struct { Text any `json:"label"` Value any `json:"value"` } Tabler interface { TableName() string } Reporter interface { TableName() string RealTable() string QuoteColumn(ctx context.Context, column string) string GroupBy(ctx context.Context) []string } FormatModel interface { Format(ctx context.Context, scene string, schemas []*Schema) } SelectColumn struct { Name string `json:"name"` Expr string `json:"expr"` Native bool `json:"native"` Callback string `json:"callback"` } DiffAttr struct { Column string `json:"column"` Label string `json:"label"` OldValue any `json:"old_value"` NewValue any `json:"new_value"` } Condition struct { Column string `json:"column"` Expr string `json:"expr"` Value any `json:"value,omitempty"` Values []any `json:"values,omitempty"` } Naming struct { Pluralize string Singular string ModuleName string TableName string } RuntimeScope struct { Domain string //域 User string //用户 ModuleName string //模块名称 TableName string //表名称 Scenario string //场景名称 Schemas []*Schema //字段schema Request *http.Request //HTTP请求结构 PrimaryKeyValue any //主键 } ImportResult struct { Code int `json:"code"` TotalCount int `json:"total_count"` SuccessCount int `json:"success_count"` UploadFile string `json:"upload_file"` FailureFile string `json:"failure_file"` Duration time.Duration `json:"duration"` } sqlCountResponse struct { Count int64 `json:"count"` } ) type ( ListResponse struct { Page int `json:"page"` PageSize int `json:"pagesize"` TotalCount int64 `json:"totalCount"` Data any `json:"data"` } CreateResponse struct { ID any `json:"id"` Status string `json:"status"` } UpdateResponse struct { ID any `json:"id"` Status string `json:"status"` } DeleteResponse struct { ID any `json:"id"` Status string `json:"status"` } ImportResponse struct { UID string `json:"uid"` Status string `json:"status"` } )