package repository import ( "context" "next-terminal/server/model" ) var AssetGroupRepository = new(assetGroupRepository) type assetGroupRepository struct { baseRepository } func (r assetGroupRepository) FindAll(c context.Context) (o []model.AssetGroup, err error) { err = r.GetDB(c).Order("sort asc, created asc").Find(&o).Error return } func (r assetGroupRepository) Create(c context.Context, o *model.AssetGroup) error { return r.GetDB(c).Create(o).Error } func (r assetGroupRepository) UpdateById(c context.Context, o *model.AssetGroup, id string) error { o.ID = id return r.GetDB(c).Updates(o).Error } func (r assetGroupRepository) DeleteById(c context.Context, id string) error { return r.GetDB(c).Where("id = ?", id).Delete(&model.AssetGroup{}).Error } func (r assetGroupRepository) DeleteByParentId(c context.Context, parentId string) error { return r.GetDB(c).Where("parent_id = ?", parentId).Delete(&model.AssetGroup{}).Error }