mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 11:47:36 +08:00
37 lines
760 B
Go
37 lines
760 B
Go
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
|
|
}
|