Browse Source

体积小

XMLWAN 3 years ago
parent
commit
9d1f992234

+ 3 - 3
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

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

+ 15 - 0
service/xcx_mobile_api_service.go View File

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
 func Dncrypt(rawData, key, iv string) (string, error) {
161
 func Dncrypt(rawData, key, iv string) (string, error) {
147
 	data, err := base64.StdEncoding.DecodeString(rawData)
162
 	data, err := base64.StdEncoding.DecodeString(rawData)
148
 	key_b, err_1 := base64.StdEncoding.DecodeString(key)
163
 	key_b, err_1 := base64.StdEncoding.DecodeString(key)