yjp 1 éve
szülő
commit
1e3765566a

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

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

+ 1 - 0
examples/examples/project/application/application.go

@@ -40,6 +40,7 @@ var applications = []Service{
 	&service.Student{},
 	&service.Identity{},
 	&service.Family{},
+	&service.ClassAndStudent{},
 	&service.StudentAndFamily{},
 	&service.StudentAndIdentity{},
 	&service.StudentAndHobby{},

+ 3 - 2
examples/examples/project/application/domain/class/entity.go

@@ -17,8 +17,9 @@ const (
 
 type Entity struct {
 	entity.Base
-	Name       string `sqlmapping:"column:name" sqlresult:"column:name"`
-	StudentNum int    `sqlmapping:"column:student_num;updateClear;" sqlresult:"column:student_num"`
+	Name       string   `sqlmapping:"column:name" sqlresult:"column:name"`
+	StudentNum int      `sqlmapping:"column:student_num;updateClear;" sqlresult:"column:student_num"`
+	StudentIDs []string `sqlmapping:"-" sqlresult:"-"`
 	entity.TimeFields
 }
 

+ 9 - 0
examples/examples/project/application/domain/class/request_params.go

@@ -29,4 +29,13 @@ type (
 	GetByIDQueryParams struct {
 		request.IDQuery
 	}
+
+	UpdateStudentsOfClassJsonBody struct {
+		request.IDJsonBody
+		StudentIDs []string `json:"studentIds" assign:"toField:StudentIDs"`
+	}
+
+	QueryStudentsOfClassQueryParams struct {
+		request.BaseQueryWithID
+	}
 )

+ 3 - 1
examples/examples/project/application/domain/family/request_params.go

@@ -40,6 +40,8 @@ type (
 	}
 
 	QueryFamilyWithStudentQueryParams struct {
-		request.IDQuery
+		request.Query
+		Father string `form:"father" assign:"toField:Father"`
+		Mother string `form:"mother" assign:"toField:Mother"`
 	}
 )

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

@@ -18,6 +18,7 @@ type Entity struct {
 	entity.Base
 	Name        string   `sqlmapping:"column:name" sqlresult:"column:name"`
 	FamilyID    string   `sqlmapping:"column:family_id" sqlresult:"column:family_id"`
+	ClassID     []string `sqlmapping:"column:class_id" sqlresult:"column:class_id"`
 	IdentityIDs []string `sqlmapping:"-" sqlresult:"-"`
 	HobbyIDs    []string `sqlmapping:"-" sqlresult:"-"`
 	entity.TimeFields

+ 16 - 1
examples/examples/project/application/domain/student/request_params.go

@@ -37,7 +37,8 @@ type (
 	}
 
 	QueryStudentWithFamilyQueryParams struct {
-		request.IDQuery
+		request.BaseQuery
+		Name string `form:"name" assign:"toField:Name"`
 	}
 
 	UpdateIdentitiesOfStudentJsonBody struct {
@@ -57,4 +58,18 @@ type (
 	QueryHobbiesOfStudentQueryParams struct {
 		request.BaseQueryWithID
 	}
+
+	UpdateClassOfStudentJsonBody struct {
+		request.IDJsonBody
+		ClassID string `json:"classId" assign:"toField:ClassID"`
+	}
+
+	QueryClassOfStudentQueryParams struct {
+		request.BaseQueryWithID
+	}
+
+	QueryStudentWithClassQueryParams struct {
+		request.BaseQuery
+		Name string `form:"name" assign:"toField:Name"`
+	}
 )

+ 34 - 0
examples/examples/project/application/service/class_and_student.go

@@ -0,0 +1,34 @@
+package service
+
+import (
+	"git.sxidc.com/go-framework/baize/convenient/relation/one2many"
+	"git.sxidc.com/go-framework/baize/examples/examples/project/application/domain/class"
+	"git.sxidc.com/go-framework/baize/examples/examples/project/application/domain/student"
+	"git.sxidc.com/go-framework/baize/framwork/application"
+)
+
+type ClassAndStudent struct{}
+
+func (app *ClassAndStudent) Init(appInstance *application.App) error {
+	app.v1(appInstance)
+	return nil
+}
+
+func (app *ClassAndStudent) Destroy() error {
+	return nil
+}
+
+func (app *ClassAndStudent) v1(appInstance *application.App) {
+	v1Binder := appInstance.Binder(application.RouterPrefix, "v1")
+
+	one2many.BindSimple(v1Binder, &one2many.Simple[class.Info, student.Info]{
+		Left:                          &class.Entity{},
+		Right:                         &student.Entity{},
+		Schema:                        dbSchema,
+		LeftUpdateJsonBody:            &class.UpdateStudentsOfClassJsonBody{},
+		LeftQueryQueryParams:          &class.QueryStudentsOfClassQueryParams{},
+		RightUpdateJsonBody:           &student.UpdateClassOfStudentJsonBody{},
+		RightQueryQueryParams:         &student.QueryClassOfStudentQueryParams{},
+		RightQueryWithLeftQueryParams: &student.QueryStudentWithClassQueryParams{},
+	})
+}

+ 5 - 0
examples/examples/project/deployment/data_service/data_containers/student.yaml

@@ -15,6 +15,11 @@ spec:
         comment: 姓名
         not_null: true
         index: true
+      - name: class_id
+        type: varchar(32)
+        comment: 班级ID
+        not_null: true
+        index: true
       - name: family_id
         type: varchar(32)
         comment: 家庭ID