area_code.go 539 B

1234567891011121314151617181920212223
  1. package user
  2. import (
  3. "eta/eta_mini_ht_api/models"
  4. )
  5. type AreaCode struct {
  6. CodeName string `gorm:"type:varchar(10);default:null"`
  7. CodeValue string `gorm:"type:varchar(10);default:null"`
  8. Enable bool `gorm:"type:tinyint(1);default:1"`
  9. }
  10. func GetAreaCodes() (list []AreaCode, err error) {
  11. db := models.Main()
  12. err = db.Model(&AreaCode{}).Find(&list).Error
  13. return
  14. }
  15. func GetValidAreaCodes() (list []AreaCode, err error) {
  16. db := models.Main()
  17. err = db.Model(&AreaCode{}).Where("enable = ?", true).Find(&list).Error
  18. return
  19. }