xcx_mobile_api_service.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package service
  2. import (
  3. "Xcx_New/models"
  4. "github.com/jinzhu/gorm"
  5. )
  6. func GetXcxMobileInformation(mobile string) (*models.XcxAdminUserRole, error) {
  7. role := models.XcxAdminUserRole{}
  8. err := UserReadDB().Model(&role).Where("mobile = ? and status = 1", mobile).Find(&role).Error
  9. if err == gorm.ErrRecordNotFound {
  10. return nil, err
  11. }
  12. if err != nil {
  13. return nil, err
  14. }
  15. return &role, nil
  16. }
  17. func CreateXcxAdminUser(role models.XcxAdminUserRole) error {
  18. err := UserReadDB().Create(&role).Error
  19. return err
  20. }
  21. func GetLoginInfor(mobile string) (models.XcxAdminUserRole, error) {
  22. role := models.XcxAdminUserRole{}
  23. err := UserReadDB().Model(&role).Where("mobile = ? and status = 1", mobile).Find(&role).Error
  24. return role, err
  25. }
  26. func GetMobilePatientInfo(mobile string) (models.XcxPatients, error) {
  27. patients := models.XcxPatients{}
  28. err := XTReadDB().Model(&patients).Where("(phone = ? or home_telephone = ? ) and status = 1", mobile, mobile).Find(&patients).Error
  29. //if err == gorm.ErrRecordNotFound {
  30. // return nil, err
  31. //}
  32. //
  33. //if err != nil {
  34. // return nil, err
  35. //}
  36. return patients, err
  37. }