mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-18 07:10:26 +08:00
refactor: 新增base.Repo与base.App,重构repo与app层代码
This commit is contained in:
@@ -3,44 +3,21 @@ 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 machineCropJobRepoImpl struct{}
|
||||
type machineCropJobRepoImpl struct {
|
||||
base.RepoImpl[*entity.MachineCronJob]
|
||||
}
|
||||
|
||||
func newMachineCronJobRepo() repository.MachineCronJob {
|
||||
return new(machineCropJobRepoImpl)
|
||||
return &machineCropJobRepoImpl{base.RepoImpl[*entity.MachineCronJob]{M: new(entity.MachineCronJob)}}
|
||||
}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineCropJobRepoImpl) GetPageList(condition *entity.MachineCronJob, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult[any] {
|
||||
func (m *machineCropJobRepoImpl) GetPageList(condition *entity.MachineCronJob, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
||||
qd := gormx.NewQuery(condition).Like("name", condition.Name).Eq("status", condition.Status).WithOrderBy(orderBy...)
|
||||
return gormx.PageQuery(qd, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (m *machineCropJobRepoImpl) GetBy(cond *entity.MachineCronJob, cols ...string) error {
|
||||
return gormx.GetBy(cond, cols...)
|
||||
}
|
||||
|
||||
func (m *machineCropJobRepoImpl) GetById(id uint64, cols ...string) *entity.MachineCronJob {
|
||||
res := new(entity.MachineCronJob)
|
||||
if err := gormx.GetById(res, id, cols...); err == nil {
|
||||
return res
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *machineCropJobRepoImpl) Delete(id uint64) {
|
||||
biz.ErrIsNil(gormx.DeleteById(new(entity.MachineCronJob), id), "删除失败")
|
||||
}
|
||||
|
||||
func (m *machineCropJobRepoImpl) Insert(entity *entity.MachineCronJob) {
|
||||
gormx.Insert(entity)
|
||||
}
|
||||
|
||||
func (m *machineCropJobRepoImpl) UpdateById(entity *entity.MachineCronJob) {
|
||||
gormx.UpdateById(entity)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user