2021-05-08 18:00:33 +08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"mayfly-go/base/model"
|
2021-06-07 17:22:07 +08:00
|
|
|
"mayfly-go/server/devops/domain/entity"
|
|
|
|
|
"mayfly-go/server/devops/domain/repository"
|
2021-05-08 18:00:33 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type machineRepo struct{}
|
|
|
|
|
|
|
|
|
|
var MachineDao repository.Machine = &machineRepo{}
|
|
|
|
|
|
|
|
|
|
// 分页获取机器信息列表
|
2021-07-28 18:03:19 +08:00
|
|
|
func (m *machineRepo) GetMachineList(condition *entity.Machine, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
2021-05-08 18:00:33 +08:00
|
|
|
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-11 14:04:09 +08:00
|
|
|
func (m *machineRepo) Count(condition *entity.Machine) int64 {
|
|
|
|
|
return model.CountBy(condition)
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-08 18:00:33 +08:00
|
|
|
// 根据条件获取账号信息
|
|
|
|
|
func (m *machineRepo) GetMachine(condition *entity.Machine, cols ...string) error {
|
|
|
|
|
return model.GetBy(condition, cols...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据id获取
|
|
|
|
|
func (m *machineRepo) GetById(id uint64, cols ...string) *entity.Machine {
|
|
|
|
|
machine := new(entity.Machine)
|
|
|
|
|
if err := model.GetById(machine, id, cols...); err != nil {
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return machine
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *machineRepo) Create(entity *entity.Machine) {
|
|
|
|
|
model.Insert(entity)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *machineRepo) UpdateById(entity *entity.Machine) {
|
|
|
|
|
model.UpdateById(entity)
|
|
|
|
|
}
|