mysql_hubimage_confs.go 1.0 KB

12345678910111213141516171819202122232425262728
  1. package dao
  2. import (
  3. "go-common/app/admin/ep/merlin/model"
  4. "go-common/library/ecode"
  5. pkgerr "github.com/pkg/errors"
  6. )
  7. // InsertHubImageConf Insert Hub Image conf.
  8. func (d *Dao) InsertHubImageConf(hubImageConf *model.HubImageConf) (err error) {
  9. return pkgerr.WithStack(d.db.Create(hubImageConf).Error)
  10. }
  11. // UpdateHubImageConf Update Hub Image Conf.
  12. func (d *Dao) UpdateHubImageConf(hubImageConf *model.HubImageConf) (err error) {
  13. return pkgerr.WithStack(d.db.Model(&model.HubImageConf{}).Where("image_name=?", hubImageConf.ImageName).Updates(map[string]interface{}{
  14. "update_by": hubImageConf.UpdateBy, "command": hubImageConf.Command, "environments": hubImageConf.Envs, "hosts": hubImageConf.Hosts}).Error)
  15. }
  16. // FindHubImageConfByImageName Find Hub Image Conf By Image Name.
  17. func (d *Dao) FindHubImageConfByImageName(imageName string) (hubImageConf *model.HubImageConf, err error) {
  18. hubImageConf = &model.HubImageConf{}
  19. if err = d.db.Where("image_name = ?", imageName).First(hubImageConf).Error; err == ecode.NothingFound {
  20. err = nil
  21. }
  22. return
  23. }