完成重构数据库操作代码

This commit is contained in:
dushixiang
2021-03-18 23:36:25 +08:00
parent 0150361054
commit 25b8381a4f
44 changed files with 2292 additions and 2016 deletions

26
server/repository/num.go Normal file
View File

@ -0,0 +1,26 @@
package repository
import (
"gorm.io/gorm"
"next-terminal/server/global"
"next-terminal/server/model"
)
type NumRepository struct {
DB *gorm.DB
}
func NewNumRepository(db *gorm.DB) *NumRepository {
numRepository = &NumRepository{DB: db}
return numRepository
}
func (r NumRepository) FindAll() (o []model.Num, err error) {
err = r.DB.Find(&o).Error
return
}
func (r NumRepository) Create(o *model.Num) (err error) {
err = global.DB.Create(o).Error
return
}