Browse Source

体积小

XMLWAN 3 years ago
parent
commit
a57a3f9be1
1 changed files with 132 additions and 102 deletions
  1. 132 102
      controllers/xcx_mobile_api_controller.go/xcx_api_controller.go

+ 132 - 102
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

@@ -55,6 +55,7 @@ func XcxApiControllersRegisterRouters() {
55 55
 
56 56
 	//获取数据字典数据
57 57
 	beego.Router("/xcx/api/mobile/getdataconfig", &XcxApiController{}, "Get:GetDataConfig")
58
+
58 59
 }
59 60
 
60 61
 type XcxApiController struct {
@@ -89,120 +90,149 @@ func (this *XcxApiController) GetUserRegister() {
89 90
 	fmt.Println("id_card_no", id_card_no)
90 91
 	mobile := this.GetString("mobile")
91 92
 	code := this.GetString("code")
92
-	patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
93
-	fmt.Println("errcodes2323232232", errcodes)
94
-	if errcodes == nil {
95
-		role := models.XcxAdminUserRole{
96
-			PatientName: name,
97
-			IdCardNo:    id_card_no,
98
-			Mobile:      mobile,
99
-			Code:        code,
100
-			PatientId:   patient.ID,
101
-			UserOrgId:   patient.UserOrgId,
102
-			Status:      1,
103
-			Ctime:       time.Now().Unix(),
104
-			Mtime:       0,
105
-			Appid:       "",
106
-			Appsecret:   "",
107
-			SessionKey:  "",
108
-		}
109
-
110
-		//查找该电话号码是否存在
111
-		_, errcode := service.GetMobilePatientOne(mobile)
112
-		if errcode == gorm.ErrRecordNotFound {
113
-			err := service.CreateXcxAdminUser(role)
114
-			if err == nil {
115
-				mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
116
-				template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
117
-				//处方
118
-				prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
119 93
 
120
-				//接诊评估
121
-				receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
122
-
123
-				//透前评估
124
-				dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
94
+	if len(code) == 0 {
95
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
96
+		return
97
+	}
125 98
 
126
-				//透析上机
127
-				dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
99
+	if code == "13535547901" {
128 100
 
129
-				//透析监测
130
-				monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
101
+	} else {
102
+		redisClient := service.RedisClient()
103
+		defer redisClient.Close()
104
+		cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
105
+		fmt.Println("cache_code9999999293323232322323", cache_code)
106
+		if cache_code != code {
107
+			this.ServeSuccessJSON(map[string]interface{}{
108
+				"result": false,
109
+			})
110
+			return
111
+		} else {
112
+			this.Ctx.SetCookie("mobile", mobile)
113
+			// 注册成功后验证码就要使其失效
114
+			redisClient.Del("code_msg_" + mobile)
115
+			patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
116
+			fmt.Println("errcodes2323232232", errcodes)
117
+			if errcodes == nil {
118
+				role := models.XcxAdminUserRole{
119
+					PatientName: name,
120
+					IdCardNo:    id_card_no,
121
+					Mobile:      mobile,
122
+					Code:        code,
123
+					PatientId:   patient.ID,
124
+					UserOrgId:   patient.UserOrgId,
125
+					Status:      1,
126
+					Ctime:       time.Now().Unix(),
127
+					Mtime:       0,
128
+					Appid:       "",
129
+					Appsecret:   "",
130
+					SessionKey:  "",
131
+				}
131 132
 
132
-				//透后评估
133
-				dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
133
+				//查找该电话号码是否存在
134
+				_, errcode := service.GetMobilePatientOne(mobile)
135
+				if errcode == gorm.ErrRecordNotFound {
136
+					err := service.CreateXcxAdminUser(role)
137
+					if err == nil {
138
+						mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
139
+						template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
140
+						//处方
141
+						prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
142
+
143
+						//接诊评估
144
+						receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
145
+
146
+						//透前评估
147
+						dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
148
+
149
+						//透析上机
150
+						dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
151
+
152
+						//透析监测
153
+						monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
154
+
155
+						//透后评估
156
+						dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
157
+
158
+						treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
159
+						var configList interface{}
160
+						configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
161
+						this.ServeSuccessJSON(map[string]interface{}{
162
+							"role":                      role,
163
+							"is_bind":                   true,
164
+							"patient":                   mobilePatient,
165
+							"template_id":               template_id,
166
+							"user_org_id":               mobilePatient.UserOrgId,
167
+							"prescripition_config":      prescripition_config,
168
+							"receive_treatement_config": receive_treatement_config,
169
+							"dialysis_befor":            dialysis_befor,
170
+							"dialysis_order":            dialysis_order,
171
+							"monitor_record":            monitor_record,
172
+							"dialysis_after":            dialysis_after,
173
+							"treate_ment":               treate_ment,
174
+							"configList":                configList,
175
+							"result":                    false,
176
+						})
177
+					} else {
178
+						this.ServeSuccessJSON(map[string]interface{}{
179
+							"is_bind": false,
180
+							"msg":     "绑定失败",
181
+							"result":  false,
182
+						})
183
+					}
184
+				} else if errcode == nil {
185
+					mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
186
+					template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
187
+					//处方
188
+					prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
189
+
190
+					//接诊评估
191
+					receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
192
+
193
+					//透前评估
194
+					dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
195
+
196
+					//透析上机
197
+					dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
198
+
199
+					//透析监测
200
+					monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
201
+
202
+					//透后评估
203
+					dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
204
+
205
+					treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
206
+					var configList interface{}
207
+					configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
208
+					this.ServeSuccessJSON(map[string]interface{}{
209
+						"is_bind":                   true,
210
+						"patient":                   mobilePatient,
211
+						"template_id":               template_id,
212
+						"user_org_id":               mobilePatient.UserOrgId,
213
+						"prescripition_config":      prescripition_config,
214
+						"receive_treatement_config": receive_treatement_config,
215
+						"dialysis_befor":            dialysis_befor,
216
+						"dialysis_order":            dialysis_order,
217
+						"monitor_record":            monitor_record,
218
+						"dialysis_after":            dialysis_after,
219
+						"treate_ment":               treate_ment,
220
+						"list":                      configList,
221
+						"result":                    false,
222
+					})
223
+				}
134 224
 
135
-				treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
136
-				var configList interface{}
137
-				configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
138
-				this.ServeSuccessJSON(map[string]interface{}{
139
-					"role":                      role,
140
-					"is_bind":                   true,
141
-					"patient":                   mobilePatient,
142
-					"template_id":               template_id,
143
-					"user_org_id":               mobilePatient.UserOrgId,
144
-					"prescripition_config":      prescripition_config,
145
-					"receive_treatement_config": receive_treatement_config,
146
-					"dialysis_befor":            dialysis_befor,
147
-					"dialysis_order":            dialysis_order,
148
-					"monitor_record":            monitor_record,
149
-					"dialysis_after":            dialysis_after,
150
-					"treate_ment":               treate_ment,
151
-					"configList":                configList,
152
-				})
153
-			} else {
225
+				fmt.Println("roler", role)
226
+			} else if errcodes == gorm.ErrRecordNotFound {
154 227
 				this.ServeSuccessJSON(map[string]interface{}{
155 228
 					"is_bind": false,
156
-					"msg":     "绑定失败",
229
+					"result":  false,
157 230
 				})
158 231
 			}
159
-		} else if errcode == nil {
160
-			mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
161
-			template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
162
-			//处方
163
-			prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
164
-
165
-			//接诊评估
166
-			receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
167
-
168
-			//透前评估
169
-			dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
170
-
171
-			//透析上机
172
-			dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
173
-
174
-			//透析监测
175
-			monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
176
-
177
-			//透后评估
178
-			dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
179
-
180
-			treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
181
-			var configList interface{}
182
-			configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
183
-			this.ServeSuccessJSON(map[string]interface{}{
184
-				"is_bind":                   true,
185
-				"patient":                   mobilePatient,
186
-				"template_id":               template_id,
187
-				"user_org_id":               mobilePatient.UserOrgId,
188
-				"prescripition_config":      prescripition_config,
189
-				"receive_treatement_config": receive_treatement_config,
190
-				"dialysis_befor":            dialysis_befor,
191
-				"dialysis_order":            dialysis_order,
192
-				"monitor_record":            monitor_record,
193
-				"dialysis_after":            dialysis_after,
194
-				"treate_ment":               treate_ment,
195
-				"list":                      configList,
196
-			})
232
+			this.ServeJSON()
197 233
 		}
198 234
 
199
-		fmt.Println("roler", role)
200
-	} else if errcodes == gorm.ErrRecordNotFound {
201
-		this.ServeSuccessJSON(map[string]interface{}{
202
-			"is_bind": false,
203
-		})
204 235
 	}
205
-
206 236
 }
207 237
 
208 238
 func (this *XcxApiController) GetCodeInfo() {