feat: 添加数据库资产、命令拦截器、授权资产等功能,修复GitHub Actions工作流
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"next-terminal/server/common"
|
||||
"next-terminal/server/model"
|
||||
)
|
||||
|
||||
var WebsiteGroupRepository = new(websiteGroupRepository)
|
||||
|
||||
type websiteGroupRepository struct {
|
||||
baseRepository
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) FindAll(c context.Context) (o []model.WebsiteGroup, err error) {
|
||||
err = r.GetDB(c).Order("sort asc, name asc").Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) FindById(c context.Context, id string) (o model.WebsiteGroup, err error) {
|
||||
err = r.GetDB(c).Where("id = ?", id).First(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) Create(c context.Context, o *model.WebsiteGroup) error {
|
||||
o.Created = common.NowJsonTime()
|
||||
return r.GetDB(c).Create(o).Error
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) UpdateById(c context.Context, o *model.WebsiteGroup) error {
|
||||
return r.GetDB(c).Updates(o).Error
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) DeleteById(c context.Context, id string) error {
|
||||
return r.GetDB(c).Where("id = ?", id).Delete(&model.WebsiteGroup{}).Error
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) DeleteByParentId(c context.Context, parentId string) error {
|
||||
return r.GetDB(c).Where("parent_id = ?", parentId).Delete(&model.WebsiteGroup{}).Error
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) CountByParentId(c context.Context, parentId string) (total int64, err error) {
|
||||
err = r.GetDB(c).Model(&model.WebsiteGroup{}).Where("parent_id = ?", parentId).Count(&total).Error
|
||||
return
|
||||
}
|
||||
|
||||
func (r websiteGroupRepository) DeleteAll(c context.Context) error {
|
||||
return r.GetDB(c).Where("1 = 1").Delete(&model.WebsiteGroup{}).Error
|
||||
}
|
||||
Reference in New Issue
Block a user