|
|
@@ -15,12 +15,6 @@ type Simple[I any] struct {
|
|
|
// 使用的领域实体,注意是ValueObject类型
|
|
|
ValueObject value_object.ValueObject
|
|
|
|
|
|
- // 表名
|
|
|
- TableName string
|
|
|
-
|
|
|
- // URL领域相对路径,如/class,后面会自动补充
|
|
|
- DomainPath string
|
|
|
-
|
|
|
// 创建使用的请求参数
|
|
|
CreateJsonBody request.Params
|
|
|
|
|
|
@@ -37,23 +31,26 @@ type Simple[I any] struct {
|
|
|
func (simple *Simple[I]) bind(binder *binding.Binder) {
|
|
|
options := simple.options
|
|
|
|
|
|
+ tableName := value_object.TableName(simple.ValueObject)
|
|
|
+ domainPath := value_object.RelativeDomainPath(simple.ValueObject)
|
|
|
+
|
|
|
// 创建
|
|
|
if !options.disableCreate {
|
|
|
if !options.createNeedTx {
|
|
|
binding.PostBind(binder, &binding.SimpleBindItem[any]{
|
|
|
- Path: simple.DomainPath + "/create",
|
|
|
+ Path: domainPath + "/create",
|
|
|
ResponseFunc: response.SendMsgResponse,
|
|
|
RequestParams: simple.CreateJsonBody,
|
|
|
Objects: []domain.Object{simple.ValueObject},
|
|
|
- ServiceFunc: Create(simple.TableName, options.createCallbacks),
|
|
|
+ ServiceFunc: Create(tableName, options.createCallbacks),
|
|
|
})
|
|
|
} else {
|
|
|
binding.PostBind(binder, &binding.SimpleBindItem[any]{
|
|
|
- Path: simple.DomainPath + "/create",
|
|
|
+ Path: domainPath + "/create",
|
|
|
ResponseFunc: response.SendMsgResponse,
|
|
|
RequestParams: simple.CreateJsonBody,
|
|
|
Objects: []domain.Object{simple.ValueObject},
|
|
|
- ServiceFunc: CreateTx(simple.TableName, options.createCallbacks),
|
|
|
+ ServiceFunc: CreateTx(tableName, options.createCallbacks),
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -62,21 +59,21 @@ func (simple *Simple[I]) bind(binder *binding.Binder) {
|
|
|
if !options.disableDelete {
|
|
|
if !options.deleteNeedTx {
|
|
|
binding.PostBind(binder, &binding.SimpleBindItem[any]{
|
|
|
- Path: simple.DomainPath + "/delete",
|
|
|
+ Path: domainPath + "/delete",
|
|
|
ResponseFunc: response.SendMsgResponse,
|
|
|
RequestParams: simple.DeleteQueryParams,
|
|
|
RequestParamsBindFunc: request.JsonBody,
|
|
|
Objects: []domain.Object{simple.ValueObject},
|
|
|
- ServiceFunc: Delete(simple.TableName, options.deleteCallbacks),
|
|
|
+ ServiceFunc: Delete(tableName, options.deleteCallbacks),
|
|
|
})
|
|
|
} else {
|
|
|
binding.PostBind(binder, &binding.SimpleBindItem[any]{
|
|
|
- Path: simple.DomainPath + "/delete",
|
|
|
+ Path: domainPath + "/delete",
|
|
|
ResponseFunc: response.SendMsgResponse,
|
|
|
RequestParams: simple.DeleteQueryParams,
|
|
|
RequestParamsBindFunc: request.JsonBody,
|
|
|
Objects: []domain.Object{simple.ValueObject},
|
|
|
- ServiceFunc: DeleteTx(simple.TableName, options.deleteCallbacks),
|
|
|
+ ServiceFunc: DeleteTx(tableName, options.deleteCallbacks),
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -84,11 +81,11 @@ func (simple *Simple[I]) bind(binder *binding.Binder) {
|
|
|
// 查询
|
|
|
if !options.disableQuery {
|
|
|
binding.GetBind(binder, &binding.SimpleBindItem[response.InfosData[I]]{
|
|
|
- Path: simple.DomainPath + "/query",
|
|
|
+ Path: domainPath + "/query",
|
|
|
ResponseFunc: response.SendInfosResponse[I],
|
|
|
RequestParams: simple.QueryQueryParams,
|
|
|
Objects: []domain.Object{simple.ValueObject},
|
|
|
- ServiceFunc: Query(simple.TableName, options.queryCallbacks, options.queryConditionFieldCallback),
|
|
|
+ ServiceFunc: Query(tableName, options.queryCallbacks, options.queryConditionFieldCallback),
|
|
|
})
|
|
|
}
|
|
|
}
|