Преглед изворни кода

Merge branch 'master' of http://git.shengws.com/csx/XT_New

csx пре 4 година
родитељ
комит
9401e30f14

+ 15 - 0
controllers/mobile_api_controllers/mobile_api_base_controller.go Прегледај датотеку

@@ -165,3 +165,18 @@ func RemoveRepeatedPurviewElement(arr []string) (newArr []string) {
165 165
 	}
166 166
 	return
167 167
 }
168
+
169
+type AdminUserInfo struct {
170
+	AdminUser    *models.AdminUser                    `json:"user"`
171
+	CurrentOrgId int64                                `json:"current_org_id"`
172
+	CurrentAppId int64                                `json:"current_app_id"`
173
+	OrgIds       []int64                              `json:"org_ids"`
174
+	Orgs         map[int64]*models.Org                `json:"orgs"`
175
+	OrgAppIds    map[int64][]int64                    `json:"org_app_ids"`
176
+	OrgApps      map[int64](map[int64]*models.OrgApp) `json:"org_apps"`
177
+	App2OrgIds   map[int64]int64                      `json:"app_to_org_ids"`
178
+	AppRoles     map[int64]*models.App_Role           `json:"app_roles"`
179
+	AppPurviews  map[int64][]*models.Purview          `json:"app_purviews"`
180
+	AppUrlfors   map[int64][]string                   `json:"app_urlfors"`
181
+	Subscibes    map[int64]*models.ServeSubscibe      `json:"org_subscibes"`
182
+}

+ 38 - 6
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Прегледај датотеку

@@ -5,8 +5,10 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"crypto/md5"
8 9
 	"encoding/json"
9 10
 	"fmt"
11
+	"github.com/astaxie/beego"
10 12
 	"github.com/jinzhu/gorm"
11 13
 	"strconv"
12 14
 	"strings"
