refactor: 新增base.Repo与base.App,重构repo与app层代码

This commit is contained in:
meilin.huang
2023-10-26 17:15:49 +08:00
parent 10f6b03fb5
commit a1303b52eb
115 changed files with 1867 additions and 1696 deletions

View File

@@ -3,27 +3,21 @@ package persistence
import (
"mayfly-go/internal/db/domain/entity"
"mayfly-go/internal/db/domain/repository"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/base"
"mayfly-go/pkg/gormx"
"mayfly-go/pkg/model"
)
type dbSqlExecRepoImpl struct{}
type dbSqlExecRepoImpl struct {
base.RepoImpl[*entity.DbSqlExec]
}
func newDbSqlExecRepo() repository.DbSqlExec {
return new(dbSqlExecRepoImpl)
}
func (d *dbSqlExecRepoImpl) Insert(dse *entity.DbSqlExec) {
gormx.Insert(dse)
}
func (d *dbSqlExecRepoImpl) DeleteBy(condition *entity.DbSqlExec) {
biz.ErrIsNil(gormx.DeleteByCondition(condition), "删除sql执行记录失败")
return &dbSqlExecRepoImpl{base.RepoImpl[*entity.DbSqlExec]{M: new(entity.DbSqlExec)}}
}
// 分页获取
func (d *dbSqlExecRepoImpl) GetPageList(condition *entity.DbSqlExecQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult[any] {
func (d *dbSqlExecRepoImpl) GetPageList(condition *entity.DbSqlExecQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
qd := gormx.NewQuery(new(entity.DbSqlExec)).WithCondModel(condition).WithOrderBy(orderBy...)
return gormx.PageQuery(qd, pageParam, toEntity)
}