mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-23 17:40:25 +08:00
refactor: 新增base.Repo与base.App,重构repo与app层代码
This commit is contained in:
@@ -3,37 +3,23 @@ package persistence
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/base"
|
||||
"mayfly-go/pkg/gormx"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type configRepoImpl struct{}
|
||||
|
||||
func newConfigRepo() repository.Config {
|
||||
return new(configRepoImpl)
|
||||
type configRepoImpl struct {
|
||||
base.RepoImpl[*entity.Config]
|
||||
}
|
||||
|
||||
func (m *configRepoImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult[any] {
|
||||
func newConfigRepo() repository.Config {
|
||||
return &configRepoImpl{base.RepoImpl[*entity.Config]{M: new(entity.Config)}}
|
||||
}
|
||||
|
||||
func (m *configRepoImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
||||
qd := gormx.NewQuery(condition).
|
||||
Eq("key", condition.Key).
|
||||
And("permission = 'all' OR permission LIKE ?", "%"+condition.Permission+",%").
|
||||
WithOrderBy(orderBy...)
|
||||
return gormx.PageQuery(qd, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (m *configRepoImpl) Insert(config *entity.Config) {
|
||||
biz.ErrIsNil(gormx.Insert(config), "新增系统配置失败")
|
||||
}
|
||||
|
||||
func (m *configRepoImpl) Update(config *entity.Config) {
|
||||
biz.ErrIsNil(gormx.UpdateById(config), "更新系统配置失败")
|
||||
}
|
||||
|
||||
func (m *configRepoImpl) GetConfig(condition *entity.Config, cols ...string) error {
|
||||
return gormx.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
func (r *configRepoImpl) GetByCondition(condition *entity.Config, cols ...string) error {
|
||||
return gormx.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user