see999 3 years ago
parent
commit
94fce69a27

+ 1 - 16
conf/app.conf View File

1
 appname = 小程序
1
 appname = 小程序
2
-httpport = 9539
2
+httpport = 9529
3
 runmode = prod
3
 runmode = prod
4
 
4
 
5
 #
5
 #
113
 writepatientpass = xhPECP2nFObR8aUK
113
 writepatientpass = xhPECP2nFObR8aUK
114
 writepatientname = sgj_cdm
114
 writepatientname = sgj_cdm
115
 
115
 
116
-
117
-readswshost = shengws1.mysql.rds.aliyuncs.com
118
-readswsport = 3306
119
-readswsuser = syh
120
-readswspass = xhPECP2nFObR8aUK
121
-readswsname = shengws
122
-
123
-
124
-
125
-writeswshost = shengws1.mysql.rds.aliyuncs.com
126
-writeswsport = 3306
127
-writeswsuser = syh
128
-writeswspass = xhPECP2nFObR8aUK
129
-writeswsname = shengws
130
-
131
 redishost = 349e580b2a524290.redis.rds.aliyuncs.com
116
 redishost = 349e580b2a524290.redis.rds.aliyuncs.com
132
 redisport = 6379
117
 redisport = 6379
133
 redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
118
 redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP

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

1051
 	var appid = "wxcdf53b48b7df107e"
1051
 	var appid = "wxcdf53b48b7df107e"
1052
 	var secret = "94e944a69ad1d43ac447f5a8769ab801"
1052
 	var secret = "94e944a69ad1d43ac447f5a8769ab801"
1053
 	var grant_type = "authorization_code"
1053
 	var grant_type = "authorization_code"
1054
-	code := this.GetString("js_code")
1055
-	//var code = "061Vw9Ga18vxSB0KvZIa1dDoGE2Vw9G6"
1054
+	//code := this.GetString("js_code")
1055
+	var code = "041pXnGa1eLxTB0iypFa1W6USs1pXnGK"
1056
 
1056
 
1057
 	openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
1057
 	openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
1058
 	session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)
1058
 	session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)

+ 96 - 0
service/xcx_mobile_api_service.go View File

572
 	err = XTReadDB().Model(&list).Where("(org_id = ? or org_id = 0) and status = 1", orgid).Find(&list).Error
572
 	err = XTReadDB().Model(&list).Where("(org_id = ? or org_id = 0) and status = 1", orgid).Find(&list).Error
573
 	return list, err
573
 	return list, err
574
 }
574
 }
575
+
576
+func GetLastScheduleListOne(patient_id int64, schedule_date int64) (models.XcxSchedule, error) {
577
+
578
+	schedule := models.XcxSchedule{}
579
+	err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date <=?", patient_id, schedule_date).Order("schedule_date desc").Last(&schedule).Error
580
+	return schedule, err
581
+}
582
+
583
+func GetInspectionGroupList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
584
+
585
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
586
+	if patientid > 0 {
587
+		db = db.Where("x.patient_id = ?", patientid)
588
+	}
589
+	if startime > 0 {
590
+		db = db.Where("x.inspect_date >= ?", startime)
591
+	}
592
+	if endtime > 0 {
593
+		db = db.Where("x.inspect_date <= ?", endtime)
594
+	}
595
+	err = db.Group("x.inspect_date,x.project_id").Find(&inspection).Error
596
+	return inspection, err
597
+}
598
+
599
+func GetInsepctionList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
600
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status =1")
601
+	table := XTReadDB().Table("xt_inspection_reference as r")
602
+	fmt.Print("table", table)
603
+	if patientid > 0 {
604
+		db = db.Where("x.patient_id = ?", patientid)
605
+	}
606
+	if startime > 0 {
607
+		db = db.Where("x.inspect_date >= ?", startime)
608
+	}
609
+	if endtime > 0 {
610
+		db = db.Where("x.inspect_date <= ?", endtime)
611
+	}
612
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,x.status,x.created_time,x.updated_time,r.range_type,r.range_min,r.range_max,r.range_value,r.range_options,r.unit").Joins("left join xt_inspection_reference as r on (r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0)   ").Scan(&inspection).Error
613
+	return inspection, err
614
+}
615
+
616
+func GetArticList(activityID int64, page int64, limit int64) (story []*models.SybStory, total int64, err error) {
617
+
618
+	offset := (page - 1) * limit
619
+	err = UserReadDB().Model(&story).Where("activity_id = ? and  audit_status = 2", activityID).Count(&total).Order("ctime desc").Offset(offset).Limit(limit).Find(&story).Error
620
+	return story, total, err
621
+}
622
+
623
+func GetArticListDetail(id int64) (models.SybStory, error) {
624
+
625
+	story := models.SybStory{}
626
+	err := UserReadDB().Where("id = ?", id).Find(&story).Error
627
+	return story, err
628
+}
629
+
630
+func GetStoryScoreList(activityID int64, page int64, limit int64) (score []*models.SybStoryScore, total int64, err error) {
631
+	offset := (page - 1) * limit
632
+	err = UserReadDB().Model(&score).Where("activity_id = ?", activityID).Count(&total).Offset(offset).Limit(limit).Preload("SybStory").Find(&score).Error
633
+	return score, total, err
634
+}
635
+
636
+func SendWxAuthAPI(appID string, appSecret string, grant_type string, code string) (map[string]string, error) {
637
+
638
+	var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
639
+	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
640
+	fmt.Println("url233232323322323", url)
641
+	resp, err := http.DefaultClient.Get(code2sessionURL)
642
+	fmt.Println("resp32332232332322", resp)
643
+
644
+	var wxMap map[string]string
645
+	err = json.NewDecoder(resp.Body).Decode(&wxMap)
646
+	if err != nil {
647
+		return wxMap, err
648
+	}
649
+	defer resp.Body.Close()
650
+
651
+	return wxMap, err
652
+}
653
+
654
+func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code string) (string, error) {
655
+	var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
656
+	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
657
+	fmt.Println(url)
658
+	resp, err := http.DefaultClient.Get(code2sessionURL)
659
+	if err != nil {
660
+		return "", err
661
+	}
662
+	var wxMap map[string]string
663
+	err = json.NewDecoder(resp.Body).Decode(&wxMap)
664
+	if err != nil {
665
+		return "", err
666
+	}
667
+	defer resp.Body.Close()
668
+	fmt.Println("2333232232", wxMap)
669
+	return wxMap["session_key"], nil
670
+}