|
|
@@ -2,10 +2,16 @@ package service
|
|
|
|
|
|
import (
|
|
|
"baize-demo/project/server/application/domain/class"
|
|
|
+ "git.sxidc.com/go-framework/baize/convenient/domain/operate_log"
|
|
|
"git.sxidc.com/go-framework/baize/convenient/entity_crud"
|
|
|
"git.sxidc.com/go-framework/baize/framework/binding"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/application"
|
|
|
+ "git.sxidc.com/go-framework/baize/framework/core/domain"
|
|
|
+ "git.sxidc.com/go-framework/baize/framework/core/domain/entity"
|
|
|
+ "git.sxidc.com/go-framework/baize/framework/core/infrastructure"
|
|
|
+ "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database"
|
|
|
+ "git.sxidc.com/service-supports/fslog"
|
|
|
)
|
|
|
|
|
|
var classService = &ClassService{}
|
|
|
@@ -32,5 +38,23 @@ func (svc *ClassService) v1(appInstance *application.App) {
|
|
|
UpdateJsonBody: &class.UpdateClassJsonBody{},
|
|
|
QueryQueryParams: &class.GetClassesQueryParams{},
|
|
|
GetByIDQueryParams: &class.GetClassByIDQueryParams{},
|
|
|
- })
|
|
|
+ }, entity_crud.WithCreateCallbacks(&entity_crud.CreateCallbacks{
|
|
|
+ After: func(c *api.Context, e entity.Entity, prepared map[string]any, i *infrastructure.Infrastructure, tx database.Executor) error {
|
|
|
+ go func() {
|
|
|
+ classEntity, err := domain.ToConcrete[*class.Entity](e)
|
|
|
+ if err != nil {
|
|
|
+ fslog.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = operate_log.WriteLog(i.DBExecutor(), dbSchema, "create", classEntity)
|
|
|
+ if err != nil {
|
|
|
+ fslog.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ return nil
|
|
|
+ },
|
|
|
+ }))
|
|
|
}
|