enterprise.go 485 B

12345678910111213141516171819202122
  1. package db
  2. import (
  3. "context"
  4. "gorm.io/gorm"
  5. "youngee_m_api/model/gorm_model"
  6. )
  7. //企业ID查找
  8. func GetEnterpriseByEnterpriseID(ctx context.Context, EnterpriseID int64) (*gorm_model.Enterprise, error) {
  9. db := GetReadDB(ctx)
  10. enterprise := gorm_model.Enterprise{}
  11. err := db.Where("enterprise_id = ?", EnterpriseID).First(&enterprise).Error
  12. if err != nil {
  13. if err == gorm.ErrRecordNotFound {
  14. return nil, nil
  15. } else {
  16. return nil, err
  17. }
  18. }
  19. return &enterprise, nil
  20. }