|
@@ -80,7 +80,7 @@ func (simple *Simple[LI, RI]) bind(binder *binding.Binder) {
|
|
|
Objects: []domain.Object{simple.Left},
|
|
|
ServiceFunc: Query[RI](middleTableName,
|
|
|
leftTableName, leftRelationColumnName,
|
|
|
- rightTableName, rightRelationColumnName),
|
|
|
+ rightTableName, rightRelationColumnName, options.leftQueryOrderBy),
|
|
|
}, leftQueryMiddlewares...)
|
|
|
}
|
|
|
}
|
|
@@ -112,7 +112,7 @@ func (simple *Simple[LI, RI]) bind(binder *binding.Binder) {
|
|
|
Objects: []domain.Object{simple.Right},
|
|
|
ServiceFunc: Query[LI](middleTableName,
|
|
|
rightTableName, rightRelationColumnName,
|
|
|
- leftTableName, leftRelationColumnName),
|
|
|
+ leftTableName, leftRelationColumnName, options.rightQueryOrderBy),
|
|
|
}, rightQueryMiddlewares...)
|
|
|
}
|
|
|
}
|
|
@@ -160,11 +160,17 @@ type Options struct {
|
|
|
// 左侧查询中间件
|
|
|
leftQueryMiddlewares []binding.Middleware
|
|
|
|
|
|
+ // 左侧查询OrderBy
|
|
|
+ leftQueryOrderBy string
|
|
|
+
|
|
|
// 右侧更新中间件
|
|
|
rightUpdateMiddlewares []binding.Middleware
|
|
|
|
|
|
// 右侧查询中间件
|
|
|
rightQueryMiddlewares []binding.Middleware
|
|
|
+
|
|
|
+ // 右侧查询OrderBy
|
|
|
+ rightQueryOrderBy string
|
|
|
}
|
|
|
|
|
|
func WithGlobalMiddlewares(middlewares ...binding.Middleware) Option {
|
|
@@ -221,6 +227,12 @@ func WithLeftQueryMiddlewares(middlewares ...binding.Middleware) Option {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func WithLeftQueryOrderBy(orderBy string) Option {
|
|
|
+ return func(options *Options) {
|
|
|
+ options.leftQueryOrderBy = orderBy
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func WithRightUpdateMiddlewares(middlewares ...binding.Middleware) Option {
|
|
|
return func(options *Options) {
|
|
|
options.rightUpdateMiddlewares = middlewares
|
|
@@ -232,3 +244,9 @@ func WithRightQueryMiddlewares(middlewares ...binding.Middleware) Option {
|
|
|
options.rightQueryMiddlewares = middlewares
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func WithRightQueryOrderBy(orderBy string) Option {
|
|
|
+ return func(options *Options) {
|
|
|
+ options.rightQueryOrderBy = orderBy
|
|
|
+ }
|
|
|
+}
|