scrm-go

site_microwebsite_service.go 50KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. package site_service
  2. import (
  3. "SCRM/models"
  4. "SCRM/service"
  5. "fmt"
  6. "time"
  7. )
  8. func AddPatientModel(model *models.SgjPatientModel)error{
  9. err := service.PatientWriteDB().Create(&model).Error
  10. fmt.Println("插入错误",err)
  11. return err
  12. }
  13. func QueryModel(orgID int64)( models.SgjPatientModel,error) {
  14. model := models.SgjPatientModel{}
  15. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&model).Error
  16. return model,err
  17. }
  18. func UpdateEditpicLink(orgID int64,ids[] int64,editpiclink models.SgjPatientEditpiclink)(err error) {
  19. if(len(ids)==1){
  20. err = service.PatientWriteDB().Model(&models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ? ", ids[0], orgID).Update(map[string]interface{}{"modeid": editpiclink.Modeid, "status": 1,"img_show":0, "mtime": time.Now().Unix()}).Error
  21. }else {
  22. err = service.PatientWriteDB().Model(&models.SgjPatientEditpiclink{}).Where("id IN(?) and user_org_id = ? ", ids, orgID).Update(map[string]interface{}{"modeid": editpiclink.Modeid, "status": 1,"img_show":0, "mtime": time.Now().Unix()}).Error
  23. }
  24. return
  25. }
  26. func AddRotation(rotation models.SgjPatientRotation) error {
  27. err := service.PatientWriteDB().Create(&rotation).Error
  28. fmt.Println("插入数据",err)
  29. return err
  30. }
  31. func GetRotationByLastData(orgid int64)(models.SgjPatientRotation,error) {
  32. rotation := models.SgjPatientRotation{}
  33. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&rotation).Error
  34. return rotation,err
  35. }
  36. func AddRotationUpload(connecmodel *models.SgjPatientConnecmodel) error {
  37. err := service.PatientWriteDB().Create(&connecmodel).Error
  38. fmt.Println("错误是什么,err",err)
  39. return err
  40. }
  41. func AddHispital(newmodel models.SgjPatientHospital) error {
  42. err := service.PatientWriteDB().Create(&newmodel).Error
  43. return err
  44. }
  45. func AddOffices(offices models.SgjPatientOffices) error {
  46. err := service.PatientWriteDB().Create(&offices).Error
  47. return err
  48. }
  49. func AddDoctor(doctor models.SgjPatientDocinfo) error {
  50. err := service.PatientWriteDB().Create(&doctor).Error
  51. return err
  52. }
  53. func AddDoctorInfo(doctor models.SgjPatientEditdoctor) error{
  54. err := service.PatientWriteDB().Create(&doctor).Error
  55. return err
  56. }
  57. func AddImages(enviroimages *models.SgjPatientEnviroimages) error {
  58. err := service.PatientWriteDB().Create(&enviroimages).Error
  59. return err
  60. }
  61. func AddOffEnvironment(officenviroment models.SgjPatientOffenvironment) error {
  62. err := service.PatientWriteDB().Create(&officenviroment).Error
  63. return err
  64. }
  65. func GetRationImages(orgID int64)(rot []*models.SgjPatientRotation, err error){
  66. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Order("sort").Find(&rot).Error
  67. fmt.Println("错误是什么",err)
  68. return
  69. }
  70. func GetHospitalInfo(orgID int64)(models.SgjPatientHospital,error) {
  71. hospital := models.SgjPatientHospital{}
  72. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&hospital).Error
  73. fmt.Println("错误是什么",err)
  74. return hospital,err
  75. }
  76. func GetOfficeInfo(orgID int64)(models.SgjPatientOffices,error) {
  77. offices := models.SgjPatientOffices{}
  78. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offices).Error
  79. fmt.Println("错误是什么",err)
  80. return offices,err
  81. }
  82. func GetQueryDocInfo(orgID int64)(doc []*models.SgjUserStaffInfo,err error) {
  83. err = service.UserReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&doc).Error
  84. fmt.Println("错误是什么",err)
  85. return
  86. }
  87. func GetQueryDocHead(orgID int64) (doc []*models.SgjPatientEditdoctor,err error) {
  88. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Order("doc_sort").Find(&doc).Error
  89. return
  90. }
  91. func GetOffEnvironment(orgID int64)(models.SgjPatientOffenvironment,error) {
  92. offenvironment := models.SgjPatientOffenvironment{}
  93. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offenvironment).Error
  94. fmt.Println("错误是什么",err)
  95. return offenvironment,err
  96. }
  97. func AddWorkTime(connecmodel *models.SgjPatientWorktime) error {
  98. err := service.PatientWriteDB().Create(&connecmodel).Error
  99. return err
  100. }
  101. func AddRideWay(connecmodel models.SgjPatientRideway) error {
  102. err := service.PatientWriteDB().Create(&connecmodel).Error
  103. return err
  104. }
  105. func AddConnetion(connection models.SgjPatientConnection) error {
  106. err := service.PatientWriteDB().Create(&connection).Error
  107. return err
  108. }
  109. func GetQueryConnection( orgID int64)(conection []*models.SgjPatientConnection,err error) {
  110. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&conection).Error
  111. return
  112. }
  113. func DeleteRideWay(orgid int64,id int64)(error){
  114. err := service.PatientWriteDB().Model(&models.SgjPatientRideway{}).Where("user_org_id =? AND mode_id = ?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  115. return err
  116. }
  117. func DeleteConnecWay(orgid int64,id int64)(error) {
  118. err := service.PatientWriteDB().Model(&models.SgjPatientConnection{}).Where("user_org_id = ? AND id =?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  119. return err
  120. }
  121. func DeleteWorkTime(orgid int64,id int64)(error) {
  122. err := service.PatientWriteDB().Model(models.SgjPatientWorktime{}).Where("user_org_id = ? AND mode_id = ?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  123. return err
  124. }
  125. func EditConnecWay(orgid int64,id int64)(models.SgjPatientConnection,error){
  126. sgj := models.SgjPatientConnection{}
  127. err := service.PatientReadDB().Model(&sgj).Where("user_org_id = ? AND id =?", orgid, id).Find(&sgj).Error
  128. return sgj,err;
  129. }
  130. func UpadateConnec(connection *models.SgjPatientConnection,orgID int64,id int64) {
  131. service.PatientWriteDB().Model(connection).Where("user_org_id = ? AND id = ? AND status = ?",orgID,id,1).Update(map[string]interface{}{"title":connection.Title,"connecway":connection.Connecway,"content":connection.Content,})
  132. }
  133. func GetUserModel(orgid int64)(model []*models.SgjPatientOrdmodel,err error){
  134. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error
  135. return
  136. }
  137. func GetQueryNewModel(orgid int64)(model []*models.SgjPatientModel,err error) {
  138. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error
  139. fmt.Println("错误是什么",err)
  140. return
  141. }
  142. func GetEditModel(orgid int64,id int64)(models.SgjPatientWorktime,error){
  143. worktime := models.SgjPatientWorktime{}
  144. err := service.PatientReadDB().Model(&worktime).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&worktime).Error
  145. return worktime,err;
  146. }
  147. func GetEditRideWay(orgid int64,id int64)(models.SgjPatientRideway,error) {
  148. rideway := models.SgjPatientRideway{}
  149. err := service.PatientReadDB().Model(&rideway).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&rideway).Error
  150. return rideway,err;
  151. }
  152. func UpdateWorkTime(mid int64,orgID int64,worktime models.SgjPatientWorktime) error {
  153. err := service.PatientWriteDB().Model(worktime).Where("id = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Update(map[string]interface{}{"title": worktime.Title, "sort": worktime.Sort, "worktime": worktime.Worktime, "mtime": time.Now().Unix()}).Error
  154. return err
  155. }
  156. func UpdateOrdeModel(id int64,orgID int64,ordmodel models.SgjPatientOrdmodel) error {
  157. err := service.PatientWriteDB().Model(ordmodel).Where("id = ? AND user_org_id = ? AND status = ?", id, orgID, 1).Update(map[string]interface{}{"title": ordmodel.Title, "sort": ordmodel.Sort, "mtime": time.Now().Unix()}).Error
  158. return err
  159. }
  160. func UpdateRideWay(id int64,orgID int64,rideway models.SgjPatientRideway) error {
  161. err := service.PatientWriteDB().Model(rideway).Where("id = ? AND user_org_id = ? AND status =?", id, orgID, 1).Update(map[string]interface{}{"title": rideway.Title, "sort": rideway.Sort, "rideway": rideway.RideWay, "mtime": time.Now().Unix()}).Error
  162. return err
  163. }
  164. func QueryDocById(orgID int64,id int64)(models.SgjUserStaffInfo,error) {
  165. info := models.SgjUserStaffInfo{}
  166. err := service.UserWriteDB().Model(&info).Where("user_org_id = ? AND id = ?",orgID ,id ).Find(&info).Error
  167. return info,err
  168. }
  169. func DeleteDoctor(id int64,orgID int64)(error) {
  170. err := service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  171. return err
  172. }
  173. func EditHospital(mid int64,orgID int64)(models.SgjPatientHospital,error) {
  174. hospital := models.SgjPatientHospital{}
  175. err := service.PatientReadDB().Model(&hospital).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Find(&hospital).Error
  176. return hospital,err
  177. }
  178. func UpdateHospital(id int64,OrgId int64,hospital models.SgjPatientHospital) error {
  179. err := service.PatientWriteDB().Model(hospital).Where("id = ? AND user_org_id = ? AND status = ?", id, OrgId, 1).Update(map[string]interface{}{"title": hospital.Title, "sort": hospital.Sort, "introduction": hospital.Introduction, "mtime": time.Now().Unix()}).Error
  180. return err
  181. }
  182. func UpdateModel(modelid int64,orgId int64 ,model models.SgjPatientModel) error {
  183. err := service.PatientWriteDB().Model(model).Where("id = ? AND user_org_id = ? AND status = ?", modelid, orgId, 1).Update(map[string]interface{}{"title": model.Title, "sort": model.Sort, "mtime": time.Now().Unix()}).Error
  184. return err
  185. }
  186. func EditOffice(mid int64,orgID int64)(models.SgjPatientOffices,error) {
  187. offices := models.SgjPatientOffices{}
  188. err := service.PatientReadDB().Model(&offices).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Find(&offices).Error
  189. return offices,err
  190. }
  191. func DeletemodleById(id int64,orgID int64)(error) {
  192. err:= service.PatientWriteDB().Model(models.SgjPatientModel{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  193. return err
  194. }
  195. func DeleteHospitalByModelid(mid int64,orgID int64)(error) {
  196. err := service.PatientWriteDB().Model(models.SgjPatientHospital{}).Where("modleid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  197. return err
  198. }
  199. func DeleteOfficeByModelid(mid int64,orgID int64)(error) {
  200. err := service.PatientWriteDB().Model(models.SgjPatientOffices{}).Where("modleid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  201. return err
  202. }
  203. func DeleteEditPicLinkByModelid(mid int64,orgID int64)(error) {
  204. err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  205. return err
  206. }
  207. func DeleteEnviroments(mid int64,orgID int64)(error) {
  208. err := service.PatientWriteDB().Model(models.SgjPatientEnviroimages{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  209. return err
  210. }
  211. func DeleteConrotation(mid int64,orgID int64)(error) {
  212. err := service.PatientWriteDB().Model(models.SgjPatientConrotation{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0,"img_show":0, "mtime": time.Now().Unix()}).Error
  213. return err
  214. }
  215. func UpdateOffices(id int64,orgID int64,offices models.SgjPatientOffices) error {
  216. err := service.PatientWriteDB().Model(offices).Where("id = ? AND user_org_id = ? AND status = ?", id, orgID, 1).Update(map[string]interface{}{"title": offices.Title, "sort": offices.Sort, "introduction": offices.Introduction, "mtime": time.Now().Unix()}).Error
  217. return err
  218. }
  219. func GetHospital(Orgid int64)(hostital []*models.SgjPatientHospital,err error) {
  220. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", Orgid, 1).Order("sort").Find(&hostital).Error
  221. return
  222. }
  223. func GetData(orgid int64)(model []*models.SgjPatientModel,err error) {
  224. db := service.PatientReadDB().Table("sgj_patient_model as m").Where(" m.status = ?", 1)
  225. fmt.Println("db是什么?",db)
  226. if(orgid > 0){
  227. db = db.Where("user_org_id = ? ", orgid)
  228. }
  229. err = db.Preload("Hospitals").Preload("Offices").Preload("Doctors").Preload("OfficeEnviroment").
  230. Preload("Editdoctor").Preload("Rotation").Preload("Macnavigation").Preload("Editmargin").Preload("Enviroimages").Preload("PatientEditpiclink").
  231. 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
  232. return
  233. }
  234. func UpdateDoctorsInfo(orgID int64,ids[] int64,editdoctor models.SgjPatientEditdoctor)(err error) {
  235. if(len(ids)==1){
  236. err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? and user_org_id = ?", ids[0], orgID).Update(map[string]interface{}{ "modleid": editdoctor.Modleid, "status": 1, "mtime": time.Now().Unix()}).Error
  237. }else {
  238. err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id IN(?) and user_org_id = ?", ids, orgID).Update(map[string]interface{}{"modleid": editdoctor.Modleid, "status": 1, "mtime": time.Now().Unix()}).Error
  239. }
  240. return
  241. }
  242. func QueryEditDoc(mid int64,orgid int64)(models.SgjPatientDocinfo, error) {
  243. editdotor := models.SgjPatientDocinfo{}
  244. err := service.PatientReadDB().Model(&editdotor).Where("modelid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdotor).Error
  245. return editdotor,err
  246. }
  247. func QuerEditDocByid(mid int64,orgid int64)(editdoctor []*models.SgjPatientEditdoctor,err error) {
  248. err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("doc_sort").Find(&editdoctor).Error
  249. return
  250. }
  251. func QueryEditImages(orgid int64,id int64)(models.SgjPatientEditdoctor,error) {
  252. editdoctor := models.SgjPatientEditdoctor{}
  253. err := service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editdoctor).Error
  254. return editdoctor,err
  255. }
  256. func QueryEditDoctor(id int64,orgid int64)(models.SgjPatientEditdoctor,error) {
  257. docinfo := models.SgjPatientEditdoctor{}
  258. err := service.PatientReadDB().Model(&docinfo).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&docinfo).Error
  259. return docinfo,err
  260. }
  261. func UpDateEditdoctor(id int64,orgid int64,editdoctor models.SgjPatientEditdoctor) error {
  262. err := service.PatientWriteDB().Model(editdoctor).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"doc_name":editdoctor.DocName,"doc_postion": editdoctor.DocPostion, "dochead": editdoctor.Dochead, "doc_sort": editdoctor.DocSort, "docintroduction": editdoctor.Docintroduction, "mtime": time.Now().Unix()}).Error
  263. return err
  264. }
  265. func Upadatedocdata(orgid int64,id int64,docinfo models.SgjPatientDocinfo) error {
  266. err := service.PatientWriteDB().Model(docinfo).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Update(map[string]interface{}{"title": docinfo.Title, "sort": docinfo.Sort, "docimages": docinfo.Docimages, "mtime": time.Now().Unix()}).Error
  267. return err
  268. }
  269. func QuerOfficeEnviroment(id int64,orgid int64)(models.SgjPatientOffenvironment,error) {
  270. offenvironment := models.SgjPatientOffenvironment{}
  271. err := service.PatientReadDB().Model(&offenvironment).Where("modelid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  272. return offenvironment,err
  273. }
  274. func QueryOfficeformById(modeid int64,orgid int64)(patientenviroimages []*models.SgjPatientEnviroimages,err error) {
  275. err = service.PatientReadDB().Model(&patientenviroimages).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&patientenviroimages).Error
  276. return
  277. }
  278. func UpdateOfficeEnvironment(id int64,orgid int64)(models.SgjPatientOffenvironment,error) {
  279. offenvironment := models.SgjPatientOffenvironment{}
  280. err := service.PatientReadDB().Model(&offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  281. return offenvironment , err
  282. }
  283. func UpdatePatientOffenvironment(id int64,orgid int64,offenvironment models.SgjPatientOffenvironment)(error) {
  284. err := service.PatientWriteDB().Model(offenvironment).Where("id= ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": offenvironment.Title, "sort": offenvironment.Sort, "keimages": offenvironment.Keimages, "mtime": time.Now().Unix()}).Error
  285. return err
  286. }
  287. func QueryHispitalDetail(orgid int64,id int64)(models.SgjPatientHospital,error) {
  288. hospital := models.SgjPatientHospital{}
  289. err := service.PatientReadDB().Model(&hospital).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&hospital).Error
  290. return hospital,err
  291. }
  292. func GetOfficeDetail(orgid int64,id int64)(models.SgjPatientOffices,error) {
  293. offices := models.SgjPatientOffices{}
  294. err := service.PatientReadDB().Model(&offices).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&offices).Error
  295. return offices,err
  296. }
  297. func GetDoctorDetail(orgid int64,id int64)(editdoctor []*models.SgjPatientEditdoctor,err error) {
  298. err = service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Order("doc_sort").Find(&editdoctor).Error
  299. return
  300. }
  301. func GetOfficEnviromentDetail(orgid int64,id int64)(offenvironment []models.SgjPatientEnviroimages,err error) {
  302. err = service.PatientReadDB().Model(&offenvironment).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, id, 1).Order("sort").Find(&offenvironment).Error
  303. return offenvironment,err
  304. }
  305. func AddNavigation(navigation *models.SgjPatientNavigation)error {
  306. err := service.PatientWriteDB().Create(&navigation).Error
  307. return err
  308. }
  309. func GetNavigationList(orgid int64)(navigation []*models.SgjPatientNavigation,err error) {
  310. err = service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
  311. return
  312. }
  313. func AddShareInfo(share *models.SgjPatientShare) error {
  314. err := service.PatientWriteDB().Create(&share).Error
  315. return err
  316. }
  317. func GetShareInfo(orgid int64)(models.SgjPatientShare,error) {
  318. share := models.SgjPatientShare{}
  319. err := service.PatientReadDB().Model(&share).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&share).Error
  320. return share,err
  321. }
  322. func DeleteNavitionById(orgID int64,id int64)(error) {
  323. err := service.PatientWriteDB().Model(models.SgjPatientNavigation{}).Where("user_org_id = ? AND id = ?", orgID, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  324. return err
  325. }
  326. func AddConnecWay(connectway *models.SgjPatientConnectway) error {
  327. err := service.PatientWriteDB().Create(&connectway).Error
  328. return err
  329. }
  330. func AddOrdModel(ordmodel *models.SgjPatientOrdmodel)error {
  331. err := service.PatientWriteDB().Create(&ordmodel).Error
  332. return err
  333. }
  334. func AddHosAddress(hosaddress *models.SgjPatientHosaddress) error {
  335. err := service.PatientWriteDB().Create(&hosaddress).Error
  336. return err
  337. }
  338. func QueryOrdeModelByID(orgid int64)(models.SgjPatientOrdmodel,error) {
  339. ordmodel := models.SgjPatientOrdmodel{}
  340. err := service.PatientReadDB().Where("user_org_id = ? AND status = ? ", orgid, 1).Last(&ordmodel).Error
  341. return ordmodel,err
  342. }
  343. func UpdateConrotaions(orgid int64,ids[] int64,conrotation models.SgjPatientConrotation)(err error) {
  344. if(len(ids)==1){
  345. err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id = ? and user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "mtime": time.Now().Unix()}).Error
  346. }else {
  347. err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id IN(?) and user_org_id = ?", ids, orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "mtime": time.Now().Unix()}).Error
  348. }
  349. return
  350. }
  351. func DeleteModle(orgid int64,id int64)(error) {
  352. err := service.PatientWriteDB().Model(models.SgjPatientOrdmodel{}).Where("user_org_id = ? AND id = ?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  353. return err
  354. }
  355. func DeleteModleByModeID(orgid int64,mid int64)(error) {
  356. err := service.PatientWriteDB().Model(models.SgjPatientConnectway{}).Where("user_org_id = ? AND mode_id = ?", orgid, mid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  357. return err
  358. }
  359. func GetOrederModel(orgid int64)(model []*models.SgjPatientOrdmodel,err error) {
  360. db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1)
  361. if(orgid > 0){
  362. db = db.Where("user_org_id = ?", orgid)
  363. }
  364. err = db.Preload("Hosaddress").Preload("Connectway").Preload("Worktime").Preload("Rideway").Preload("Oldration").Preload("Conrotation").
  365. Select("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error
  366. fmt.Println("sql错误是什么",err)
  367. return
  368. }
  369. func AddRotationpic(conrotation models.SgjPatientConrotation) error {
  370. err := service.PatientWriteDB().Create(&conrotation).Error
  371. return err
  372. }
  373. func GetRotationImages(orgid int64)(conrotation []models.SgjPatientConrotation,err error) {
  374. err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1,1).Find(&conrotation).Error
  375. return conrotation,err
  376. }
  377. func AddrotationImage(oldrotation *models.SgjPatientOldrotation) error {
  378. err := service.PatientWriteDB().Create(&oldrotation).Error
  379. return err
  380. }
  381. func UpdateConrotation(orgid int64,ids[] int64,conrotation models.SgjPatientConrotation)(err error) {
  382. if(len(ids)==1){
  383. err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id = ? AND user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error
  384. }else {
  385. err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id IN(?) and user_org_id = ?", ids, orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error
  386. }
  387. return
  388. }
  389. func AddImageslink(editpiclink *models.SgjPatientEditpiclink) error {
  390. err := service.PatientWriteDB().Create(&editpiclink).Error
  391. return err
  392. }
  393. func GetEnImages(orgid int64)(enviroimages []models.SgjPatientEnviroimages,err error) {
  394. err = service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND status = ? AND imgshow = ? ", orgid,1,1).Order("sort").Find(&enviroimages).Error
  395. return enviroimages,err
  396. }
  397. func UpdateImages(orgid int64,ids [] int64,enviroimages models.SgjPatientEnviroimages)(err error) {
  398. if(len(ids)==1){
  399. err = service.PatientWriteDB().Model(&models.SgjPatientEnviroimages{}).Where("id = ? AND user_org_id = ? ", ids[0], orgid).Update(map[string]interface{}{"modeid": enviroimages.Modeid, "status": 1,"imgshow":0, "mtime": time.Now().Unix()}).Error
  400. }else {
  401. err = service.PatientWriteDB().Model(&models.SgjPatientEnviroimages{}).Where("id IN(?) and user_org_id = ? ", ids, orgid).Update(map[string]interface{}{"modeid": enviroimages.Modeid, "status": 1,"imgshow":0, "mtime": time.Now().Unix()}).Error
  402. }
  403. return
  404. }
  405. func GetEditEnvirimagesById(orgid int64,id int64)(models.SgjPatientEnviroimages,error) {
  406. enviroimages := models.SgjPatientEnviroimages{}
  407. err := service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND id =? AND status = ?", orgid, id, 1).Find(&enviroimages).Error
  408. return enviroimages,err
  409. }
  410. func UpdateEnviroimages(id int64,orgid int64,enviroimages models.SgjPatientEnviroimages)( err error) {
  411. err = service.PatientReadDB().Model(&enviroimages).Where("id = ? AND user_org_id = ? AND status =?", id, orgid, 1).Update(map[string]interface{}{"enviroimages": enviroimages.Enviroimages, "sort": enviroimages.Sort, "mtime": time.Now().Unix()}).Error
  412. return err
  413. }
  414. func GetEditImages(orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  415. err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ? AND img_show = ?",orgid,1,1).Find(&editpiclink).Error
  416. return editpiclink,err
  417. }
  418. func AddMagicNavi(editmargin *models.SgjPatientEditmargin) error {
  419. err := service.PatientWriteDB().Create(&editmargin).Error
  420. return err
  421. }
  422. func GetMagicImages(orgid int64)( editmargin []models.SgjPatientEditmargin,err error) {
  423. err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1,1).Find(&editmargin).Error
  424. return editmargin,err
  425. }
  426. func AddMarginChart(macnavigation *models.SgjPatientMacnavigation) error {
  427. err := service.PatientWriteDB().Create(&macnavigation).Error
  428. return err
  429. }
  430. func DeleteRotations(id int64, orgid int64)(error) {
  431. err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ? ", id, orgid).Update(map[string]interface{}{"status": 0,"img_show":0, "mtime": time.Now().Unix()}).Error
  432. return err
  433. }
  434. func UpdateRotationImages(orgid int64,id int64)(models.SgjPatientEditpiclink,error){
  435. editpiclink := models.SgjPatientEditpiclink{}
  436. err := service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editpiclink).Error
  437. return editpiclink,err
  438. }
  439. func SaveRotationImages(id int64,orgid int64,editpiclink models.SgjPatientEditpiclink)error {
  440. err := service.PatientWriteDB().Model(editpiclink).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"images": editpiclink.Images, "sort": editpiclink.Sort, "piclink": editpiclink.Piclink, "linkaddress": editpiclink.Linkaddress, "mtime": time.Now().Unix()}).Error
  441. return err
  442. }
  443. func EditNavigation(orgid int64,id int64)(models.SgjPatientNavigation,error){
  444. navigation := models.SgjPatientNavigation{}
  445. err := service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&navigation).Error
  446. return navigation,err
  447. }
  448. func UpdateNavtion(id int64,orgid int64,navigation models.SgjPatientNavigation) error {
  449. err := service.PatientWriteDB().Model(navigation).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"navtitle": navigation.Navtitle, "navimages": navigation.Navimages, "jumpset": navigation.Jumpset, "navaddress": navigation.Navaddress, "mtime": time.Now().Unix()}).Error
  450. return err
  451. }
  452. func DeleteImages(id int64,orgid int64)(error) {
  453. err := service.PatientWriteDB().Model(models.SgjPatientConrotation{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0,"modeid":0,"img_show":0,"mtime": time.Now().Unix()}).Error
  454. return err
  455. }
  456. func DeleteSingleImages(id int64,orgid int64) (error) {
  457. err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0,"modeid":0,"img_show":0, "mtime": time.Now().Unix()}).Error
  458. return err
  459. }
  460. func AddActivity(addactivity *models.SgjPatientAddactivity) error {
  461. err := service.PatientWriteDB().Create(&addactivity).Error
  462. return err
  463. }
  464. func QueryActivity(id int64,orgid int64)(models.SgjPatientAddactivity,error) {
  465. addactivity := models.SgjPatientAddactivity{}
  466. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&addactivity).Error
  467. return addactivity,err
  468. }
  469. func UpdateActivit(id int64,orgid int64,addactivity models.SgjPatientAddactivity) error {
  470. err := service.PatientWriteDB().Model(addactivity).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": addactivity.Title, "sort": addactivity.Sort, "number": addactivity.Number, "mtime":time.Now().Unix()}).Error
  471. return err
  472. }
  473. func DeleteMargin(id int64,orgid int64)(error) {
  474. err := service.PatientWriteDB().Model(models.SgjPatientEditmargin{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  475. return err
  476. }
  477. func GetEditRotationImages(id int64,orgid int64)(models.SgjPatientOrdmodel,error) {
  478. oldrotation := models.SgjPatientOrdmodel{}
  479. err := service.PatientReadDB().Model(oldrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&oldrotation).Error
  480. return oldrotation,err
  481. }
  482. func GetEditConrotion(id int64,orgid int64)(conrotation []models.SgjPatientConrotation, err error) {
  483. err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error
  484. return conrotation,err
  485. }
  486. func EditVisibleById(id int64,orgid int64)(models.SgjPatientConrotation,error) {
  487. conrotation := models.SgjPatientConrotation{}
  488. err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error
  489. return conrotation,err
  490. }
  491. func UpdateEditpic(id int64,orgid int64,conrotation models.SgjPatientConrotation) error {
  492. err := service.PatientWriteDB().Model(conrotation).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"images": conrotation.Images, "sort": conrotation.Sort, "piclink": conrotation.Piclink, "linkaddress": conrotation.Linkaddress}).Error
  493. return err
  494. }
  495. func GetPatientConrotationLast(orgid int64)( models.SgjPatientConrotation,error){
  496. conrotation := models.SgjPatientConrotation{}
  497. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conrotation).Error
  498. return conrotation,err
  499. }
  500. func UpdateConLinkAddress(orgid int64,conid int64,conlinkaddress models.SgjPatientConlinkaddress) error {
  501. err := service.PatientWriteDB().Model(&conlinkaddress).Where("user_org_id = ? and status = ? and con_id = ?", orgid, 1, conid).Update(map[string]interface{}{"con_id": conlinkaddress.ConId, "mtime": time.Now().Unix()}).Error
  502. return err
  503. }
  504. func AddEditpic(conrotation *models.SgjPatientConrotation)(error) {
  505. err := service.PatientWriteDB().Create(&conrotation).Error
  506. return err
  507. }
  508. func QueryOldrotion(id int64,orgid int64)(models.SgjPatientOldrotation,error) {
  509. conrotation := models.SgjPatientOldrotation{}
  510. err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ? ", id, orgid).Find(&conrotation).Error
  511. return conrotation,err
  512. }
  513. func QueryConRotation(mid int64,orgid int64)(conrotation []models.SgjPatientConrotation,err error) {
  514. err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("sort").Find(&conrotation).Error
  515. return conrotation,err
  516. }
  517. func UpdateConrotaionById(id int64,orgid int64,oldrotation models.SgjPatientOldrotation)(error) {
  518. err := service.PatientWriteDB().Model(oldrotation).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": oldrotation.Title, "sort": oldrotation.Sort, "rotation_images": oldrotation.RotationImages, "mtime": time.Now().Unix()}).Error
  519. return err
  520. }
  521. func GetPatientRotaion(id int64,orgid int64)(models.SgjPatientRotation,error) {
  522. rotation := models.SgjPatientRotation{}
  523. err := service.PatientReadDB().Model(&rotation).Where("model_id = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&rotation).Error
  524. return rotation,err
  525. }
  526. func GetPatientRotationById(id int64,orgid int64)(models.SgjPatientRotation,error) {
  527. rotation := models.SgjPatientRotation{}
  528. err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id =?", id, orgid).Find(&rotation).Error
  529. return rotation,err
  530. }
  531. func QueryEditpiclink(id int64,orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  532. err = service.PatientReadDB().Model(editpiclink).Where("modeid = ? AND user_org_id = ? AND status = ?", id, orgid,1).Order("sort").Find(&editpiclink).Error
  533. return editpiclink,err
  534. }
  535. func GetEditSingleVisible(id int64,orgid int64)(models.SgjPatientEditpiclink,error) {
  536. editpiclink := models.SgjPatientEditpiclink{}
  537. err := service.PatientReadDB().Model(&editpiclink).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error
  538. return editpiclink,err
  539. }
  540. func GetQueryEditpiclink(modeid int64,orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  541. err = service.PatientReadDB().Model(&editpiclink).Where("modeid=? AND user_org_id = ? AND status = ?", modeid, orgid,1).Order("sort").Find(&editpiclink).Error
  542. return editpiclink,err
  543. }
  544. func UpdateEditPatPicLink(id int64,orgid int64,editpiclink models.SgjPatientEditpiclink)(error) {
  545. err := service.PatientWriteDB().Model(editpiclink).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"images": editpiclink.Images, "sort": editpiclink.Sort, "piclink": editpiclink.Piclink, "linkaddress": editpiclink.Linkaddress, "mtime": time.Now().Unix()}).Error
  546. return err
  547. }
  548. func GetPatientRotations(id int64,orgid int64)(models.SgjPatientRotation,error) {
  549. rotation := models.SgjPatientRotation{}
  550. err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&rotation).Error
  551. return rotation,err
  552. }
  553. func UpdateRotationByid(id int64,orgid int64,rotation models.SgjPatientRotation)(error) {
  554. err := service.PatientWriteDB().Model(rotation).Where("id=? AND user_org_id = ? AND status =?", id, orgid, 1).Update(map[string]interface{}{"title": rotation.Title, "sort": rotation.Sort, "rotation_images": rotation.RotationImages, "mtime": time.Now().Unix()}).Error
  555. return err
  556. }
  557. func UpdateModelById(id int64,orgid int64,model models.SgjPatientModel) error {
  558. err := service.PatientWriteDB().Model(model).Where("id=? AND user_org_id =? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": model.Title, "sort": model.Sort, "mtime": time.Now().Unix()}).Error
  559. return err
  560. }
  561. func QuerEditMarginById(id int64,orgid int64)(models.SgjPatientEditmargin,error) {
  562. editmargin := models.SgjPatientEditmargin{}
  563. err := service.PatientReadDB().Model(editmargin).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Find(&editmargin).Error
  564. return editmargin,err
  565. }
  566. func UpdateMarginById(id int64,orgid int64,editmargin models.SgjPatientEditmargin) error {
  567. err := service.PatientWriteDB().Model(editmargin).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"margintitle": editmargin.Margtitle, "margimage": editmargin.Margimage, "marginaddress": editmargin.Marginaddress}).Error
  568. return err
  569. }
  570. func GetActivitiesById(orgid int64)(models.SgjPatientAddactivity,error) {
  571. addactivity := models.SgjPatientAddactivity{}
  572. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error
  573. fmt.Println("查询活动列表错误",err)
  574. return addactivity,err
  575. }
  576. func GetAllActivities(orgid int64,limit int64)(activity []models.Activity,err error) {
  577. err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Limit(limit).Find(&activity).Error
  578. return
  579. }
  580. func GetArticleType(orgid int64)(category []models.ArticleCategory,err error) {
  581. err = service.PatientReadDB().Model(category).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&category).Error
  582. return category,err
  583. }
  584. func AddActiclelist(articlelist *models.SgjPatientArticlelist)(error) {
  585. err := service.PatientWriteDB().Model(articlelist).Create(&articlelist).Error
  586. return err
  587. }
  588. func GetArticlelist(orgid int64)(models.SgjPatientArticlelist,error) {
  589. articlelist := models.SgjPatientArticlelist{}
  590. err := service.PatientReadDB().Where("user_org_id = ? AND Status = ?", orgid, 1).Last(&articlelist).Error
  591. fmt.Println("错误",err)
  592. return articlelist,err
  593. }
  594. func GetAllArticles(orgid int64,limit int64)(articlelist []models.Articles,err error) {
  595. err = service.PatientReadDB().Model(articlelist).Where("user_org_id = ? AND Status = ?", orgid, 1).Limit(limit).Find(&articlelist).Error
  596. return
  597. }
  598. //func GetAllArticlesDetail(id int64) {
  599. //
  600. //}
  601. func GetArticlelistById(modeid int64,orgID int64)(models.SgjPatientArticlelist,error) {
  602. articlelist := models.SgjPatientArticlelist{}
  603. err := service.PatientReadDB().Model(articlelist).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&articlelist).Error
  604. return articlelist,err
  605. }
  606. func GetAllActivitiById(modeid int64,orgID int64)(models.SgjPatientAddactivity,error) {
  607. addactivity := models.SgjPatientAddactivity{}
  608. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&addactivity).Error
  609. return addactivity,err
  610. }
  611. func UpdateArticeDetail(id int64,orgid int64,articlelist models.SgjPatientArticlelist)error {
  612. err := service.PatientWriteDB().Model(articlelist).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": articlelist.Title, "sort": articlelist.Sort, "number": articlelist.Number, "mtime": time.Now().Unix()}).Error
  613. return err
  614. }
  615. func GetMacImagesByModeid(modeid int64,orgid int64)(macnavigation []models.SgjPatientEditmargin,err error) {
  616. err = service.PatientReadDB().Model(macnavigation).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&macnavigation).Error
  617. return macnavigation,err
  618. }
  619. func GetModelById(id int64 ,orgid int64)(models.SgjPatientModel,error) {
  620. model := models.SgjPatientModel{}
  621. err := service.PatientReadDB().Model(model).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&model).Error
  622. return model,err
  623. }
  624. func GetOffENvironmentById(id int64,orgid int64)(models.SgjPatientOffenvironment,error) {
  625. offenvironment := models.SgjPatientOffenvironment{}
  626. err := service.PatientReadDB().Model(offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  627. return offenvironment,err
  628. }
  629. func AddOfficeThree(enviroimages *models.SgjPatientEnviroimages)(error) {
  630. err := service.PatientWriteDB().Model(&enviroimages).Create(&enviroimages).Error
  631. return err
  632. }
  633. func GetOfficeTwoVisible(orgid int64,id int64)(models.SgjPatientEnviroimages,error) {
  634. enviroimages := models.SgjPatientEnviroimages{}
  635. err := service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&enviroimages).Error
  636. return enviroimages,err
  637. }
  638. func UpdateOfficeTwo(orgid int64,id int64,enviroimages models.SgjPatientEnviroimages) error {
  639. err := service.PatientWriteDB().Model(&enviroimages).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Update(map[string]interface{}{"enviroimages": enviroimages.Enviroimages, "sort": enviroimages.Sort, "mtime": time.Now().Unix()}).Error
  640. return err
  641. }
  642. func GetQueryEnviroimage(orgid int64,mid int64)(enviroimages []models.SgjPatientEnviroimages,err error) {
  643. err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, mid,1).Find(&enviroimages).Error
  644. return enviroimages,err
  645. }
  646. func DeleteOfficeById(id int64,orgid int64)(error) {
  647. err := service.PatientWriteDB().Model(models.SgjPatientEnviroimages{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0,"modeid":0, "mtime": time.Now().Unix()}).Error
  648. return err
  649. }
  650. func GetArticleById(classid int64,orgid int64)(articlelist []models.Articles,err error) {
  651. err = service.PatientReadDB().Model(models.Articles{}).Where("class_id = ? AND user_org_id = ? AND status = ?", classid, orgid,1).Find(&articlelist).Error
  652. return
  653. }
  654. func GetAllActivity(orgid int64)(activtity []models.Activity,err error) {
  655. err = service.PatientReadDB().Model(models.Activity{}).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&activtity).Error
  656. return
  657. }
  658. func AddLinkAddress(linkaddress *models.SgjPatientLinkaddress) error {
  659. err := service.PatientWriteDB().Create(&linkaddress).Error
  660. return err
  661. }
  662. func GetLinkAddress(orgid int64)(models.SgjPatientLinkaddress,error) {
  663. linkaddress := models.SgjPatientLinkaddress{}
  664. err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND status = ? ", orgid, 1).Last(&linkaddress).Error
  665. return linkaddress,err
  666. }
  667. func QuerylinkAddress(id int64,orgid int64)(models.SgjPatientLinkaddress,error) {
  668. linkaddress := models.SgjPatientLinkaddress{}
  669. err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&linkaddress).Error
  670. return linkaddress,err
  671. }
  672. func GetAllConnecway(orgid int64)(connect []models.SgjPatientConnection,err error) {
  673. err = service.PatientReadDB().Model(&connect).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&connect).Error
  674. return
  675. }
  676. func GetConnecway(orgid int64,id int64)(models.SgjPatientOrdmodel,error) {
  677. ordmodel := models.SgjPatientOrdmodel{}
  678. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND status = ? AND id = ?", orgid, 1,id).Find(&ordmodel).Error
  679. return ordmodel,err
  680. }
  681. func GetConnecwayById(orgid int64,id int64)(models.SgjPatientConnection,error) {
  682. connection := models.SgjPatientConnection{}
  683. err := service.PatientReadDB().Model(&connection).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&connection).Error
  684. return connection,err
  685. }
  686. func UpdateConnectway(id int64,orgid int64,connection models.SgjPatientConnection) error {
  687. err := service.PatientWriteDB().Model(&connection).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": connection.Title, "connecway": connection.Connecway, "content": connection.Content,"mtime":time.Now().Unix()}).Error
  688. return err
  689. }
  690. func AddConnectways(connection *models.SgjPatientConnection) error {
  691. err := service.PatientWriteDB().Create(&connection).Error
  692. return err
  693. }
  694. func UpdateConnectways(id int64,orgid int64,connectway models.SgjPatientConnectway) error {
  695. err := service.PatientWriteDB().Model(&connectway).Where("mode_id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": connectway.Title, "sort": connectway.Sort, "ctime": time.Now().Unix()}).Error
  696. return err
  697. }
  698. func GetHostpitalIntroduction(orgid int64,id int64)(models.SgjPatientOrdmodel,error) {
  699. ordmodel := models.SgjPatientOrdmodel{}
  700. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&ordmodel).Error
  701. return ordmodel,err
  702. }
  703. func GetHostpitaAddress(orgid int64,moid int64)(models.SgjPatientHosaddress,error) {
  704. hosaddress := models.SgjPatientHosaddress{}
  705. err := service.PatientReadDB().Model(&hosaddress).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, moid, 1).Find(&hosaddress).Error
  706. return hosaddress,err
  707. }
  708. func UpdateHosAddress(id int64,orgid int64,hosaddress models.SgjPatientHosaddress)error {
  709. err := service.PatientWriteDB().Model(&hosaddress).Where("modeid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": hosaddress.Title, "sort": hosaddress.Sort, "address": hosaddress.Address, "mtime": time.Now().Unix()}).Error
  710. return err
  711. }
  712. func AddPicLinkAddress(conlinkaddress *models.SgjPatientConlinkaddress) error {
  713. err := service.PatientWriteDB().Create(&conlinkaddress).Error
  714. return err
  715. }
  716. func GetConLinkAddressById(orgid int64)(models.SgjPatientConlinkaddress,error) {
  717. conlinkaddress := models.SgjPatientConlinkaddress{}
  718. err := service.PatientReadDB().Model(&conlinkaddress).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conlinkaddress).Error
  719. return conlinkaddress,err
  720. }
  721. func GetLinkAddressDetail(orgid int64,conid int64)(models.SgjPatientConlinkaddress,error) {
  722. conlinkaddress := models.SgjPatientConlinkaddress{}
  723. err := service.PatientReadDB().Where("user_org_id = ? AND con_id = ? AND status = ?", orgid, conid, 1).Find(&conlinkaddress).Error
  724. return conlinkaddress,err
  725. }
  726. func UpdatePicFformThree(orgid int64,id int64,conlinkaddress models.SgjPatientConlinkaddress) error {
  727. err := service.PatientReadDB().Model(&conlinkaddress).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Update(map[string]interface{}{"linktype": conlinkaddress.Linktype, "linktypetwo": conlinkaddress.Linktypetwo, "linktypethree": conlinkaddress.Linktypethree, "linktypefour": conlinkaddress.Linktypefour,"linkaddress":conlinkaddress.Linkaddress,"defineaddress":conlinkaddress.Defineaddress}).Error
  728. return err
  729. }
  730. func GetEnImagesTwo(orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  731. err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&editpiclink).Error
  732. return editpiclink,err
  733. }
  734. func GetEnImagesThree(orgid int64)(conrotation []models.SgjPatientConrotation,err error) {
  735. err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&conrotation).Error
  736. return conrotation,err
  737. }
  738. func AddMagiclinkData(magiclink *models.SgjPatientMagiclink)error {
  739. err := service.PatientWriteDB().Create(&magiclink).Error
  740. return err
  741. }
  742. func GetMacLinkAddress(orgid int64)(models.SgjPatientMagiclink,error) {
  743. patientMagiclink := models.SgjPatientMagiclink{}
  744. err := service.PatientReadDB().Model(&patientMagiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&patientMagiclink).Error
  745. return patientMagiclink,err
  746. }
  747. func UpdateEditMagin(orgid int64,ids[] int64,editmargin models.SgjPatientEditmargin)(err error) {
  748. if(len(ids) == 1){
  749. err = service.PatientWriteDB().Model(&models.SgjPatientEditmargin{}).Where("id= ? AND user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": editmargin.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error
  750. }else {
  751. err = service.PatientWriteDB().Model(&models.SgjPatientEditmargin{}).Where("id IN(?) and user_org_id = ? ", ids, orgid).Update(map[string]interface{}{"modeid": editmargin.Modeid, "status": 1,"img_show":0, "mtime": time.Now().Unix()}).Error
  752. }
  753. return
  754. }
  755. func AddMacgicform(editmargin *models.SgjPatientEditmargin)error {
  756. err := service.PatientWriteDB().Create(&editmargin).Error
  757. return err
  758. }
  759. func GetMacImagesDetail(orgid int64,modeid int64)(editmargin []models.SgjPatientEditmargin,err error) {
  760. err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND modeid = ?", orgid, 1, modeid).Find(&editmargin).Error
  761. return editmargin,err
  762. }
  763. func DeletMacImagesDetail(id int64,orgid int64)(error) {
  764. err := service.PatientWriteDB().Model(models.SgjPatientEditmargin{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0,"modeid":0, "mtime": time.Now().Unix()}).Error
  765. return err
  766. }
  767. func GetEditMacImageDetailById(orgid int64,id int64)(models.SgjPatientEditmargin,error) {
  768. editmargin := models.SgjPatientEditmargin{}
  769. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, id).Find(&editmargin).Error
  770. return editmargin,err
  771. }
  772. func UpdateEditMacFormById(id int64,orgid int64,editmargin models.SgjPatientEditmargin)(err error) {
  773. err = service.PatientWriteDB().Model(&models.SgjPatientEditmargin{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"margtitle": editmargin.Margtitle, "margimage": editmargin.Margimage, "jumpset": editmargin.Jumpset, "marginaddress": editmargin.Marginaddress, "mtime": time.Now().Unix()}).Error
  774. return err
  775. }
  776. func GetLikeMacAddressById(orgid int64,id int64)(models.SgjPatientMagiclink,error) {
  777. magiclink := models.SgjPatientMagiclink{}
  778. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, id).Find(&magiclink).Error
  779. return magiclink,err
  780. }
  781. func GetAllArticeList(orgid int64)(articles []models.Articles,err error) {
  782. err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&articles).Error
  783. return articles,err
  784. }
  785. func UpdateLinkAddress(id int64,orgid int64,magiclink models.SgjPatientMagiclink)error {
  786. err := service.PatientWriteDB().Model(&models.SgjPatientMagiclink{}).Where("id = ? AND user_org_id = ? ", id, orgid).Update(map[string]interface{}{"linktype": magiclink.Linktype, "instationlink": magiclink.Instationlink, "articetype": magiclink.Articetype, "phone": magiclink.Phone, "outstationlink": magiclink.Outstationlink, "linkaddress": magiclink.Linkaddress, "title": magiclink.Title, "mtime": time.Now().Unix()}).Error
  787. return err
  788. }
  789. func AddMacLinkAddress(magiclink *models.SgjPatientMagiclink)error {
  790. err := service.PatientWriteDB().Create(&magiclink).Error
  791. return err
  792. }
  793. func GetPatientLinkAddress(id int64,orgid int64)(models.SgjPatientLinkaddress,error) {
  794. linkaddress := models.SgjPatientLinkaddress{}
  795. err := service.PatientReadDB().Where(" id = ? AND user_org_id = ?", id, orgid).Find(&linkaddress).Error
  796. return linkaddress,err
  797. }
  798. func GetCountImages(orgid int64)(edipiclink []models.SgjPatientEditpiclink,total int64,err error) {
  799. err = service.PatientReadDB().Where("user_org_id = ? AND img_show = ? AND status = ?", orgid,1,1).Find(&edipiclink).Count(&total).Error
  800. return edipiclink,total,err
  801. }
  802. func GetTotalCount(orgid int64)(conrotation []models.SgjPatientConrotation,total int64,err error) {
  803. err = service.PatientReadDB().Where("user_org_id = ? AND img_show = ? AND status = ?", orgid, 1, 1).Find(&conrotation).Count(&total).Error
  804. return conrotation,total,err
  805. }
  806. func GetCountPicImages(orgid int64,modeid int64)(edipiclink []models.SgjPatientEditpiclink,total int64,err error) {
  807. err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Find(&edipiclink).Count(&total).Error
  808. return edipiclink,total,err
  809. }
  810. func QueryEditpiclinkCount(mid int64,orgid int64)(editpiclink []models.SgjPatientEditpiclink,total int64,err error) {
  811. err= service.PatientWriteDB().Where("modeid = ? AND user_org_id =? AND status = ?", mid, orgid, 1).Find(&editpiclink).Count(&total).Error
  812. return editpiclink,total,err
  813. }
  814. func AddNavgationlink(navgationlink *models.SgjPatientNavgationlink)error {
  815. err := service.PatientWriteDB().Create(&navgationlink).Error
  816. return err
  817. }
  818. func GetNavgationlinkLastData(orgid int64)(models.SgjPatientNavgationlink,error) {
  819. navgationlink := models.SgjPatientNavgationlink{}
  820. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&navgationlink).Error
  821. return navgationlink,err
  822. }
  823. func GetNavgationlinkAddressBylinkId(orgid int64,linkid int64)(models.SgjPatientNavgationlink,error) {
  824. navgationlink := models.SgjPatientNavgationlink{}
  825. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, linkid).Find(&navgationlink).Error
  826. return navgationlink,err
  827. }
  828. func UpdateditnavigationLink(orgid int64,id int64,navgationlink models.SgjPatientNavgationlink) error {
  829. err := service.PatientWriteDB().Model(&navgationlink).Where("user_org_id = ? AND id =?", orgid, id).Update(map[string]interface{}{"linktype": navgationlink.Linktype, "linktypetwo": navgationlink.Linktypetwo, "articetype": navgationlink.Articetype, "title": navgationlink.Title, "phone": navgationlink.Phone, "outstation":
  830. navgationlink.Outstation, "linkaddress": navgationlink.Linkaddress, "mtime": time.Now().Unix()}).Error
  831. return err
  832. }