[feat] 重新梳理依赖
This commit is contained in:
@@ -3,7 +3,9 @@ package contracts
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"git.fsdpf.net/go/condition"
|
||||
"git.fsdpf.net/go/db"
|
||||
"git.fsdpf.net/go/req"
|
||||
)
|
||||
|
||||
type OrmExecute int
|
||||
@@ -30,47 +32,18 @@ const (
|
||||
RelationType_Right RelationType = "right"
|
||||
)
|
||||
|
||||
const (
|
||||
ConditionType_OR ConditionType = "OR"
|
||||
ConditionType_AND ConditionType = "AND"
|
||||
)
|
||||
|
||||
const (
|
||||
ConditionTokenType_SQL ConditionTokenType = "sql"
|
||||
ConditionTokenType_FUNC ConditionTokenType = "func"
|
||||
ConditionTokenType_PARAM ConditionTokenType = "param"
|
||||
ConditionTokenType_STRING ConditionTokenType = "string"
|
||||
)
|
||||
|
||||
const (
|
||||
ConditionOperator_IS_NULL ConditionOperator = "IS NULL"
|
||||
ConditionOperator_IS_NOT_NULL ConditionOperator = "IS NOT NULL"
|
||||
ConditionOperator_EQ ConditionOperator = "="
|
||||
ConditionOperator_NE ConditionOperator = "!="
|
||||
ConditionOperator_GT ConditionOperator = ">"
|
||||
ConditionOperator_GE ConditionOperator = ">="
|
||||
ConditionOperator_LT ConditionOperator = "<"
|
||||
ConditionOperator_LE ConditionOperator = "<="
|
||||
ConditionOperator_LIKE ConditionOperator = "LIKE"
|
||||
ConditionOperator_NOT_LIKE ConditionOperator = "NOT LIKE"
|
||||
ConditionOperator_IN ConditionOperator = "IN"
|
||||
ConditionOperator_NOT_IN ConditionOperator = "NOT IN"
|
||||
ConditionOperator_REGEXP ConditionOperator = "REGEXP"
|
||||
ConditionOperator_NOT_REGEXP ConditionOperator = "NOT REGEXP"
|
||||
)
|
||||
|
||||
const (
|
||||
OrderByDirection_ASC OrderByDirection = db.ORDER_ASC
|
||||
OrderByDirection_DESC OrderByDirection = db.ORDER_DESC
|
||||
)
|
||||
|
||||
type Orm interface {
|
||||
SetGlobalParams(g GlobalParams) Orm
|
||||
SetGlobalParams(g req.GlobalParams) Orm
|
||||
GetModel(params ...string) Model
|
||||
SetRelationModel(m Model) Model
|
||||
SetQueryField(qf QueryField) error
|
||||
SetQueryField(qf req.QueryField) error
|
||||
SetOrderBy(params []OrderBy) error
|
||||
SetCondition(cond Condition) error
|
||||
SetCondition(cond *condition.Condition) error
|
||||
SetController(ctr OrmController) error
|
||||
Execute(OrmExecute) (any, error)
|
||||
Clone(tx *db.Transaction) Orm
|
||||
@@ -83,9 +56,9 @@ type Relation interface {
|
||||
AppendTo(Model)
|
||||
Type() RelationType
|
||||
SetType(RelationType)
|
||||
SetCondition(Condition) Condition
|
||||
SetPrependCondition(Condition) Condition
|
||||
GetCondition() Condition
|
||||
SetCondition(*condition.Condition) *condition.Condition
|
||||
SetPrependCondition(*condition.Condition) *condition.Condition
|
||||
GetCondition() *condition.Condition
|
||||
GetRelationResource() string
|
||||
GetRelationField() string
|
||||
GetRelationForeignKey() string
|
||||
@@ -94,26 +67,26 @@ type Relation interface {
|
||||
type Join interface {
|
||||
Relation
|
||||
GetCode() string
|
||||
GetResource() Resource
|
||||
GetResource() req.Resource
|
||||
// GetDependencies(items []ResRelation, dependencies ...string) []string
|
||||
Inject(dbBuilder *db.Builder, m Model)
|
||||
}
|
||||
type Model interface {
|
||||
Relation
|
||||
ModelParam
|
||||
condition.TokenValue
|
||||
GetCode() string
|
||||
GetPrimaryKey() string
|
||||
GetQueryFieldsStruct(extends ...reflect.StructField) any
|
||||
GetQueryFieldsSliceStruct(fields ...reflect.StructField) any
|
||||
GetAttribute() map[string]any
|
||||
GetResult() reflect.Value
|
||||
GetResource() Resource
|
||||
GetResource() req.Resource
|
||||
QueryBuilder() *db.Builder
|
||||
GetTransaction() *db.Transaction
|
||||
SetQueryField(QueryField)
|
||||
SetQueryField(req.QueryField)
|
||||
SetRelationResult(code string, vItems reflect.Value)
|
||||
GetJoinsCode() []string
|
||||
SetAuthDB(ResAuthDB)
|
||||
SetAuthDB(req.ResAuthDB)
|
||||
SetOrderBy(params ...OrderBy) Model
|
||||
SetGroupBy(params ...GroupBy) Model
|
||||
SetJoin(Join) Model
|
||||
@@ -130,43 +103,8 @@ type Model interface {
|
||||
// Exists() (bool, error)
|
||||
}
|
||||
|
||||
type ModelParam interface {
|
||||
GetParam(k string) GlobalParams
|
||||
GetGlobalParamsUser() User
|
||||
}
|
||||
|
||||
type OrmController interface {
|
||||
AuthDB() ResAuthDB
|
||||
}
|
||||
|
||||
type Condition interface {
|
||||
Type() ConditionType
|
||||
IsEmpty() bool
|
||||
IsNotEmpty() bool
|
||||
IsAlwaysRight() bool
|
||||
ToSql(ModelParam) db.Expression
|
||||
AppendTo(Condition)
|
||||
SetExpr(ConditionExpr) Condition
|
||||
SetCondition(Condition) Condition
|
||||
SetMatchPrefix(string) Condition
|
||||
GetFields(operator ConditionOperator, types ...ConditionTokenType) map[string]string
|
||||
GetFieldsValue(m ModelParam, isWithResource bool) map[string]any
|
||||
}
|
||||
|
||||
type ConditionExpr interface {
|
||||
GetField() string
|
||||
GetFieldResource() string
|
||||
GetOperator() ConditionOperator
|
||||
|
||||
SetMatchPrefix(string) ConditionExpr
|
||||
|
||||
AppendTo(Condition)
|
||||
ToSql(m ModelParam) db.Expression
|
||||
GetTokenName() string
|
||||
GetTokenType() ConditionTokenType
|
||||
GetTokenValue(ModelParam) any
|
||||
GetTokenSqlValue(ModelParam) string
|
||||
IsIgnoreEmptyParma(ModelParam) bool
|
||||
AuthDB() req.ResAuthDB
|
||||
}
|
||||
|
||||
type OrderBy interface {
|
||||
@@ -192,13 +130,13 @@ type QueryWithRecursive interface {
|
||||
// @param rForeignKey 关联外键, 如 id
|
||||
type NewOrmRelation func(t RelationType, m Model, rResource, rField, rForeignKey string) Model
|
||||
|
||||
type NewOrmJoin func(t RelationType, res Resource, alias, rResource, rField, rForeignKey string) Join
|
||||
type NewOrmJoin func(t RelationType, res req.Resource, alias, rResource, rField, rForeignKey string) Join
|
||||
|
||||
type NewOrmCondition func(typ ConditionType, describe string) Condition
|
||||
type NewOrmCondition func(typ ConditionType, describe string) *condition.Condition
|
||||
|
||||
type NewOrmConditionExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool) ConditionExpr
|
||||
type NewOrmConditionExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool) *condition.ConditionExpr
|
||||
|
||||
type NewOrmConditionFuncExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool, fn, fnParam string) ConditionExpr
|
||||
type NewOrmConditionFuncExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool, fn, fnParam string) *condition.ConditionExpr
|
||||
|
||||
type NewOrmQueryWithRecursive func(pField, cField string, root any, isWithoutCondition bool, depth int) QueryWithRecursive
|
||||
|
||||
@@ -206,8 +144,8 @@ type NewOrmOrderBy func(sql string, direction OrderByDirection) OrderBy
|
||||
|
||||
type NewOrmGroupBy func(sql string) GroupBy
|
||||
|
||||
type NewOrmModel func(res Resource, code, name string) Model
|
||||
type NewOrmModel func(res req.Resource, code, name string) Model
|
||||
|
||||
type NewOrm func(res Resource, tx *db.Transaction) Orm
|
||||
type NewOrm func(res req.Resource, tx *db.Transaction) Orm
|
||||
|
||||
type GetOrmConditionByRes func(categoryUuid string, describe string) Condition
|
||||
type GetOrmConditionByRes func(categoryUuid string, describe string) *condition.Condition
|
||||
|
||||
Reference in New Issue
Block a user