Rainbond/db/mysql/dao/tenant_application.go

37 lines
760 B
Go
Raw Normal View History

2020-09-17 15:45:46 +08:00
package dao
import (
"github.com/goodrain/rainbond/db/model"
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
)
// TenantApplicationDaoImpl -
type TenantApplicationDaoImpl struct {
DB *gorm.DB
}
//AddModel -
func (a *TenantApplicationDaoImpl) AddModel(mo model.Interface) error {
appReq, ok := mo.(*model.Application)
if !ok {
return errors.New("Failed to convert interface to App")
}
var oldApp model.Application
if err := a.DB.Where("tenantID = ? AND appID = ?", appReq.TenantID, appReq.AppID).Find(&oldApp).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return a.DB.Create(appReq).Error
}
return err
}
return nil
}
//UpdateModel -
func (a *TenantApplicationDaoImpl) UpdateModel(mo model.Interface) error {
return nil
}