XMLWAN před 3 roky
rodič
revize
9d1f992234

+ 3 - 3
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go Zobrazit soubor

@@ -108,11 +108,11 @@ func (this *XcxApiController) GetUserRegister() {
108 108
 		}
109 109
 
110 110
 		//查找该电话号码是否存在
111
-		_, errcode := service.GetMobilePatient(mobile)
111
+		_, errcode := service.GetMobilePatientOne(mobile)
112 112
 		if errcode == gorm.ErrRecordNotFound {
113 113
 			err := service.CreateXcxAdminUser(role)
114 114
 			if err == nil {
115
-				mobilePatient, _ := service.GetMobilePatient(id_card_no)
115
+				mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
116 116
 				this.ServeSuccessJSON(map[string]interface{}{
117 117
 					"role":    role,
118 118
 					"is_bind": true,
@@ -125,7 +125,7 @@ func (this *XcxApiController) GetUserRegister() {
125 125
 				})
126 126
 			}
127 127
 		} else if errcode == nil {
128
-			mobilePatient, _ := service.GetMobilePatient(id_card_no)
128
+			mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
129 129
 			this.ServeSuccessJSON(map[string]interface{}{
130 130
 				"is_bind": true,
131 131
 				"patient": mobilePatient,

+ 15 - 0
service/xcx_mobile_api_service.go Zobrazit soubor

@@ -143,6 +143,21 @@ func GetMobilePatient(mobile string, idcard string) (*models.XcxPatients, error)
143 143
 
144 144
 }
145 145
 
146
+func GetMobilePatientOne(mobile string) (*models.XcxAdminUserRole, error) {
147
+
148
+	patient := models.XcxAdminUserRole{}
149
+	err := XTReadDB().Model(&patient).Where("mobile = ? and status = 1", mobile).Find(&patient).Error
150
+	if err == gorm.ErrRecordNotFound {
151
+		return nil, err
152
+	}
153
+
154
+	if err != nil {
155
+		return nil, err
156
+	}
157
+	return &patient, nil
158
+
159
+}
160
+
146 161
 func Dncrypt(rawData, key, iv string) (string, error) {
147 162
 	data, err := base64.StdEncoding.DecodeString(rawData)
148 163
 	key_b, err_1 := base64.StdEncoding.DecodeString(key)