mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-27 03:20:25 +08:00
refactor: 代码重构、分页数据组件支持多选
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/gormx"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -14,19 +15,20 @@ func newMachineScriptRepo() repository.MachineScript {
|
||||
}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineScriptRepoImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
|
||||
func (m *machineScriptRepoImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult[any] {
|
||||
qd := gormx.NewQuery(condition).WithCondModel(condition).WithOrderBy(orderBy...)
|
||||
return gormx.PageQuery(qd, pageParam, toEntity)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (m *machineScriptRepoImpl) GetMachineScript(condition *entity.MachineScript, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
return gormx.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptRepoImpl) GetById(id uint64, cols ...string) *entity.MachineScript {
|
||||
ms := new(entity.MachineScript)
|
||||
if err := model.GetById(ms, id, cols...); err != nil {
|
||||
if err := gormx.GetById(ms, id, cols...); err != nil {
|
||||
return nil
|
||||
|
||||
}
|
||||
@@ -35,13 +37,13 @@ func (m *machineScriptRepoImpl) GetById(id uint64, cols ...string) *entity.Machi
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptRepoImpl) Delete(id uint64) {
|
||||
biz.ErrIsNil(model.DeleteById(new(entity.MachineScript), id), "删除失败")
|
||||
biz.ErrIsNil(gormx.DeleteById(new(entity.MachineScript), id), "删除失败")
|
||||
}
|
||||
|
||||
func (m *machineScriptRepoImpl) Create(entity *entity.MachineScript) {
|
||||
model.Insert(entity)
|
||||
gormx.Insert(entity)
|
||||
}
|
||||
|
||||
func (m *machineScriptRepoImpl) UpdateById(entity *entity.MachineScript) {
|
||||
model.UpdateById(entity)
|
||||
gormx.UpdateById(entity)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user