scrm-go

site_microwebsite_service.go 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  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 UpdateOffices(id int64,orgID int64,offices models.SgjPatientOffices) error {
  204. 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
  205. return err
  206. }
  207. func GetHospital(Orgid int64)(hostital []*models.SgjPatientHospital,err error) {
  208. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", Orgid, 1).Order("sort").Find(&hostital).Error
  209. return
  210. }
  211. func GetData(orgid int64)(model []*models.SgjPatientModel,err error) {
  212. db := service.PatientReadDB().Table("sgj_patient_model as m").Where(" m.status = ?", 1)
  213. fmt.Println("db是什么?",db)
  214. if(orgid > 0){
  215. db = db.Where("user_org_id = ? ", orgid)
  216. }
  217. err = db.Preload("Hospitals").Preload("Offices").Preload("Doctors").Preload("OfficeEnviroment").
  218. Preload("Editdoctor").Preload("Rotation").Preload("Macnavigation").
  219. 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
  220. return
  221. }
  222. func UpdateDoctorsInfo(orgID int64,ids[] int64,editdoctor models.SgjPatientEditdoctor)(err error) {
  223. if(len(ids)==1){
  224. 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
  225. }else {
  226. 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
  227. }
  228. return
  229. }
  230. func QueryEditDoc(mid int64,orgid int64)(models.SgjPatientDocinfo, error) {
  231. editdotor := models.SgjPatientDocinfo{}
  232. err := service.PatientReadDB().Model(&editdotor).Where("modelid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdotor).Error
  233. return editdotor,err
  234. }
  235. func QuerEditDocByid(mid int64,orgid int64)(editdoctor []*models.SgjPatientEditdoctor,err error) {
  236. err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("doc_sort").Find(&editdoctor).Error
  237. return
  238. }
  239. func QueryEditImages(orgid int64,id int64)(models.SgjPatientEditdoctor,error) {
  240. editdoctor := models.SgjPatientEditdoctor{}
  241. err := service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editdoctor).Error
  242. return editdoctor,err
  243. }
  244. func QueryEditDoctor(id int64,orgid int64)(models.SgjPatientEditdoctor,error) {
  245. docinfo := models.SgjPatientEditdoctor{}
  246. err := service.PatientReadDB().Model(&docinfo).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&docinfo).Error
  247. return docinfo,err
  248. }
  249. func UpDateEditdoctor(id int64,orgid int64,editdoctor models.SgjPatientEditdoctor) error {
  250. 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
  251. return err
  252. }
  253. func Upadatedocdata(orgid int64,id int64,docinfo models.SgjPatientDocinfo) error {
  254. 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
  255. return err
  256. }
  257. func QuerOfficeEnviroment(id int64,orgid int64)(models.SgjPatientOffenvironment,error) {
  258. offenvironment := models.SgjPatientOffenvironment{}
  259. err := service.PatientReadDB().Model(&offenvironment).Where("modelid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  260. return offenvironment,err
  261. }
  262. func QueryOfficeformById(modeid int64,orgid int64)(patientenviroimages []*models.SgjPatientEnviroimages,err error) {
  263. err = service.PatientReadDB().Model(&patientenviroimages).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&patientenviroimages).Error
  264. return
  265. }
  266. func UpdateOfficeEnvironment(id int64,orgid int64)(models.SgjPatientOffenvironment,error) {
  267. offenvironment := models.SgjPatientOffenvironment{}
  268. err := service.PatientReadDB().Model(&offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  269. return offenvironment , err
  270. }
  271. func UpdatePatientOffenvironment(id int64,orgid int64,offenvironment models.SgjPatientOffenvironment)(error) {
  272. 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
  273. return err
  274. }
  275. func QueryHispitalDetail(orgid int64,id int64)(models.SgjPatientHospital,error) {
  276. hospital := models.SgjPatientHospital{}
  277. err := service.PatientReadDB().Model(&hospital).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&hospital).Error
  278. return hospital,err
  279. }
  280. func GetOfficeDetail(orgid int64,id int64)(models.SgjPatientOffices,error) {
  281. offices := models.SgjPatientOffices{}
  282. err := service.PatientReadDB().Model(&offices).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&offices).Error
  283. return offices,err
  284. }
  285. func GetDoctorDetail(orgid int64,id int64)(editdoctor []*models.SgjPatientEditdoctor,err error) {
  286. err = service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Order("doc_sort").Find(&editdoctor).Error
  287. return
  288. }
  289. func GetOfficEnviromentDetail(orgid int64,id int64)(models.SgjPatientOffenvironment,error) {
  290. offenvironment := models.SgjPatientOffenvironment{}
  291. err := service.PatientReadDB().Model(&offenvironment).Where("user_org_id = ? AND modelid = ? AND status = ?", orgid, id, 1).Order("sort").Find(&offenvironment).Error
  292. return offenvironment,err
  293. }
  294. func AddNavigation(navigation *models.SgjPatientNavigation)error {
  295. err := service.PatientWriteDB().Create(&navigation).Error
  296. return err
  297. }
  298. func GetNavigationList(orgid int64)(navigation []*models.SgjPatientNavigation,err error) {
  299. err = service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
  300. return
  301. }
  302. func AddShareInfo(share *models.SgjPatientShare) error {
  303. err := service.PatientWriteDB().Create(&share).Error
  304. return err
  305. }
  306. func GetShareInfo(orgid int64)(models.SgjPatientShare,error) {
  307. share := models.SgjPatientShare{}
  308. err := service.PatientReadDB().Model(&share).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&share).Error
  309. return share,err
  310. }
  311. func DeleteNavitionById(orgID int64,id int64)(error) {
  312. 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
  313. return err
  314. }
  315. func AddConnecWay(connectway *models.SgjPatientConnectway) error {
  316. err := service.PatientWriteDB().Create(&connectway).Error
  317. return err
  318. }
  319. func AddOrdModel(ordmodel *models.SgjPatientOrdmodel)error {
  320. err := service.PatientWriteDB().Create(&ordmodel).Error
  321. return err
  322. }
  323. func AddHosAddress(hosaddress *models.SgjPatientHosaddress) error {
  324. err := service.PatientWriteDB().Create(&hosaddress).Error
  325. return err
  326. }
  327. func QueryOrdeModelByID(orgid int64)(models.SgjPatientOrdmodel,error) {
  328. ordmodel := models.SgjPatientOrdmodel{}
  329. err := service.PatientReadDB().Where("user_org_id = ? AND status = ? ", orgid, 1).Last(&ordmodel).Error
  330. return ordmodel,err
  331. }
  332. func UpdateConrotaions(orgid int64,ids[] int64,conrotation models.SgjPatientConrotation)(err error) {
  333. if(len(ids)==1){
  334. 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
  335. }else {
  336. 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
  337. }
  338. return
  339. }
  340. func DeleteModle(orgid int64,id int64)(error) {
  341. 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
  342. return err
  343. }
  344. func DeleteModleByModeID(orgid int64,mid int64)(error) {
  345. 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
  346. return err
  347. }
  348. func GetOrederModel(orgid int64)(model []*models.SgjPatientOrdmodel,err error) {
  349. db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1)
  350. if(orgid > 0){
  351. db = db.Where("user_org_id = ?", orgid)
  352. }
  353. err = db.Preload("Hosaddress").Preload("Connectway").Preload("Worktime").Preload("Rideway").Preload("Oldration").
  354. Select("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error
  355. fmt.Println("sql错误是什么",err)
  356. return
  357. }
  358. func AddRotationpic(conrotation models.SgjPatientConrotation) error {
  359. err := service.PatientWriteDB().Create(&conrotation).Error
  360. return err
  361. }
  362. func GetRotationImages(orgid int64)(conrotation []models.SgjPatientConrotation,err error) {
  363. err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1,1).Find(&conrotation).Error
  364. return conrotation,err
  365. }
  366. func AddrotationImage(oldrotation *models.SgjPatientOldrotation) error {
  367. err := service.PatientWriteDB().Create(&oldrotation).Error
  368. return err
  369. }
  370. func UpdateConrotation(orgid int64,ids[] int64,conrotation models.SgjPatientConrotation)(err error) {
  371. if(len(ids)==1){
  372. 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
  373. }else {
  374. 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
  375. }
  376. return
  377. }
  378. func AddImageslink(editpiclink *models.SgjPatientEditpiclink) error {
  379. err := service.PatientWriteDB().Create(&editpiclink).Error
  380. return err
  381. }
  382. func GetEnImages(orgid int64)(enviroimages []models.SgjPatientEnviroimages,err error) {
  383. err = service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&enviroimages).Error
  384. return enviroimages,err
  385. }
  386. func UpdateImages(orgid int64,ids [] int64,enviroimages models.SgjPatientEnviroimages)(err error) {
  387. if(len(ids)==1){
  388. err = service.PatientWriteDB().Model(&models.SgjPatientEnviroimages{}).Where("id = ? AND user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": enviroimages.Modeid, "status": 1, "mtime": time.Now().Unix()}).Error
  389. }else {
  390. err = service.PatientWriteDB().Model(&models.SgjPatientEnviroimages{}).Where("id IN(?) and user_org_id = ?", ids, orgid).Update(map[string]interface{}{"modeid": enviroimages.Modeid, "status": 1, "mtime": time.Now().Unix()}).Error
  391. }
  392. return
  393. }
  394. func GetEditEnvirimagesById(orgid int64,id int64)(models.SgjPatientEnviroimages,error) {
  395. enviroimages := models.SgjPatientEnviroimages{}
  396. err := service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND id =? AND status = ?", orgid, id, 1).Find(&enviroimages).Error
  397. return enviroimages,err
  398. }
  399. func UpdateEnviroimages(id int64,orgid int64,enviroimages models.SgjPatientEnviroimages)( err error) {
  400. 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
  401. return err
  402. }
  403. func GetEditImages(orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  404. err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ? AND img_show = ?",orgid,1,1).Find(&editpiclink).Error
  405. return editpiclink,err
  406. }
  407. func AddMagicNavi(editmargin *models.SgjPatientEditmargin) error {
  408. err := service.PatientWriteDB().Create(&editmargin).Error
  409. return err
  410. }
  411. func GetMagicImages(orgid int64)( editmargin []models.SgjPatientEditmargin,err error) {
  412. err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1,1).Find(&editmargin).Error
  413. return editmargin,err
  414. }
  415. func AddMarginChart(macnavigation *models.SgjPatientMacnavigation) error {
  416. err := service.PatientWriteDB().Create(&macnavigation).Error
  417. return err
  418. }
  419. func DeleteRotations(id int64, orgid int64)(error) {
  420. err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  421. return err
  422. }
  423. func UpdateRotationImages(orgid int64,id int64)(models.SgjPatientEditpiclink,error){
  424. editpiclink := models.SgjPatientEditpiclink{}
  425. err := service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editpiclink).Error
  426. return editpiclink,err
  427. }
  428. func SaveRotationImages(id int64,orgid int64,editpiclink models.SgjPatientEditpiclink)error {
  429. 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
  430. return err
  431. }
  432. func EditNavigation(orgid int64,id int64)(models.SgjPatientNavigation,error){
  433. navigation := models.SgjPatientNavigation{}
  434. err := service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&navigation).Error
  435. return navigation,err
  436. }
  437. func UpdateNavtion(id int64,orgid int64,navigation models.SgjPatientNavigation) error {
  438. 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
  439. return err
  440. }
  441. func DeleteImages(id int64,orgid int64)(error) {
  442. err := service.PatientWriteDB().Model(models.SgjPatientConrotation{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  443. return err
  444. }
  445. func DeleteSingleImages(id int64,orgid int64) (error) {
  446. err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  447. return err
  448. }
  449. func AddActivity(addactivity *models.SgjPatientAddactivity) error {
  450. err := service.PatientWriteDB().Create(&addactivity).Error
  451. return err
  452. }
  453. func QueryActivity(id int64,orgid int64)(models.SgjPatientAddactivity,error) {
  454. addactivity := models.SgjPatientAddactivity{}
  455. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&addactivity).Error
  456. return addactivity,err
  457. }
  458. func UpdateActivit(id int64,orgid int64,addactivity models.SgjPatientAddactivity) error {
  459. 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
  460. return err
  461. }
  462. func DeleteMargin(id int64,orgid int64)(error) {
  463. 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
  464. return err
  465. }
  466. func GetEditRotationImages(id int64,orgid int64)(models.SgjPatientOldrotation,error) {
  467. oldrotation := models.SgjPatientOldrotation{}
  468. err := service.PatientReadDB().Model(oldrotation).Where("mode_id = ? AND user_org_id = ?", id, orgid).Find(&oldrotation).Error
  469. return oldrotation,err
  470. }
  471. func GetEditConrotion(id int64,orgid int64)(conrotation []models.SgjPatientConrotation, err error) {
  472. err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error
  473. return conrotation,err
  474. }
  475. func EditVisibleById(id int64,orgid int64)(models.SgjPatientConrotation,error) {
  476. conrotation := models.SgjPatientConrotation{}
  477. err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error
  478. return conrotation,err
  479. }
  480. func UpdateEditpic(id int64,orgid int64,conrotation models.SgjPatientConrotation) error {
  481. 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
  482. return err
  483. }
  484. func GetPatientConrotationLast(orgid int64)( models.SgjPatientConrotation,error){
  485. conrotation := models.SgjPatientConrotation{}
  486. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conrotation).Error
  487. return conrotation,err
  488. }
  489. func UpdateConLinkAddress(orgid int64,conid int64,conlinkaddress models.SgjPatientConlinkaddress) error {
  490. 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
  491. return err
  492. }
  493. func AddEditpic(conrotation *models.SgjPatientConrotation)(error) {
  494. err := service.PatientWriteDB().Create(&conrotation).Error
  495. return err
  496. }
  497. func QueryOldrotion(id int64,orgid int64)(models.SgjPatientOldrotation,error) {
  498. conrotation := models.SgjPatientOldrotation{}
  499. err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ? ", id, orgid).Find(&conrotation).Error
  500. return conrotation,err
  501. }
  502. func UpdateConrotaionById(id int64,orgid int64,oldrotation models.SgjPatientOldrotation)(error) {
  503. 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
  504. return err
  505. }
  506. func GetPatientRotaion(id int64,orgid int64)(models.SgjPatientRotation,error) {
  507. rotation := models.SgjPatientRotation{}
  508. err := service.PatientReadDB().Model(&rotation).Where("model_id = ? AND user_org_id = ?", id, orgid).Find(&rotation).Error
  509. return rotation,err
  510. }
  511. func GetPatientRotationById(id int64,orgid int64)(models.SgjPatientRotation,error) {
  512. rotation := models.SgjPatientRotation{}
  513. err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id =?", id, orgid).Find(&rotation).Error
  514. return rotation,err
  515. }
  516. func QueryEditpiclink(id int64,orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  517. err = service.PatientReadDB().Model(editpiclink).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error
  518. return editpiclink,err
  519. }
  520. func GetEditSingleVisible(id int64,orgid int64)(models.SgjPatientEditpiclink,error) {
  521. editpiclink := models.SgjPatientEditpiclink{}
  522. err := service.PatientReadDB().Model(&editpiclink).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error
  523. return editpiclink,err
  524. }
  525. func GetQueryEditpiclink(id int64,orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  526. err = service.PatientReadDB().Model(&editpiclink).Where("id=? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error
  527. return editpiclink,err
  528. }
  529. func UpdateEditPatPicLink(id int64,orgid int64,editpiclink models.SgjPatientEditpiclink)(error) {
  530. 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
  531. return err
  532. }
  533. func GetPatientRotations(id int64,orgid int64)(models.SgjPatientRotation,error) {
  534. rotation := models.SgjPatientRotation{}
  535. err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&rotation).Error
  536. return rotation,err
  537. }
  538. func UpdateRotationByid(id int64,orgid int64,rotation models.SgjPatientRotation)(error) {
  539. 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
  540. return err
  541. }
  542. func UpdateModelById(id int64,orgid int64,model models.SgjPatientModel) error {
  543. 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
  544. return err
  545. }
  546. func QuerEditMarginById(id int64,orgid int64)(models.SgjPatientEditmargin,error) {
  547. editmargin := models.SgjPatientEditmargin{}
  548. err := service.PatientReadDB().Model(editmargin).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Find(&editmargin).Error
  549. return editmargin,err
  550. }
  551. func UpdateMarginById(id int64,orgid int64,editmargin models.SgjPatientEditmargin) error {
  552. 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
  553. return err
  554. }
  555. func GetActivitiesById(orgid int64)(models.SgjPatientAddactivity,error) {
  556. addactivity := models.SgjPatientAddactivity{}
  557. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error
  558. fmt.Println("查询活动列表错误",err)
  559. return addactivity,err
  560. }
  561. func GetAllActivities(orgid int64,limit int64)(activity []models.Activity,err error) {
  562. err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Limit(limit).Find(&activity).Error
  563. return
  564. }
  565. func GetArticleType(orgid int64)(category []models.ArticleCategory,err error) {
  566. err = service.PatientReadDB().Model(category).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&category).Error
  567. return category,err
  568. }
  569. func AddActiclelist(articlelist *models.SgjPatientArticlelist)(error) {
  570. err := service.PatientWriteDB().Model(articlelist).Create(&articlelist).Error
  571. return err
  572. }
  573. func GetArticlelist(orgid int64)(models.SgjPatientArticlelist,error) {
  574. articlelist := models.SgjPatientArticlelist{}
  575. err := service.PatientReadDB().Where("user_org_id = ? AND Status = ?", orgid, 1).Last(&articlelist).Error
  576. fmt.Println("错误",err)
  577. return articlelist,err
  578. }
  579. func GetAllArticles(orgid int64,limit int64)(articlelist []models.Articles,err error) {
  580. err = service.PatientReadDB().Model(articlelist).Where("user_org_id = ? AND Status = ?", orgid, 1).Limit(limit).Find(&articlelist).Error
  581. return
  582. }
  583. //func GetAllArticlesDetail(id int64) {
  584. //
  585. //}
  586. func GetArticlelistById(modeid int64,orgID int64)(models.SgjPatientArticlelist,error) {
  587. articlelist := models.SgjPatientArticlelist{}
  588. err := service.PatientReadDB().Model(articlelist).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&articlelist).Error
  589. return articlelist,err
  590. }
  591. func GetAllActivitiById(modeid int64,orgID int64)(models.SgjPatientAddactivity,error) {
  592. addactivity := models.SgjPatientAddactivity{}
  593. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&addactivity).Error
  594. return addactivity,err
  595. }
  596. func UpdateArticeDetail(id int64,orgid int64,articlelist models.SgjPatientArticlelist)error {
  597. 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
  598. return err
  599. }
  600. func GetMacImagesByModeid(modeid int64,orgid int64)(models.SgjPatientMacnavigation,error) {
  601. macnavigation := models.SgjPatientMacnavigation{}
  602. err := service.PatientReadDB().Model(macnavigation).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&macnavigation).Error
  603. return macnavigation,err
  604. }
  605. func GetModelById(id int64 ,orgid int64)(models.SgjPatientModel,error) {
  606. model := models.SgjPatientModel{}
  607. err := service.PatientReadDB().Model(model).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&model).Error
  608. return model,err
  609. }
  610. func GetOffENvironmentById(id int64,orgid int64)(models.SgjPatientOffenvironment,error) {
  611. offenvironment := models.SgjPatientOffenvironment{}
  612. err := service.PatientReadDB().Model(offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  613. return offenvironment,err
  614. }
  615. func AddOfficeThree(enviroimages *models.SgjPatientEnviroimages)(error) {
  616. err := service.PatientWriteDB().Model(&enviroimages).Create(&enviroimages).Error
  617. return err
  618. }
  619. func GetOfficeTwoVisible(orgid int64,id int64)(models.SgjPatientEnviroimages,error) {
  620. enviroimages := models.SgjPatientEnviroimages{}
  621. err := service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&enviroimages).Error
  622. return enviroimages,err
  623. }
  624. func UpdateOfficeTwo(orgid int64,id int64,enviroimages models.SgjPatientEnviroimages) error {
  625. 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
  626. return err
  627. }
  628. func DeleteOfficeById(id int64,orgid int64)(error) {
  629. err := service.PatientWriteDB().Model(models.SgjPatientEnviroimages{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  630. return err
  631. }
  632. func GetArticleById(classid int64,orgid int64)(articlelist []models.Articles,err error) {
  633. err = service.PatientReadDB().Model(models.Articles{}).Where("class_id = ? AND user_org_id = ? AND status = ?", classid, orgid,1).Find(&articlelist).Error
  634. return
  635. }
  636. func GetAllActivity(orgid int64)(activtity []models.Activity,err error) {
  637. err = service.PatientReadDB().Model(models.Activity{}).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&activtity).Error
  638. return
  639. }
  640. func AddLinkAddress(linkaddress *models.SgjPatientLinkaddress) error {
  641. err := service.PatientWriteDB().Create(&linkaddress).Error
  642. return err
  643. }
  644. func GetLinkAddress(orgid int64)(models.SgjPatientLinkaddress,error) {
  645. linkaddress := models.SgjPatientLinkaddress{}
  646. err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND status = ? ", orgid, 1).Last(&linkaddress).Error
  647. return linkaddress,err
  648. }
  649. func QuerylinkAddress(id int64,orgid int64)(models.SgjPatientLinkaddress,error) {
  650. linkaddress := models.SgjPatientLinkaddress{}
  651. err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&linkaddress).Error
  652. return linkaddress,err
  653. }
  654. func GetAllConnecway(orgid int64)(connect []models.SgjPatientConnection,err error) {
  655. err = service.PatientReadDB().Model(&connect).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&connect).Error
  656. return
  657. }
  658. func GetConnecway(orgid int64,id int64)(models.SgjPatientOrdmodel,error) {
  659. ordmodel := models.SgjPatientOrdmodel{}
  660. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND status = ? AND id = ?", orgid, 1,id).Find(&ordmodel).Error
  661. return ordmodel,err
  662. }
  663. func GetConnecwayById(orgid int64,id int64)(models.SgjPatientConnection,error) {
  664. connection := models.SgjPatientConnection{}
  665. err := service.PatientReadDB().Model(&connection).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&connection).Error
  666. return connection,err
  667. }
  668. func UpdateConnectway(id int64,orgid int64,connection models.SgjPatientConnection) error {
  669. 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
  670. return err
  671. }
  672. func AddConnectways(connection *models.SgjPatientConnection) error {
  673. err := service.PatientWriteDB().Create(&connection).Error
  674. return err
  675. }
  676. func UpdateConnectways(id int64,orgid int64,connectway models.SgjPatientConnectway) error {
  677. 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
  678. return err
  679. }
  680. func GetHostpitalIntroduction(orgid int64,id int64)(models.SgjPatientOrdmodel,error) {
  681. ordmodel := models.SgjPatientOrdmodel{}
  682. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&ordmodel).Error
  683. return ordmodel,err
  684. }
  685. func GetHostpitaAddress(orgid int64,moid int64)(models.SgjPatientHosaddress,error) {
  686. hosaddress := models.SgjPatientHosaddress{}
  687. err := service.PatientReadDB().Model(&hosaddress).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, moid, 1).Find(&hosaddress).Error
  688. return hosaddress,err
  689. }
  690. func UpdateHosAddress(id int64,orgid int64,hosaddress models.SgjPatientHosaddress)error {
  691. 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
  692. return err
  693. }
  694. func AddPicLinkAddress(conlinkaddress *models.SgjPatientConlinkaddress) error {
  695. err := service.PatientWriteDB().Create(&conlinkaddress).Error
  696. return err
  697. }
  698. func GetConLinkAddressById(orgid int64)(models.SgjPatientConlinkaddress,error) {
  699. conlinkaddress := models.SgjPatientConlinkaddress{}
  700. err := service.PatientReadDB().Model(&conlinkaddress).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conlinkaddress).Error
  701. return conlinkaddress,err
  702. }
  703. func GetLinkAddressDetail(orgid int64,conid int64)(models.SgjPatientConlinkaddress,error) {
  704. conlinkaddress := models.SgjPatientConlinkaddress{}
  705. err := service.PatientReadDB().Where("user_org_id = ? AND con_id = ? AND status = ?", orgid, conid, 1).Find(&conlinkaddress).Error
  706. return conlinkaddress,err
  707. }
  708. func UpdatePicFformThree(orgid int64,id int64,conlinkaddress models.SgjPatientConlinkaddress) error {
  709. 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
  710. return err
  711. }
  712. func GetEnImagesTwo(orgid int64)(editpiclink []models.SgjPatientEditpiclink,err error) {
  713. err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&editpiclink).Error
  714. return editpiclink,err
  715. }
  716. func GetEnImagesThree(orgid int64)(conrotation []models.SgjPatientConrotation,err error) {
  717. err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&conrotation).Error
  718. return conrotation,err
  719. }
  720. func AddMagiclinkData(magiclink *models.SgjPatientMagiclink)error {
  721. err := service.PatientWriteDB().Create(&magiclink).Error
  722. return err
  723. }
  724. func GetMacLinkAddress(orgid int64)(models.SgjPatientMagiclink,error) {
  725. patientMagiclink := models.SgjPatientMagiclink{}
  726. err := service.PatientReadDB().Model(&patientMagiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&patientMagiclink).Error
  727. return patientMagiclink,err
  728. }
  729. func UpdateEditMagin(orgid int64,ids[] int64,editmargin models.SgjPatientEditmargin)(err error) {
  730. if(len(ids) == 1){
  731. 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
  732. }else {
  733. 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
  734. }
  735. return
  736. }