完成重构数据库操作代码

This commit is contained in:
dushixiang
2021-03-19 20:22:04 +08:00
parent 25b8381a4f
commit 2eb4dc3969
37 changed files with 294 additions and 329 deletions

View File

@ -3,7 +3,6 @@ package repository
import (
"gorm.io/gorm"
"next-terminal/server/constant"
"next-terminal/server/global"
"next-terminal/server/model"
)
@ -68,13 +67,13 @@ func (r CommandRepository) Create(o *model.Command) (err error) {
}
func (r CommandRepository) FindById(id string) (o model.Command, err error) {
err = global.DB.Where("id = ?", id).First(&o).Error
err = r.DB.Where("id = ?", id).First(&o).Error
return
}
func (r CommandRepository) UpdateById(o *model.Command, id string) {
func (r CommandRepository) UpdateById(o *model.Command, id string) error {
o.ID = id
global.DB.Updates(o)
return r.DB.Updates(o).Error
}
func (r CommandRepository) DeleteById(id string) error {