see999 3 년 전
부모
커밋
07b8333d0b
1개의 변경된 파일3개의 추가작업 그리고 102개의 파일을 삭제
  1. 3 102
      service/xcx_mobile_api_service.go

+ 3 - 102
service/xcx_mobile_api_service.go 파일 보기

@@ -9,7 +9,6 @@ import (
9 9
 	"errors"
10 10
 	"fmt"
11 11
 	"github.com/jinzhu/gorm"
12
-	"net/http"
13 12
 	"time"
14 13
 )
15 14
 
@@ -131,8 +130,8 @@ func GetWeekDayOfWeek() (weekMonday string) {
131 130
 func GetMobilePatient(mobile string, idcard string) (*models.XcxPatients, error) {
132 131
 
133 132
 	patient := models.XcxPatients{}
134
-	err := XTReadDB().Model(&patient).Where("(phone = ? or relative_phone =?) and id_card_no = ?", mobile, mobile, idcard).Find(&patient).Error
135
-
133
+	err := XTReadDB().Model(&patient).Where("(phone = ? or relative_phone =?) and id_card_no =?", mobile, mobile, idcard).Find(&patient).Error
134
+	//err := XTReadDB().Model(&patient).Where("id_card_no = ? and status = 1", mobile).Find(&patient).Error
136 135
 	if err == gorm.ErrRecordNotFound {
137 136
 		return nil, err
138 137
 	}
@@ -154,7 +153,7 @@ func GetTemplateMode(orgid int64) (models.XcxGobalTemplate, error) {
154 153
 func GetMobilePatientOne(mobile string) (*models.XcxAdminUserRole, error) {
155 154
 
156 155
 	patient := models.XcxAdminUserRole{}
157
-	err := UserReadDB().Model(&patient).Where("mobile = ? and status = 1", mobile).Find(&patient).Error
156
+	err := XTReadDB().Model(&patient).Where("mobile = ? and status = 1", mobile).Find(&patient).Error
158 157
 	if err == gorm.ErrRecordNotFound {
159 158
 		return nil, err
160 159
 	}
@@ -573,101 +572,3 @@ func GetDataConfig(orgid int64) (list []*models.XcxDataConfig, err error) {
573 572
 	err = XTReadDB().Model(&list).Where("(org_id = ? or org_id = 0) and status = 1", orgid).Find(&list).Error
574 573
 	return list, err
575 574
 }
576
-
577
-func GetLastScheduleListOne(patient_id int64, schedule_date int64) (models.XcxSchedule, error) {
578
-
579
-	schedule := models.XcxSchedule{}
580
-	err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date <=?", patient_id, schedule_date).Order("schedule_date desc").Last(&schedule).Error
581
-	return schedule, err
582
-}
583
-
584
-func GetInspectionGroupList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
585
-
586
-	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
587
-	if patientid > 0 {
588
-		db = db.Where("x.patient_id = ?", patientid)
589
-	}
590
-	if startime > 0 {
591
-		db = db.Where("x.inspect_date >= ?", startime)
592
-	}
593
-	if endtime > 0 {
594
-		db = db.Where("x.inspect_date <= ?", endtime)
595
-	}
596
-	err = db.Group("x.inspect_date,x.project_id").Find(&inspection).Error
597
-	return inspection, err
598
-}
599
-
600
-func GetInsepctionList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
601
-	db := XTReadDB().Table("xt_inspection as x").Where("x.status =1")
602
-	table := XTReadDB().Table("xt_inspection_reference as r")
603
-	fmt.Print("table", table)
604
-	if patientid > 0 {
605
-		db = db.Where("x.patient_id = ?", patientid)
606
-	}
607
-	if startime > 0 {
608
-		db = db.Where("x.inspect_date >= ?", startime)
609
-	}
610
-	if endtime > 0 {
611
-		db = db.Where("x.inspect_date <= ?", endtime)
612
-	}
613
-	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
614
-	return inspection, err
615
-}
616
-
617
-func GetArticList(activityID int64, page int64, limit int64) (story []*models.SybStory, total int64, err error) {
618
-
619
-	offset := (page - 1) * limit
620
-	err = UserReadDB().Model(&story).Where("activity_id = ? and  audit_status = 2", activityID).Count(&total).Order("ctime desc").Offset(offset).Limit(limit).Find(&story).Error
621
-	return story, total, err
622
-}
623
-
624
-func GetArticListDetail(id int64) (models.SybStory, error) {
625
-
626
-	story := models.SybStory{}
627
-	err := UserReadDB().Where("id = ?", id).Find(&story).Error
628
-	return story, err
629
-}
630
-
631
-func GetStoryScoreList(activityID int64, page int64, limit int64) (score []*models.SybStoryScore, total int64, err error) {
632
-	offset := (page - 1) * limit
633
-	err = UserReadDB().Model(&score).Where("activity_id = ?", activityID).Count(&total).Offset(offset).Limit(limit).Preload("SybStory").Find(&score).Error
634
-	return score, total, err
635
-}
636
-
637
-func SendWxAuthAPI(appID string, appSecret string, grant_type string, code string) (string, error) {
638
-
639
-	var code2sessionURL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appID + "&secret=" + appSecret + "&code=" + code + "&grant_type=" + grant_type
640
-	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
641
-	fmt.Println("url233232323322323", url)
642
-	resp, err := http.DefaultClient.Get(url)
643
-	fmt.Println("resp32332232332322", resp)
644
-	if err != nil {
645
-		return "", err
646
-	}
647
-	var wxMap map[string]string
648
-	err = json.NewDecoder(resp.Body).Decode(&wxMap)
649
-	if err != nil {
650
-		return "", err
651
-	}
652
-	defer resp.Body.Close()
653
-
654
-	return wxMap["openid"], nil
655
-}
656
-
657
-func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code string) (string, error) {
658
-	var code2sessionURL = "GET https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
659
-	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
660
-	fmt.Println("url233232323322323", url)
661
-	resp, err := http.DefaultClient.Get(url)
662
-	if err != nil {
663
-		return "", err
664
-	}
665
-	var wxMap map[string]string
666
-	err = json.NewDecoder(resp.Body).Decode(&wxMap)
667
-	if err != nil {
668
-		return "", err
669
-	}
670
-	defer resp.Body.Close()
671
-
672
-	return wxMap["session_key"], nil
673
-}