team.go 575 B

123456789101112131415161718192021
  1. package service
  2. import (
  3. "go-common/app/admin/main/config/model"
  4. "go-common/library/log"
  5. )
  6. // CreateTeam create App.
  7. func (s *Service) CreateTeam(name, env, zone string) error {
  8. app := &model.Team{Name: name, Env: env, Zone: zone}
  9. return s.dao.DB.Create(app).Error
  10. }
  11. //TeamByName get team by Name.
  12. func (s *Service) TeamByName(name, env, zone string) (team *model.Team, err error) {
  13. team = &model.Team{}
  14. if err = s.dao.DB.FirstOrCreate(&team, &model.Team{Name: name, Env: env, Zone: zone}).Error; err != nil {
  15. log.Error("TeamByName() error(%v)", err)
  16. }
  17. return
  18. }