mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-13 04:40:24 +08:00
refactor: 新增base.Repo与base.App,重构repo与app层代码
This commit is contained in:
@@ -3,49 +3,26 @@ package persistence
|
||||
import (
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/base"
|
||||
"mayfly-go/pkg/gormx"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type authCertRepoImpl struct{}
|
||||
|
||||
func newAuthCertRepo() repository.AuthCert {
|
||||
return new(authCertRepoImpl)
|
||||
type authCertRepoImpl struct {
|
||||
base.RepoImpl[*entity.AuthCert]
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) GetPageList(condition *entity.AuthCertQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult[any] {
|
||||
func newAuthCertRepo() repository.AuthCert {
|
||||
return &authCertRepoImpl{base.RepoImpl[*entity.AuthCert]{M: new(entity.AuthCert)}}
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) GetPageList(condition *entity.AuthCertQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
||||
qd := gormx.NewQuery(new(entity.AuthCert)).WithCondModel(condition).WithOrderBy(orderBy...)
|
||||
return gormx.PageQuery(qd, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) Insert(ac *entity.AuthCert) {
|
||||
biz.ErrIsNil(gormx.Insert(ac), "新增授权凭证失败")
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) Update(ac *entity.AuthCert) {
|
||||
biz.ErrIsNil(gormx.UpdateById(ac), "更新授权凭证失败")
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) GetById(id uint64) *entity.AuthCert {
|
||||
ac := new(entity.AuthCert)
|
||||
err := gormx.GetById(ac, id)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return ac
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) GetByIds(ids ...uint64) []*entity.AuthCert {
|
||||
acs := new([]*entity.AuthCert)
|
||||
gormx.GetByIdIn(new(entity.AuthCert), acs, ids)
|
||||
return *acs
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) GetByCondition(condition *entity.AuthCert, cols ...string) error {
|
||||
return gormx.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
func (m *authCertRepoImpl) DeleteById(id uint64) {
|
||||
gormx.DeleteById(new(entity.AuthCert), id)
|
||||
}
|
||||
// func (m *authCertRepoImpl) GetByIds(ids ...uint64) []*entity.AuthCert {
|
||||
// acs := new([]*entity.AuthCert)
|
||||
// gormx.GetByIdIn(new(entity.AuthCert), acs, ids)
|
||||
// return *acs
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user