yjp 1 年間 前
コミット
3e289b791c

+ 32 - 20
convenient/binding/request/common.go

@@ -1,6 +1,6 @@
 package request
 
-type WithID interface {
+type IDRequestParam interface {
 	Params
 	GetID() string
 }
@@ -13,23 +13,23 @@ func (id *IDJsonBody) GetID() string {
 	return id.ID
 }
 
-type IDPath struct {
+type IDPathParam struct {
 	ID string `uri:"id" binding:"required" assign:"toField:ID"`
 }
 
-func (id *IDPath) GetID() string {
+func (id *IDPathParam) GetID() string {
 	return id.ID
 }
 
-type IDQuery struct {
+type IDQueryParam struct {
 	ID string `form:"id" binding:"required" assign:"toField:ID"`
 }
 
-func (id *IDQuery) GetID() string {
+func (id *IDQueryParam) GetID() string {
 	return id.ID
 }
 
-type TenantID interface {
+type TenantIDRequestParam interface {
 	Params
 	GetTenantID() string
 }
@@ -42,47 +42,59 @@ func (id *IDJsonBody) GetTenantID() string {
 	return id.ID
 }
 
-type TenantIDPath struct {
+type TenantIDPathParam struct {
 	TenantID string `uri:"tenant_id" binding:"required" assign:"toField:TenantID"`
 }
 
-func (id *IDPath) GetTenantID() string {
+func (id *IDPathParam) GetTenantID() string {
 	return id.ID
 }
 
-type TenantIDQuery struct {
+type TenantIDQueryParam struct {
 	TenantID string `form:"tenant_id" binding:"required" assign:"toField:TenantID"`
 }
 
-func (id *IDQuery) GetTenantID() string {
+func (id *IDQueryParam) GetTenantID() string {
 	return id.ID
 }
 
-type Query interface {
+type QueryRequestParams interface {
 	Params
 	GetPageNo() int
 	GetPageSize() int
 }
 
-type BaseQuery struct {
+type BaseQueryParams struct {
 	PageNo   int `form:"pageNo" assign:"-"`
 	PageSize int `form:"pageSize" assign:"-"`
 }
 
-func (q *BaseQuery) GetPageNo() int {
+func (q *BaseQueryParams) GetPageNo() int {
 	return q.PageNo
 }
 
-func (q *BaseQuery) GetPageSize() int {
+func (q *BaseQueryParams) GetPageSize() int {
 	return q.PageSize
 }
 
-type QueryWithID interface {
-	WithID
-	Query
+type QueryWithIDRequestParams interface {
+	IDRequestParam
+	QueryRequestParams
 }
 
-type BaseQueryWithID struct {
-	IDQuery
-	BaseQuery
+type BaseQueryWithIDParams struct {
+	IDQueryParam
+	BaseQueryParams
+}
+
+type CreateUserIDJsonBody struct {
+	CreateUserID string `json:"createUserId" binding:"required" assign:"toField:CreateUserID"`
+}
+
+type LastUpdateUserIDJsonBody struct {
+	LastUpdateUserID string `json:"lastUpdateUserId" binding:"required" assign:"toField:LastUpdateUserID"`
+}
+
+type LastUpdateUserIDPathParams struct {
+	LastUpdateUserID string `uri:"lastUpdateUserId" binding:"required" assign:"toField:LastUpdateUserID"`
 }

+ 2 - 2
convenient/entity/service.go

@@ -77,7 +77,7 @@ func Delete(tableName string, callbacks *Callbacks[any]) binding.ServiceFunc[any
 			return nil, fserr.New("需要传递领域对象应该为实体")
 		}
 
-		err := e.CheckFieldID(e.DomainCNName())
+		err := e.ForDelete()
 		if err != nil {
 			return callbackOnErrorReturn(callbacks, e, err, i, nil)
 		}
@@ -171,7 +171,7 @@ func Query[O any](tableName string, callbacks *Callbacks[response.InfosData[O]],
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}

+ 4 - 4
convenient/entity/simple.go

@@ -22,16 +22,16 @@ type Simple[I any] struct {
 	CreateJsonBody request.Params
 
 	// 删除使用的请求参数,注意是WithID类型
-	DeleteQueryParams request.WithID
+	DeleteQueryParams request.IDRequestParam
 
 	// 更新使用的请求参数,注意是WithID类型
-	UpdateJsonBody request.WithID
+	UpdateJsonBody request.IDRequestParam
 
 	// 查询使用的请求参数,注意是Query类型
-	QueryQueryParams request.Query
+	QueryQueryParams request.QueryRequestParams
 
 	// 根据ID查询使用的请求参数,注意是WithID类型
-	GetByIDQueryParams request.WithID
+	GetByIDQueryParams request.IDRequestParam
 
 	// 可选配置项,通过WithXXX配置
 	options *Options[I]

+ 1 - 1
convenient/relation/many2many/service.go

@@ -142,7 +142,7 @@ func Query[TI any](middleTableName string,
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}

+ 2 - 2
convenient/relation/many2many/simple.go

@@ -27,13 +27,13 @@ type Simple[LI any, RI any] struct {
 	LeftUpdateJsonBody request.Params
 
 	// 查询左实体关联使用的请求参数,注意是QueryWithID类型
-	LeftQueryQueryParams request.QueryWithID
+	LeftQueryQueryParams request.QueryWithIDRequestParams
 
 	// 更新右实体关联使用的请求参数
 	RightUpdateJsonBody request.Params
 
 	// 查询右实体关联使用的请求参数,注意是QueryWithID类型
-	RightQueryQueryParams request.QueryWithID
+	RightQueryQueryParams request.QueryWithIDRequestParams
 
 	// 可选配置项,通过WithXXX配置
 	options *Options

+ 2 - 2
convenient/relation/one2many/service.go

@@ -135,7 +135,7 @@ func QueryLeft[RI any](leftTableName string,
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}
@@ -331,7 +331,7 @@ func QueryRightWithLeftInfo[RI any, LI any](rightTableName string, rightRelation
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}

+ 3 - 3
convenient/relation/one2many/simple.go

@@ -27,16 +27,16 @@ type Simple[LI any, RI any] struct {
 	LeftUpdateJsonBody request.Params
 
 	// 查询左实体关联使用的请求参数,注意是Query类型
-	LeftQueryQueryParams request.Query
+	LeftQueryQueryParams request.QueryRequestParams
 
 	// 更新左实体关联使用的请求参数
 	RightUpdateJsonBody request.Params
 
 	// 查询右实体关联使用的请求参数,注意是QueryWithID类型
-	RightQueryQueryParams request.QueryWithID
+	RightQueryQueryParams request.QueryWithIDRequestParams
 
 	// 查询右实体带左实体信息使用的请求参数,注意是Query类型
-	RightQueryWithLeftQueryParams request.Query
+	RightQueryWithLeftQueryParams request.QueryRequestParams
 
 	// 可选配置项,通过WithXXX配置
 	options *Options

+ 1 - 1
convenient/relation/one2one/service.go

@@ -211,7 +211,7 @@ func QueryWithOtherInfo[FI any, TI any](fromTableName string, fromRelationColumn
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}

+ 6 - 6
convenient/relation/one2one/simple.go

@@ -24,22 +24,22 @@ type Simple[LI any, RI any] struct {
 	Schema string
 
 	// 更新左实体关联使用的请求参数
-	LeftUpdateJsonBody request.WithID
+	LeftUpdateJsonBody request.IDRequestParam
 
 	// 查询左实体关联使用的请求参数,注意是WithID类型
-	LeftQueryQueryParams request.WithID
+	LeftQueryQueryParams request.IDRequestParam
 
 	// 查询左实体带右实体信息使用的请求参数,注意是Query类型
-	LeftQueryWithRightQueryParams request.Query
+	LeftQueryWithRightQueryParams request.QueryRequestParams
 
 	// 更新右实体关联使用的请求参数,注意是WithID类型
-	RightUpdateJsonBody request.WithID
+	RightUpdateJsonBody request.IDRequestParam
 
 	// 查询右实体关联使用的请求参数,注意是WithID类型
-	RightQueryQueryParams request.WithID
+	RightQueryQueryParams request.IDRequestParam
 
 	// 查询右实体带左实体信息使用的请求参数,注意是WithID类型
-	RightQueryWithLeftQueryParams request.Query
+	RightQueryWithLeftQueryParams request.QueryRequestParams
 
 	// 可选配置项,通过WithXXX配置
 	options *Options

+ 2 - 2
convenient/relation/remote/service.go

@@ -146,7 +146,7 @@ func QueryToExist[TI any](middleTableName string,
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}
@@ -236,7 +236,7 @@ func QueryToRemote(middleTableName string, fromRemote bool, fromTableName string
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}

+ 2 - 2
convenient/relation/remote/simple.go

@@ -32,13 +32,13 @@ type Simple[I any] struct {
 	LeftUpdateJsonBody request.Params
 
 	// 查询左实体关联使用的请求参数,注意是Query类型
-	LeftQueryQueryParams request.QueryWithID
+	LeftQueryQueryParams request.QueryWithIDRequestParams
 
 	// 更新右实体关联使用的请求参数
 	RightUpdateJsonBody request.Params
 
 	// 查询右实体关联使用的请求参数,注意是Query类型
-	RightQueryQueryParams request.QueryWithID
+	RightQueryQueryParams request.QueryWithIDRequestParams
 
 	// 可选配置项,通过WithXXX配置
 	options *Options

+ 1 - 1
convenient/value_object/service.go

@@ -114,7 +114,7 @@ func Query[O any](tableName string, callbacks *Callbacks[response.InfosData[O]],
 
 		dbExecutor := i.DBExecutor()
 
-		queryParams, ok := params.(request.Query)
+		queryParams, ok := params.(request.QueryRequestParams)
 		if !ok {
 			return errResponse, fserr.New("请求参数不是Query接口")
 		}

+ 1 - 1
convenient/value_object/simple.go

@@ -25,7 +25,7 @@ type Simple[I any] struct {
 	DeleteQueryParams request.Params
 
 	// 查询使用的请求参数,注意是Query类型
-	QueryQueryParams request.Query
+	QueryQueryParams request.QueryRequestParams
 
 	// 可选配置项,通过WithXXX配置
 	options *Options[I]

+ 4 - 0
examples/examples/project/application/domain/class/entity.go

@@ -45,6 +45,10 @@ func (e *Entity) ForCreate() error {
 	return nil
 }
 
+func (e *Entity) ForDelete() error {
+	return e.CheckFieldID(e.DomainCNName())
+}
+
 func (e *Entity) ForUpdate() error {
 	err := e.CheckFieldID(e.DomainCNName())
 	if err != nil {

+ 4 - 4
examples/examples/project/application/domain/class/request_params.go

@@ -11,7 +11,7 @@ type (
 	}
 
 	DeletePathParams struct {
-		request.IDPath
+		request.IDPathParam
 	}
 
 	UpdateJsonBody struct {
@@ -21,13 +21,13 @@ type (
 	}
 
 	QueryQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Name       string `form:"name" assign:"toField:Name"`
 		StudentNum int    `form:"studentNum" assign:"toField:StudentNum"`
 	}
 
 	GetByIDQueryParams struct {
-		request.IDQuery
+		request.IDQueryParam
 	}
 
 	UpdateStudentsOfClassJsonBody struct {
@@ -36,6 +36,6 @@ type (
 	}
 
 	QueryStudentsOfClassQueryParams struct {
-		request.BaseQueryWithID
+		request.BaseQueryWithIDParams
 	}
 )

+ 4 - 0
examples/examples/project/application/domain/family/entity.go

@@ -46,6 +46,10 @@ func (e *Entity) ForCreate() error {
 	return nil
 }
 
+func (e *Entity) ForDelete() error {
+	return e.CheckFieldID(e.DomainCNName())
+}
+
 func (e *Entity) ForUpdate() error {
 	err := e.CheckFieldID(e.DomainCNName())
 	if err != nil {

+ 5 - 5
examples/examples/project/application/domain/family/request_params.go

@@ -11,7 +11,7 @@ type (
 	}
 
 	DeletePathParams struct {
-		request.IDPath
+		request.IDPathParam
 	}
 
 	UpdateJsonBody struct {
@@ -21,13 +21,13 @@ type (
 	}
 
 	QueryQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Father string `form:"father" assign:"toField:Father"`
 		Mother string `form:"mother" assign:"toField:Mother"`
 	}
 
 	GetByIDQueryParams struct {
-		request.IDQuery
+		request.IDQueryParam
 	}
 
 	UpdateStudentOfFamilyJsonBody struct {
@@ -36,11 +36,11 @@ type (
 	}
 
 	QueryStudentOfFamilyQueryParams struct {
-		request.IDQuery
+		request.IDQueryParam
 	}
 
 	QueryFamilyWithStudentQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Father string `form:"father" assign:"toField:Father"`
 		Mother string `form:"mother" assign:"toField:Mother"`
 	}

+ 4 - 0
examples/examples/project/application/domain/hobby/entity.go

@@ -26,6 +26,10 @@ func (e *Entity) ForCreate() error {
 	return nil
 }
 
+func (e *Entity) ForDelete() error {
+	return e.CheckFieldID(e.DomainCNName())
+}
+
 func (e *Entity) ForUpdate() error {
 	err := e.CheckFieldID(e.DomainCNName())
 	if err != nil {

+ 1 - 1
examples/examples/project/application/domain/hobby/request_params.go

@@ -11,6 +11,6 @@ type (
 	}
 
 	QueryStudentsOfHobbyQueryParams struct {
-		request.BaseQueryWithID
+		request.BaseQueryWithIDParams
 	}
 )

+ 4 - 0
examples/examples/project/application/domain/identity/entity.go

@@ -43,6 +43,10 @@ func (e *Entity) ForCreate() error {
 	return nil
 }
 
+func (e *Entity) ForDelete() error {
+	return e.CheckFieldID(e.DomainCNName())
+}
+
 func (e *Entity) ForUpdate() error {
 	err := e.CheckFieldID(e.DomainCNName())
 	if err != nil {

+ 4 - 4
examples/examples/project/application/domain/identity/request_params.go

@@ -10,7 +10,7 @@ type (
 	}
 
 	DeletePathParams struct {
-		request.IDPath
+		request.IDPathParam
 	}
 
 	UpdateJsonBody struct {
@@ -19,12 +19,12 @@ type (
 	}
 
 	QueryQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Name string `form:"name" assign:"toField:Name"`
 	}
 
 	GetByIDQueryParams struct {
-		request.IDQuery
+		request.IDQueryParam
 	}
 
 	UpdateStudentsOfIdentityJsonBody struct {
@@ -33,6 +33,6 @@ type (
 	}
 
 	QueryStudentsOfIdentityQueryParams struct {
-		request.BaseQueryWithID
+		request.BaseQueryWithIDParams
 	}
 )

+ 4 - 0
examples/examples/project/application/domain/student/entity.go

@@ -46,6 +46,10 @@ func (e *Entity) ForCreate() error {
 	return nil
 }
 
+func (e *Entity) ForDelete() error {
+	return e.CheckFieldID(e.DomainCNName())
+}
+
 func (e *Entity) ForUpdate() error {
 	err := e.CheckFieldID(e.DomainCNName())
 	if err != nil {

+ 9 - 9
examples/examples/project/application/domain/student/request_params.go

@@ -10,7 +10,7 @@ type (
 	}
 
 	DeletePathParams struct {
-		request.IDPath
+		request.IDPathParam
 	}
 
 	UpdateJsonBody struct {
@@ -19,12 +19,12 @@ type (
 	}
 
 	QueryQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Name string `form:"name" assign:"toField:Name"`
 	}
 
 	GetByIDQueryParams struct {
-		request.IDQuery
+		request.IDQueryParam
 	}
 
 	UpdateFamilyOfStudentJsonBody struct {
@@ -33,11 +33,11 @@ type (
 	}
 
 	QueryFamilyOfStudentQueryParams struct {
-		request.IDQuery
+		request.IDQueryParam
 	}
 
 	QueryStudentWithFamilyQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Name string `form:"name" assign:"toField:Name"`
 	}
 
@@ -47,7 +47,7 @@ type (
 	}
 
 	QueryIdentitiesOfStudentQueryParams struct {
-		request.BaseQueryWithID
+		request.BaseQueryWithIDParams
 	}
 
 	UpdateHobbiesOfStudentJsonBody struct {
@@ -56,7 +56,7 @@ type (
 	}
 
 	QueryHobbiesOfStudentQueryParams struct {
-		request.BaseQueryWithID
+		request.BaseQueryWithIDParams
 	}
 
 	UpdateClassOfStudentJsonBody struct {
@@ -65,11 +65,11 @@ type (
 	}
 
 	QueryClassOfStudentQueryParams struct {
-		request.BaseQueryWithID
+		request.BaseQueryWithIDParams
 	}
 
 	QueryStudentWithClassQueryParams struct {
-		request.BaseQuery
+		request.BaseQueryParams
 		Name string `form:"name" assign:"toField:Name"`
 	}
 )

+ 0 - 16
framwork/domain/entity/base.go

@@ -10,14 +10,6 @@ func (e *Base) DBSchema() string {
 	return ""
 }
 
-func (e *Base) DomainCNName() string {
-	panic("领域实体没有实现DomainCNName接口")
-}
-
-func (e *Base) DomainCamelName() string {
-	panic("领域实体没有实现DomainCamelName接口")
-}
-
 func (e *Base) GenerateID() error {
 	e.ID = strutils.SimpleUUID()
 	return nil
@@ -34,11 +26,3 @@ func (e *Base) CheckFieldID(domainCNName string) error {
 func (e *Base) IDColumnName() string {
 	return ColumnID
 }
-
-func (e *Base) ForCreate() error {
-	panic("领域实体没有实现ForCreate接口")
-}
-
-func (e *Base) ForUpdate() error {
-	panic("领域实体没有实现ForUpdate接口")
-}

+ 1 - 0
framwork/domain/entity/entity.go

@@ -10,5 +10,6 @@ type Entity interface {
 	GetID() string
 	CheckFieldID(domainCNName string) error
 	ForCreate() error
+	ForDelete() error
 	ForUpdate() error
 }