scrm-go

micro_service.go 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package micro_service
  2. import (
  3. "SCRM/models"
  4. "SCRM/service"
  5. "fmt"
  6. "github.com/jinzhu/gorm"
  7. )
  8. func GetData(orgid int64)(model []*models.SgjPatientModel,err error) {
  9. db := service.PatientReadDB().Table("sgj_patient_model as m").Where(" m.status = ?", 1)
  10. dbs := service.PatientReadDB().Table("sgj_patient_editpiclink as s")
  11. fmt.Println("db是什么?",db)
  12. if(orgid > 0){
  13. db = db.Where("user_org_id = ? ", orgid)
  14. }
  15. err = db.Preload("Hospitals").Preload("Offices").Preload("OfficeEnviroment").
  16. Preload("Editdoctor").Preload("Editmargin").Preload("Enviroimages").Preload("PatientEditpiclink", func(db *gorm.DB) *gorm.DB{
  17. return dbs.Select("s.id,s.images,s.sort,s.piclink,s.linkaddress,s.user_org_id,s.status,s.ctime,s.mtime,s.modeid,s.img_show,s.linkid").Order("sort")
  18. }).Select("m.id,m.title,m.sort,m.ctime,m.mtime,m.user_org_id,m.status,m.mode_type").Order("sort").Find(&model).Error
  19. return
  20. }
  21. func GetArticlelist(orgid int64)(models.SgjPatientArticlelist,error) {
  22. articlelist := models.SgjPatientArticlelist{}
  23. err := service.PatientReadDB().Where("user_org_id = ? AND Status = ?", orgid, 1).Last(&articlelist).Error
  24. fmt.Println("错误",err)
  25. return articlelist,err
  26. }
  27. //func GetArticlelistlimit(orgid int64)(models.SgjPatientArticlelist,error) {
  28. // articlelist := models.SgjPatientArticlelist{}
  29. // service.PatientReadDB().Model(&articlelist).Where("")
  30. //}
  31. func GetlastLimit(orgid int64)(models.SgjPatientArticlelist,error) {
  32. articlelist := models.SgjPatientArticlelist{}
  33. err := service.PatientReadDB().Model(&articlelist).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&articlelist).Error
  34. return articlelist,err
  35. }
  36. func GetAllArticeList(orgid int64,limit int64)(articles []models.Articles,err error) {
  37. err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ? AND article_status = ?", orgid, 1,1).Limit(limit).Order("ctime desc").Find(&articles).Error
  38. return articles,err
  39. }
  40. func GetActivitiesById(orgid int64)(models.SgjPatientAddactivity,error) {
  41. addactivity := models.SgjPatientAddactivity{}
  42. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error
  43. fmt.Println("查询活动列表错误",err)
  44. return addactivity,err
  45. }
  46. func GetLastActivitiesLast(orgid int64)(models.SgjPatientAddactivity,error) {
  47. addactivity := models.SgjPatientAddactivity{}
  48. err := service.PatientReadDB().Model(&addactivity).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error
  49. return addactivity,err
  50. }
  51. func GetAllActivities(orgid int64,limit int64)(activity []models.Activity,err error) {
  52. err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Limit(limit).Find(&activity).Error
  53. return
  54. }
  55. func GetAllActivitiestwo(orgid int64)(activity []models.Activity,err error) {
  56. err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Order("ctime desc").Find(&activity).Error
  57. return activity,err
  58. }
  59. func QueryHispitalDetail(orgid int64,id int64)(models.SgjPatientHospital,error) {
  60. hospital := models.SgjPatientHospital{}
  61. err := service.PatientReadDB().Model(&hospital).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&hospital).Error
  62. return hospital,err
  63. }
  64. func GetOfficeDetail(orgid int64,id int64)(models.SgjPatientOffices,error) {
  65. offices := models.SgjPatientOffices{}
  66. err := service.PatientReadDB().Model(&offices).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&offices).Error
  67. return offices,err
  68. }
  69. func GetDoctorDetail(orgid int64,id int64)(editdoctor []*models.SgjPatientEditdoctor,err error) {
  70. err = service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Order("doc_sort").Find(&editdoctor).Error
  71. return
  72. }
  73. func GetOfficEnviromentDetail(orgid int64,id int64)(offenvironment []models.SgjPatientEnviroimages,err error) {
  74. err = service.PatientReadDB().Model(&offenvironment).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, id, 1).Order("sort").Find(&offenvironment).Error
  75. return offenvironment,err
  76. }
  77. func GetArticlelistById(modeid int64,orgID int64)(models.SgjPatientArticlelist,error) {
  78. articlelist := models.SgjPatientArticlelist{}
  79. err := service.PatientReadDB().Model(articlelist).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&articlelist).Error
  80. return articlelist,err
  81. }
  82. func GetAllArticles(orgid int64,limit int64)(articlelist []models.Articles,err error) {
  83. err = service.PatientReadDB().Model(articlelist).Where("user_org_id = ? AND Status = ?", orgid, 1).Limit(limit).Find(&articlelist).Error
  84. return
  85. }
  86. func GetAllPushArticles(orgid int64)(articleslist []models.Articles,err error) {
  87. err = service.PatientReadDB().Model(articleslist).Where("user_org_id = ? AND article_status = ? AND status = ?", orgid, 1, 1).Order("ctime desc").Find(&articleslist).Error
  88. return
  89. }
  90. func GetAllActivitiById(modeid int64,orgID int64)(models.SgjPatientAddactivity,error) {
  91. addactivity := models.SgjPatientAddactivity{}
  92. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&addactivity).Error
  93. return addactivity,err
  94. }
  95. func GetDefalutNavigationData(orgid int64)(navigation []models.SgjPatientNavigation,err error) {
  96. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
  97. return navigation,err
  98. }
  99. func GetOrederModel(orgid int64)(model []*models.SgjPatientOrdmodel,err error) {
  100. db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1)
  101. if(orgid > 0){
  102. db = db.Where("user_org_id = ?", orgid)
  103. }
  104. err = db.Preload("Hosaddress").Preload("Connectway").Preload("Worktime").Preload("Rideway").Preload("Oldration").Preload("Conrotation").
  105. Select("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error
  106. fmt.Println("sql错误是什么",err)
  107. return
  108. }
  109. func GetAllConnecway(orgid int64)(connect []models.SgjPatientConnection,err error) {
  110. err = service.PatientReadDB().Model(&connect).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&connect).Error
  111. return
  112. }
  113. func GetActivitDetail(id int64,orgid int64)(models.Activity,error) {
  114. activity := models.Activity{}
  115. err := service.PatientReadDB().Model(&activity).Where(" id = ? AND user_org_id = ?", id, orgid).Find(&activity).Error
  116. return activity,err
  117. }
  118. func GetArticlesDetail(id int64,orgid int64)(models.Articles,error) {
  119. articles := models.Articles{}
  120. err := service.PatientReadDB().Model(&articles).Where("id = ? AND user_org_id = ?", id, orgid).Find(&articles).Error
  121. return articles,err
  122. }
  123. //func GetDoctorInfo(id int64,orgid int64)(models.SgjPatientEditdoctor,error) {
  124. // editdoctor := models.SgjPatientEditdoctor{}
  125. // err := service.PatientReadDB().Model(&editdoctor).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editdoctor).Error
  126. // return editdoctor,err
  127. //}
  128. func GetDoctorInfo(id int64,orgid int64)(models.SgjUserStaffInfo,error) {
  129. info := models.SgjUserStaffInfo{}
  130. err := service.UserReadDB().Model(&info).Where("id = ? AND user_org_id = ?", id, orgid).Find(&info).Error
  131. return info,err
  132. }
  133. func GetRotationLinkAddress(orgid int64,linkid int64)(models.SgjPatientLinkaddress,error) {
  134. linkaddress := models.SgjPatientLinkaddress{}
  135. err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&linkaddress).Error
  136. return linkaddress,err
  137. }
  138. func GetNavigationLinkAddressById(id int64,orgid int64)(models.SgjPatientEditmargin,error) {
  139. editmargin := models.SgjPatientEditmargin{}
  140. err := service.PatientReadDB().Model(&editmargin).Where("id=? and user_org_id = ?", id, orgid).Find(&editmargin).Error
  141. return editmargin,err
  142. }
  143. func GetEnviromentImages(mid int64,orgid int64)(enviro []models.SgjPatientEnviroimages,err error) {
  144. err = service.PatientReadDB().Model(&enviro).Where(" modeid = ? AND user_org_id = ?", mid, orgid).Find(&enviro).Error
  145. return
  146. }
  147. func GetAllDoctors(orgid int64)(staff []models.SgjUserStaffInfo,err error) {
  148. err = service.UserReadDB().Model(&staff).Where("user_org_id = ? AND status = ? AND user_type <> ? AND user_title <> ? AND user_title <> ?", orgid,1,3, 12,13).Find(&staff).Error
  149. return staff,err
  150. }