2022-09-09 18:26:08 +08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"mayfly-go/internal/machine/domain/entity"
|
|
|
|
|
"mayfly-go/internal/machine/domain/repository"
|
2023-07-01 14:34:42 +08:00
|
|
|
"mayfly-go/pkg/gormx"
|
2022-09-09 18:26:08 +08:00
|
|
|
"mayfly-go/pkg/model"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type machineFileRepoImpl struct{}
|
|
|
|
|
|
|
|
|
|
func newMachineFileRepo() repository.MachineFile {
|
|
|
|
|
return new(machineFileRepoImpl)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 分页获取机器文件信息列表
|
2023-10-26 17:15:49 +08:00
|
|
|
func (m *machineFileRepoImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
2023-07-01 14:34:42 +08:00
|
|
|
qd := gormx.NewQuery(condition).WithCondModel(condition).WithOrderBy(orderBy...)
|
|
|
|
|
return gormx.PageQuery(qd, pageParam, toEntity)
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据条件获取账号信息
|
|
|
|
|
func (m *machineFileRepoImpl) GetMachineFile(condition *entity.MachineFile, cols ...string) error {
|
2023-07-01 14:34:42 +08:00
|
|
|
return gormx.GetBy(condition, cols...)
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据id获取
|
|
|
|
|
func (m *machineFileRepoImpl) GetById(id uint64, cols ...string) *entity.MachineFile {
|
|
|
|
|
ms := new(entity.MachineFile)
|
2023-07-01 14:34:42 +08:00
|
|
|
if err := gormx.GetById(ms, id, cols...); err != nil {
|
2022-09-09 18:26:08 +08:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return ms
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据id获取
|
2023-10-26 17:15:49 +08:00
|
|
|
func (m *machineFileRepoImpl) Delete(id uint64) error {
|
|
|
|
|
return gormx.DeleteById(new(entity.MachineFile), id)
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
func (m *machineFileRepoImpl) Create(entity *entity.MachineFile) error {
|
|
|
|
|
return gormx.Insert(entity)
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
func (m *machineFileRepoImpl) UpdateById(entity *entity.MachineFile) error {
|
|
|
|
|
return gormx.UpdateById(entity)
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|