@@ -242,7 +244,7 @@ func (this *NewDialysisApiController) SavePatient() {
242 244
 	fmt.Print("治疗方式", treatmentmethod)
243 245
 
244 246
 	//查询身份证号码是否存在
245
-	thisPatientOne, _ := service.FindPatientByIdCardNoOne(orgid, idCard)
247
+	thisPatientOne, _ := service.FindPatientByIdCardNoFive(orgid, idCard)
246 248
 	if thisPatientOne.ID > 0 {
247 249
 		returnData := make(map[string]interface{}, 0)
248 250
 		returnData["msg"] = "身份证号码已存在"
@@ -251,7 +253,7 @@ func (this *NewDialysisApiController) SavePatient() {
251 253
 	}
252 254
 
253 255
 	//查询手机号码是否存在
254
-	thisPatient, err := service.FindPatientByMobileOne(phone, orgid)
256
+	thisPatient, err := service.FindPatientByMobileFive(phone, orgid)
255 257
 	if thisPatient.ID > 0 {
256 258
 		returnData := make(map[string]interface{}, 0)
257 259
 		returnData["msg"] = "手机号码已存在"
@@ -261,7 +263,7 @@ func (this *NewDialysisApiController) SavePatient() {
261 263
 	//如果是血透病人
262 264
 	if bloodPatient == 1 {
263 265
 		//查询透析号是否存在
264
-		thisPatientTwo, _ := service.FindPatientByDialysisNoOne(orgid, dialysis)
266
+		thisPatientTwo, _ := service.FindPatientByDialysisNoFive(orgid, dialysis)
265 267
 		if thisPatientTwo.ID > 0 {
266 268
 			returnData := make(map[string]interface{}, 0)
267 269
 			returnData["msg"] = "透析号已存在"
@@ -1293,7 +1295,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1293 1295
 		patient, _ := service.GetNewPatient(id)
1294 1296
 
1295 1297
 		//判断身份证号是否相同
1296
-		thisPatient, _ := service.FindPatientByIdCardNoOne(orgid, idCard)
1298
+		thisPatient, _ := service.FindPatientByIdCardNoOne(orgid, idCard, id)
1297 1299
 		if thisPatient.ID > 0 && thisPatient.ID != patient.BloodId {
1298 1300
 			returnData := make(map[string]interface{}, 0)
1299 1301
 			returnData["msg"] = "身份证号码已存在"
@@ -1302,7 +1304,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1302 1304
 		}
1303 1305
 
1304 1306
 		//查询手机号码是否存在
1305
-		thisPatientOne, err := service.FindPatientByMobileOne(phone, orgid)
1307
+		thisPatientOne, err := service.FindPatientByMobileOne(phone, orgid, id)
1306 1308
 		if thisPatientOne.ID > 0 && thisPatientOne.ID != patient.BloodId {
1307 1309
 			returnData := make(map[string]interface{}, 0)
1308 1310
 			returnData["msg"] = "手机号码已存在"
@@ -1311,7 +1313,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1311 1313
 		}
1312 1314
 
1313 1315
 		//查询号透析号是否相同
1314
-		thisPatientother, _ := service.FindPatientByDialysisNoOne(orgid, dialysis)
1316
+		thisPatientother, _ := service.FindPatientByDialysisNoOne(orgid, dialysis, id)
1315 1317
 		if thisPatientother.ID > 0 && thisPatientother.ID != patient.BloodId {
1316 1318
 			returnData := make(map[string]interface{}, 0)
1317 1319
 			returnData["msg"] = "透析号码已存在"
@@ -2332,3 +2334,33 @@ func (this *NewDialysisApiController) SaveNameTwo() {
2332 2334
 		"role": role,
2333 2335
 	})
2334 2336
 }
2337
+
2338
+func (this *NewDialysisApiController) GetCurrentOrg() {
2339
+	nowTime := time.Now().Unix()
2340
+	adminInfo := this.GetMobileAdminUserInfo()
2341
+	orgId := adminInfo.Org.Id
2342
+	fxKey := beego.AppConfig.String("fxtokenkey")
2343
+	stringA := fmt.Sprintf("org_id=%d&time=%d", orgId, nowTime)
2344
+
2345
+	data := []byte(stringA)
2346
+	has := md5.Sum(data)
2347
+	md5str := fmt.Sprintf("%x", has)
2348
+	stringB := fmt.Sprintf("string=%s&key=%s", md5str, fxKey)
2349
+
2350
+	data = []byte(stringB)
2351
+	has = md5.Sum(data)
2352
+	signToken := fmt.Sprintf("%x", has)
2353
+
2354
+	name, err := service.GetOrgName(orgId)
2355
+	//var fxlink = signToken + fmt.Sprintf("&fxtoken=%s&fxorgid=%d&timestamp=%d&fxadmin=%d", signToken, orgId, nowTime, name.Creator)
2356
+	//fmt.Println(fxlink)
2357
+	if err != nil {
2358
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2359
+		return
2360
+	}
2361
+	this.ServeSuccessJSON(map[string]interface{}{
2362
+		"org":       name,
2363
+		"nowTime":   nowTime,
2364
+		"signToken": signToken,
2365
+	})
2366
+}

+ 1 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Прегледај датотеку

@@ -144,4 +144,5 @@ func NewMobileAPIControllersRegisterRouters() {
144 144
 	beego.Router("/m/api/patient/updatebed", &NewDialysisApiController{}, "Get:UpdatedBed")
145 145
 	beego.Router("/m/api/patient/getmyorginformation", &NewDialysisApiController{}, "Get:GetMyOrgInformation")
146 146
 	beego.Router("/m/api/patient/savenametwo", &NewDialysisApiController{}, "Get:SaveNameTwo")
147
+	beego.Router("/m/api/patient/getcurrentorg", &NewDialysisApiController{}, "Get:GetCurrentOrg")
147 148
 }

+ 29 - 11
service/patientmanage_service.go Прегледај датотеку

@@ -406,18 +406,33 @@ func CreatePatientTwo(patient *models.Patients, contagions []int64, diseases []i
406 406
 	return
407 407
 }
408 408
 
409
-func FindPatientByIdCardNoOne(orgID int64, idCardNo string) (patient models.XtPatientsNew, err error) {
410
-	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and id_card_no=?", orgID, idCardNo).First(&patient).Error
409
+func FindPatientByMobileFive(mobile string, orgID int64) (patient models.XtPatientsNew, err error) {
410
+	err = readDb.Model(&models.Patients{}).Where("phone=? and user_org_id=? and status=1", mobile, orgID).First(&patient).Error
411 411
 	return
412 412
 }
413 413
 
414
-func FindPatientByDialysisNoOne(orgID int64, dialysisNo string) (patient models.Patients, err error) {
414
+func FindPatientByDialysisNoFive(orgID int64, dialysisNo string) (patient models.Patients, err error) {
415 415
 	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and dialysis_no=?", orgID, dialysisNo).First(&patient).Error
416 416
 	return
417 417
 }
418 418
 
419
-func FindPatientByMobileOne(mobile string, orgID int64) (patient models.XtPatientsNew, err error) {
420
-	err = readDb.Model(&models.Patients{}).Where("phone=? and user_org_id=? and status=1", mobile, orgID).First(&patient).Error
419
+func FindPatientByIdCardNoFive(orgID int64, idCardNo string) (patient models.XtPatientsNew, err error) {
420
+	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and id_card_no=?", orgID, idCardNo).First(&patient).Error
421
+	return
422
+}
423
+
424
+func FindPatientByIdCardNoOne(orgID int64, idCardNo string, id int64) (patient models.XtPatientsNew, err error) {
425
+	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and id_card_no=? and id<>?", orgID, idCardNo, id).First(&patient).Error
426
+	return
427
+}
428
+
429
+func FindPatientByDialysisNoOne(orgID int64, dialysisNo string, id int64) (patient models.Patients, err error) {
430
+	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and dialysis_no=? and id<>?", orgID, dialysisNo, id).First(&patient).Error
431
+	return
432
+}
433
+
434
+func FindPatientByMobileOne(mobile string, orgID int64, id int64) (patient models.XtPatientsNew, err error) {
435
+	err = readDb.Model(&models.Patients{}).Where("phone=? and user_org_id=? and status=1 and id<>?", mobile, orgID, id).First(&patient).Error
421 436
 	return
422 437
 }
423 438
 
@@ -486,10 +501,11 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
486 501
 	if patientID > 0 {
487 502
 		db = db.Where("x.patient_id = ?", patientID)
488 503
 	}
489
-	if advice_type > 0 {
504
+	if advice_type == 1 {
490 505
 		db = db.Where("x.advice_type = ?", advice_type)
491
-	} else if advice_type == 0 {
492
-		db = db.Where("x.advice_type in (?)", []int{1, 3})
506
+	}
507
+	if advice_type == 3 {
508
+		db = db.Where("x.advice_type <> 1")
493 509
 	}
494 510
 	if start > 0 {
495 511
 		db = db.Where("x.start_time>=?", start)
@@ -515,11 +531,13 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
515 531
 	if patientID > 0 {
516 532
 		db = db.Where("x.patient_id = ?", patientID)
517 533
 	}
518
-	if advice_type > 0 {
534
+	if advice_type == 1 {
519 535
 		db = db.Where("x.advice_type = ?", advice_type)
520
-	} else if advice_type == 0 {
521
-		db = db.Where("x.advice_type in (?)", []int{1, 3})
522 536
 	}
537
+	if advice_type == 3 {
538
+		db = db.Where("x.advice_type <> 1")
539
+	}
540
+
523 541
 	if start > 0 {
524 542
 		db = db.Where("x.start_time>=?", start)
525 543
 	}