site_microwebsite_service.go 81KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914
  1. package site_service
  2. import (
  3. "SCRM/models"
  4. "SCRM/service"
  5. "SCRM/utils"
  6. "fmt"
  7. "github.com/jinzhu/gorm"
  8. "github.com/robfig/cron"
  9. "strconv"
  10. "time"
  11. )
  12. // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
  13. var createDefalutDataCronJob *cron.Cron
  14. func BeginAutoCreateDefalutData() {
  15. createDefalutDataCronJob.Start()
  16. }
  17. func init() {
  18. utils.InfoLog("开启自动排班定时任务")
  19. createDefalutDataCronJob = cron.New()
  20. spec := "*/5 * * * * ?" // 每隔5秒执行一次
  21. createDefalutDataCronJob.AddFunc(spec, func() {
  22. AutoCreateDefalutSchedules()
  23. })
  24. }
  25. func AutoCreateDefalutSchedules() {
  26. utils.TraceLog("自动添加数据任务开始执行")
  27. //获取是10分前的时间
  28. var orginfo []*models.OrgInfo
  29. nowtime := time.Now().Unix()
  30. fmt.Println("当前时间", nowtime)
  31. timebefor := time.Now().Add(-time.Minute * 10).Unix()
  32. fmt.Println("10分钟之前时间", timebefor)
  33. //1570653733 //1570654333
  34. err := service.PatientReadDB().Raw("select * from sgj_users.sgj_user_org as u where u.ctime>=? AND u.ctime<= ?", timebefor, nowtime).Scan(&orginfo).Error
  35. fmt.Println("err", err)
  36. fmt.Println("orginfo", orginfo)
  37. for i := 0; i < len(orginfo); i++ {
  38. userOrgID := orginfo[i].ID
  39. orgintroduction := orginfo[i].OrgIntroduction
  40. telephone := orginfo[i].Telephone
  41. address := orginfo[i].Address
  42. fmt.Println("ID是设么", userOrgID)
  43. navigation, err := GetPatientNavigation(userOrgID)
  44. fmt.Println("err", err)
  45. if len(navigation) == 0 {
  46. patientNavigation := models.SgjPatientNavigation{
  47. Navtitle: "首页",
  48. Navimages: "https://images.shengws.com/2089_o_1571990714383.png",
  49. Status: 1,
  50. UserOrgId: userOrgID,
  51. Nonavimages: "https://images.shengws.com/2105_o_1571990730785.png",
  52. Linktype: 1,
  53. Ctime: time.Now().Unix(),
  54. }
  55. err := AddNavgation(&patientNavigation)
  56. fmt.Println("err", err)
  57. patientnavigationthree := models.SgjPatientNavigation{
  58. Navtitle: "客服",
  59. Navimages: "https://images.shengws.com/2101_o_1571990903053.png",
  60. Status: 1,
  61. UserOrgId: userOrgID,
  62. Nonavimages: "https://images.shengws.com/2113_o_1571990915581.png",
  63. Linktype: 2,
  64. Ctime: time.Now().Unix(),
  65. }
  66. err = AddNavgation(&patientnavigationthree)
  67. patientnavigationtwo := models.SgjPatientNavigation{
  68. Navtitle: "电话",
  69. Navimages: "https://images.shengws.com/2092_o_1571990776921.png",
  70. Status: 1,
  71. UserOrgId: userOrgID,
  72. Linktype: 3,
  73. Nonavimages: "https://images.shengws.com/2100_o_1571990784845.png",
  74. Ctime: time.Now().Unix(),
  75. }
  76. err = AddNavgation(&patientnavigationtwo)
  77. sgjPatientNavigation := models.SgjPatientNavigation{
  78. Navtitle: "联系我们",
  79. Navimages: "https://images.shengws.com/2124_o_1571990749565.png",
  80. Status: 1,
  81. UserOrgId: userOrgID,
  82. Nonavimages: "https://images.shengws.com/2079_o_1571990763549.png",
  83. Linktype: 4,
  84. Ctime: time.Now().Unix(),
  85. }
  86. err = AddNavgation(&sgjPatientNavigation)
  87. fmt.Println("err", err)
  88. }
  89. model, err := GetData(userOrgID)
  90. if len(model) == 0 {
  91. patientModel := models.SgjPatientModel{
  92. Title: "轮播图",
  93. Sort: 1,
  94. UserOrgId: userOrgID,
  95. Ctime: time.Now().Unix(),
  96. Status: 1,
  97. ModeType: 1,
  98. }
  99. err := AddPatientModelTwo(&patientModel)
  100. fmt.Println("err", err)
  101. sgjPatientModel, err := GetQueryModelByLastData(userOrgID)
  102. editpiclink := models.SgjPatientEditpiclink{
  103. Images: "https://images.shengws.com/2124_o_1570607834870.png",
  104. Sort: 1,
  105. UserOrgId: userOrgID,
  106. Status: 1,
  107. Ctime: time.Now().Unix(),
  108. Modeid: sgjPatientModel.ID,
  109. }
  110. err = AddPatientEdit(&editpiclink)
  111. fmt.Println("err", err)
  112. patientmodefour := models.SgjPatientModel{
  113. Title: "魔方导航",
  114. Sort: 2,
  115. UserOrgId: userOrgID,
  116. Ctime: time.Now().Unix(),
  117. Status: 1,
  118. ModeType: 8,
  119. }
  120. err = AddPatientModelTwo(&patientmodefour)
  121. sgjpatietnmodelfour, err := GetQueryModelByLastData(userOrgID)
  122. ID := int64(sgjpatietnmodelfour.ID + 1)
  123. fmt.Println("ID是多少", ID)
  124. modeid := strconv.FormatInt(ID, 10)
  125. magiclink := models.SgjPatientMagiclink{
  126. UserOrgId: userOrgID,
  127. Linktype: 2,
  128. Instationlink: ID,
  129. Ctime: time.Now().Unix(),
  130. Status: 1,
  131. }
  132. AddMacLinkAddress(&magiclink)
  133. patientMagiclink, err := GetMacLinkAddressByLastData(userOrgID)
  134. orgid := strconv.FormatInt(userOrgID, 10)
  135. KeID := int64(sgjpatietnmodelfour.ID + 3)
  136. OfficeID := strconv.FormatInt(KeID, 10)
  137. magiclinktwo := models.SgjPatientMagiclink{
  138. UserOrgId: userOrgID,
  139. Linktype: 2,
  140. Instationlink: KeID,
  141. Ctime: time.Now().Unix(),
  142. Status: 1,
  143. }
  144. AddMacLinkAddress(&magiclinktwo)
  145. patientMagiclinktwo, err := GetMacLinkAddressByLastData(userOrgID)
  146. ActiID := int64(sgjpatietnmodelfour.ID + 5)
  147. magiclinkthree := models.SgjPatientMagiclink{
  148. UserOrgId: userOrgID,
  149. Linktype: 2,
  150. Instationlink: ActiID,
  151. Ctime: time.Now().Unix(),
  152. Status: 1,
  153. }
  154. AddMacLinkAddress(&magiclinkthree)
  155. patientMagiclinkthree, err := GetMacLinkAddressByLastData(userOrgID)
  156. ActisID := strconv.FormatInt(ActiID, 10)
  157. ActivID := int64(sgjpatietnmodelfour.ID + 6)
  158. magiclinkfour := models.SgjPatientMagiclink{
  159. UserOrgId: userOrgID,
  160. Linktype: 2,
  161. Instationlink: ActivID,
  162. Ctime: time.Now().Unix(),
  163. Status: 1,
  164. }
  165. AddMacLinkAddress(&magiclinkfour)
  166. patientMagiclinkfour, err := GetMacLinkAddressByLastData(userOrgID)
  167. ActivsID := strconv.FormatInt(ActivID, 10)
  168. EnviID := int64(sgjpatietnmodelfour.ID + 4)
  169. magiclinkfive := models.SgjPatientMagiclink{
  170. UserOrgId: userOrgID,
  171. Linktype: 2,
  172. Instationlink: EnviID,
  173. Ctime: time.Now().Unix(),
  174. Status: 1,
  175. }
  176. AddMacLinkAddress(&magiclinkfive)
  177. patientMagiclinkfive, err := GetMacLinkAddressByLastData(userOrgID)
  178. EniviIDs := strconv.FormatInt(EnviID, 10)
  179. editmargin := models.SgjPatientEditmargin{
  180. Margtitle: "医院介绍",
  181. Margimage: "https://images.shengws.com/2162_o_1571992616722.png",
  182. UserOrgId: userOrgID,
  183. Status: 1,
  184. Ctime: time.Now().Unix(),
  185. Modeid: sgjpatietnmodelfour.ID,
  186. Jumpset: 1,
  187. //Marginaddress:"http://jk.test.sgjyun.com/#/hospitalIntroduction?id="+modeid+"&orgid="+orgid ,
  188. Linkid: patientMagiclink.ID,
  189. Marginaddress: "http://microweb.kuyicloud.com/#/hospitalIntroduction?id=" + modeid + "&orgid=" + orgid,
  190. }
  191. err = AddEditMargin(&editmargin)
  192. patientEditmargin := models.SgjPatientEditmargin{
  193. Margtitle: "医护团队",
  194. Margimage: "https://images.shengws.com/2121_o_1571992634289.png",
  195. UserOrgId: userOrgID,
  196. Status: 1,
  197. Ctime: time.Now().Unix(),
  198. Modeid: sgjpatietnmodelfour.ID,
  199. Jumpset: 1,
  200. //Marginaddress:"http://jk.test.sgjyun.com/#/medicalTeam?id="+OfficeID+"&orgid="+orgid,
  201. Marginaddress: "http://microweb.kuyicloud.com/#/medicalTeam?id=" + OfficeID + "&orgid=" + orgid,
  202. Linkid: patientMagiclinktwo.ID,
  203. }
  204. err = AddEditMargin(&patientEditmargin)
  205. sgjPatientEditmargin := models.SgjPatientEditmargin{
  206. Margtitle: "医院动态",
  207. Margimage: "https://images.shengws.com/2163_o_1571992676180.png",
  208. UserOrgId: userOrgID,
  209. Status: 1,
  210. Ctime: time.Now().Unix(),
  211. Modeid: sgjpatietnmodelfour.ID,
  212. Jumpset: 1,
  213. //Marginaddress:"http://jk.test.sgjyun.com/#/news?id="+ActisID+"&orgid="+orgid,
  214. Marginaddress: "http://microweb.kuyicloud.com/#/news?id=" + ActisID + "&orgid=" + orgid,
  215. Linkid: patientMagiclinkthree.ID,
  216. }
  217. AddEditMargin(&sgjPatientEditmargin)
  218. patienteditmarginfour := models.SgjPatientEditmargin{
  219. Margtitle: "医院活动",
  220. Margimage: "https://images.shengws.com/2117_o_1571992689392.png",
  221. UserOrgId: userOrgID,
  222. Status: 1,
  223. Ctime: time.Now().Unix(),
  224. Modeid: sgjpatietnmodelfour.ID,
  225. Jumpset: 1,
  226. //Marginaddress:"http://jk.test.sgjyun.com/#/activity?id="+ActivsID+"&orgid="+orgid,
  227. Marginaddress: "http://microweb.kuyicloud.com/#/activity?id=" + ActivsID + "&orgid=" + orgid,
  228. Linkid: patientMagiclinkfour.ID,
  229. }
  230. AddEditMargin(&patienteditmarginfour)
  231. patienteditmarginfive := models.SgjPatientEditmargin{
  232. Margtitle: "医院环境",
  233. Margimage: "https://images.shengws.com/2130_o_1571992702226.png",
  234. UserOrgId: userOrgID,
  235. Status: 1,
  236. Ctime: time.Now().Unix(),
  237. Modeid: sgjpatietnmodelfour.ID,
  238. Jumpset: 1,
  239. //Marginaddress:"http://jk.test.sgjyun.com/#/departmentEnvironment?id="+EniviIDs+"&orgid="+orgid,
  240. Marginaddress: "http://microweb.kuyicloud.com/#/departmentEnvironment?id=" + EniviIDs + "&orgid=" + orgid,
  241. Linkid: patientMagiclinkfive.ID,
  242. }
  243. AddEditMargin(&patienteditmarginfive)
  244. patienteditmarginsix := models.SgjPatientEditmargin{
  245. Margtitle: "咨询客服",
  246. Margimage: "https://images.shengws.com/2149_o_1571992721076.png",
  247. UserOrgId: userOrgID,
  248. Status: 1,
  249. Ctime: time.Now().Unix(),
  250. Modeid: sgjpatietnmodelfour.ID,
  251. Jumpset: 1,
  252. }
  253. AddEditMargin(&patienteditmarginsix)
  254. patienteditmarginserven := models.SgjPatientEditmargin{
  255. Margtitle: "加入会员",
  256. Margimage: "https://images.shengws.com/2165_o_1571992737567.png",
  257. UserOrgId: userOrgID,
  258. Status: 1,
  259. Ctime: time.Now().Unix(),
  260. Modeid: sgjpatietnmodelfour.ID,
  261. Jumpset: 1,
  262. }
  263. AddEditMargin(&patienteditmarginserven)
  264. patienteditmargineghit := models.SgjPatientEditmargin{
  265. Margtitle: "联系我们",
  266. Margimage: "https://images.shengws.com/2122_o_1571992753168.png",
  267. UserOrgId: userOrgID,
  268. Status: 1,
  269. Ctime: time.Now().Unix(),
  270. Modeid: sgjpatietnmodelfour.ID,
  271. }
  272. AddEditMargin(&patienteditmargineghit)
  273. patientModelTwo := models.SgjPatientModel{
  274. Title: "医院介绍",
  275. Sort: 4,
  276. UserOrgId: userOrgID,
  277. Ctime: time.Now().Unix(),
  278. Status: 1,
  279. ModeType: 2,
  280. }
  281. AddPatientModelTwo(&patientModelTwo)
  282. sgjPatientModelTwo, err := GetQueryModelByLastData(userOrgID)
  283. hospital := models.SgjPatientHospital{
  284. Title: "医院介绍",
  285. Sort: 4,
  286. Introduction: orgintroduction,
  287. UserOrgId: userOrgID,
  288. Modleid: sgjPatientModelTwo.ID,
  289. Status: 1,
  290. Ctime: time.Now().Unix(),
  291. }
  292. AddHospital(&hospital)
  293. Sgjpatientmodelthree := models.SgjPatientModel{
  294. Title: "科室介绍",
  295. Sort: 8,
  296. UserOrgId: userOrgID,
  297. Ctime: time.Now().Unix(),
  298. Status: 1,
  299. ModeType: 3,
  300. }
  301. AddPatientModelTwo(&Sgjpatientmodelthree)
  302. datathree, err := GetQueryModelByLastData(userOrgID)
  303. offices := models.SgjPatientOffices{
  304. Title: "科室介绍",
  305. Sort: 8,
  306. UserOrgId: userOrgID,
  307. Ctime: time.Now().Unix(),
  308. Status: 1,
  309. Modleid: datathree.ID,
  310. Introduction: "",
  311. }
  312. AddPatientOffices(&offices)
  313. patientModelFive := models.SgjPatientModel{
  314. Title: "医护团队",
  315. Sort: 5,
  316. UserOrgId: userOrgID,
  317. Ctime: time.Now().Unix(),
  318. Status: 1,
  319. ModeType: 4,
  320. }
  321. AddPatientModelTwo(&patientModelFive)
  322. data, err := GetQueryModelByLastData(userOrgID)
  323. editdoctor := models.SgjPatientEditdoctor{
  324. Dochead: "https://images.shengws.com/2062_o_1570608303729.png",
  325. DocSort: 1,
  326. Docintroduction: "",
  327. UserOrgId: userOrgID,
  328. Modleid: data.ID,
  329. Status: 1,
  330. Ctime: time.Now().Unix(),
  331. DocPostion: 1,
  332. }
  333. AddEditDoctor(&editdoctor)
  334. modelserven := models.SgjPatientModel{
  335. Title: "医院环境",
  336. Sort: 6,
  337. UserOrgId: userOrgID,
  338. Ctime: time.Now().Unix(),
  339. Status: 1,
  340. ModeType: 5,
  341. }
  342. AddPatientModelTwo(&modelserven)
  343. lastData, err := GetQueryModelByLastData(userOrgID)
  344. enviroimages := models.SgjPatientEnviroimages{
  345. Enviroimages: "https://images.shengws.com/2076_o_1572602899145.jpg",
  346. Sort: 1,
  347. UserOrgId: userOrgID,
  348. Status: 1,
  349. Modeid: lastData.ID,
  350. Ctime: time.Now().Unix(),
  351. }
  352. AddImages(&enviroimages)
  353. modelArticles := models.SgjPatientModel{
  354. Title: "医院动态",
  355. Sort: 3,
  356. UserOrgId: userOrgID,
  357. Ctime: time.Now().Unix(),
  358. Status: 1,
  359. ModeType: 6,
  360. }
  361. AddPatientModelTwo(&modelArticles)
  362. articleslist, err := GetQueryModelByLastData(userOrgID)
  363. fmt.Println("articleslist", articleslist)
  364. fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
  365. articlelist := models.SgjPatientArticlelist{
  366. Title: "医院动态",
  367. Sort: 3,
  368. UserOrgId: userOrgID,
  369. Status: 1,
  370. Ctime: time.Now().Unix(),
  371. Number: 1,
  372. Modeid: articleslist.ID,
  373. }
  374. AddActiclelist(&articlelist)
  375. fmt.Println("我爱你中国法阿发法阿凡达阿凡达阿道夫阿道夫阿道夫阿发阿凡达暗室逢灯阿斯蒂芬暗室逢灯")
  376. articles, err := GetAritclesData(userOrgID)
  377. if len(articles) == 0 {
  378. articles := models.Articles{
  379. Title: "",
  380. Content: "",
  381. Imgs: "https://images.shengws.com/2062_o_1570608303729.png",
  382. Status: 1,
  383. Ctime: time.Now().Unix(),
  384. UserOrgId: userOrgID,
  385. ArticleStatus: 1,
  386. }
  387. AddActicles(&articles)
  388. }
  389. modelActivitis := models.SgjPatientModel{
  390. Title: "医院活动",
  391. Sort: 7,
  392. UserOrgId: userOrgID,
  393. Ctime: time.Now().Unix(),
  394. Status: 1,
  395. ModeType: 7,
  396. }
  397. AddPatientModelTwo(&modelActivitis)
  398. activtiys, err := GetQueryModelByLastData(userOrgID)
  399. addactivity := models.SgjPatientAddactivity{
  400. Title: "医院活动",
  401. Sort: 7,
  402. UserOrgId: userOrgID,
  403. Ctime: time.Now().Unix(),
  404. Status: 1,
  405. Modeid: activtiys.ID,
  406. Number: 1,
  407. }
  408. AddActivity(&addactivity)
  409. activity, err := GetArititys(userOrgID)
  410. if len(activity) == 0 {
  411. activity := models.Activity{
  412. Title: "医院活动",
  413. PosterPhoto: "https://images.shengws.com/2062_o_1570608303729.png",
  414. UserOrgId: userOrgID,
  415. CreateTime: time.Now().Unix(),
  416. Status: 1,
  417. }
  418. AddActivitys(&activity)
  419. }
  420. }
  421. oldmodels, err := GetContactUsModel(userOrgID)
  422. fmt.Println("orgmodels是设么", oldmodels)
  423. if len(oldmodels) == 0 {
  424. ordmodel := models.PatientOrdmodel{
  425. Title: "轮播图",
  426. UserOrgId: userOrgID,
  427. Sort: 1,
  428. ModeType: 1,
  429. Status: 1,
  430. Ctime: time.Now().Unix(),
  431. }
  432. err := AddPatientOrdModel(&ordmodel)
  433. fmt.Println("错误是设么", err)
  434. patientOrdmodel, err := GetPatientOrdModelByLastData(userOrgID)
  435. conrotation := models.SgjPatientConrotation{
  436. Images: "https://images.shengws.com/2124_o_1570607834870.png",
  437. Sort: 1,
  438. Modeid: patientOrdmodel.ID,
  439. UserOrgId: userOrgID,
  440. Ctime: time.Now().Unix(),
  441. Status: 1,
  442. Piclink: 1,
  443. }
  444. AddConRotation(&conrotation)
  445. ordmodelOne := models.PatientOrdmodel{
  446. Title: "医院地址",
  447. UserOrgId: userOrgID,
  448. Sort: 2,
  449. ModeType: 2,
  450. Status: 1,
  451. Ctime: time.Now().Unix(),
  452. }
  453. AddPatientOrdModel(&ordmodelOne)
  454. patientOrdmodelOne, err := GetPatientOrdModelByLastData(userOrgID)
  455. hosaddress := models.SgjPatientHosaddress{
  456. Title: "医院地址",
  457. UserOrgId: userOrgID,
  458. Address: address,
  459. Ctime: time.Now().Unix(),
  460. Status: 1,
  461. Modeid: patientOrdmodelOne.ID,
  462. }
  463. AddHosAddress(&hosaddress)
  464. ordmodeltwo := models.PatientOrdmodel{
  465. Title: "联系方式",
  466. UserOrgId: userOrgID,
  467. Sort: 3,
  468. ModeType: 3,
  469. Status: 1,
  470. Ctime: time.Now().Unix(),
  471. }
  472. AddPatientOrdModel(&ordmodeltwo)
  473. patientOrdmodelTwo, err := GetPatientOrdModelByLastData(userOrgID)
  474. connectway := models.SgjPatientConnectway{
  475. Title: "联系方式",
  476. UserOrgId: userOrgID,
  477. Status: 1,
  478. Ctime: time.Now().Unix(),
  479. ModeId: patientOrdmodelTwo.ID,
  480. }
  481. AddConnecWay(&connectway)
  482. connection := models.SgjPatientConnection{
  483. Title: "电话",
  484. Connecway: 1,
  485. Content: telephone,
  486. Status: 1,
  487. UserOrgId: userOrgID,
  488. }
  489. AddConnetion(connection)
  490. ordmodelthree := models.PatientOrdmodel{
  491. Title: "工作时间",
  492. UserOrgId: userOrgID,
  493. Sort: 4,
  494. ModeType: 4,
  495. Status: 1,
  496. Ctime: time.Now().Unix(),
  497. }
  498. AddPatientOrdModel(&ordmodelthree)
  499. patientOrdmodelThree, err := GetPatientOrdModelByLastData(userOrgID)
  500. worktime := models.SgjPatientWorktime{
  501. Title: "工作时间",
  502. UserOrgId: userOrgID,
  503. Status: 1,
  504. Ctime: time.Now().Unix(),
  505. ModeId: patientOrdmodelThree.ID,
  506. Worktime: "暂无数据",
  507. }
  508. AddWorkTime(&worktime)
  509. ordmodelfour := models.PatientOrdmodel{
  510. Title: "乘车方式",
  511. UserOrgId: userOrgID,
  512. Sort: 5,
  513. ModeType: 5,
  514. Status: 1,
  515. Ctime: time.Now().Unix(),
  516. }
  517. AddPatientOrdModel(&ordmodelfour)
  518. patientOrdmodelfour, err := GetPatientOrdModelByLastData(userOrgID)
  519. rideway := models.SgjPatientRideway{
  520. Title: "乘车方式",
  521. UserOrgId: userOrgID,
  522. Status: 1,
  523. Ctime: time.Now().Unix(),
  524. ModeId: patientOrdmodelfour.ID,
  525. RideWay: "暂无数据",
  526. }
  527. AddRideWay(rideway)
  528. }
  529. }
  530. }
  531. func AddPatientModel(model *models.SgjPatientModel) error {
  532. err := service.PatientWriteDB().Create(&model).Error
  533. fmt.Println("插入错误", err)
  534. return err
  535. }
  536. func QueryModel(orgID int64) (models.SgjPatientModel, error) {
  537. model := models.SgjPatientModel{}
  538. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&model).Error
  539. return model, err
  540. }
  541. func UpdateEditpicLink(orgID int64, ids []int64, editpiclink models.SgjPatientEditpiclink) (err error) {
  542. if len(ids) == 1 {
  543. 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
  544. } else {
  545. 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
  546. }
  547. return
  548. }
  549. func AddRotation(rotation models.SgjPatientRotation) error {
  550. err := service.PatientWriteDB().Create(&rotation).Error
  551. fmt.Println("插入数据", err)
  552. return err
  553. }
  554. func GetRotationByLastData(orgid int64) (models.SgjPatientRotation, error) {
  555. rotation := models.SgjPatientRotation{}
  556. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&rotation).Error
  557. return rotation, err
  558. }
  559. func AddRotationUpload(connecmodel *models.SgjPatientConnecmodel) error {
  560. err := service.PatientWriteDB().Create(&connecmodel).Error
  561. fmt.Println("错误是什么,err", err)
  562. return err
  563. }
  564. func AddHispital(newmodel models.SgjPatientHospital) error {
  565. err := service.PatientWriteDB().Create(&newmodel).Error
  566. return err
  567. }
  568. func AddOffices(offices models.SgjPatientOffices) error {
  569. err := service.PatientWriteDB().Create(&offices).Error
  570. return err
  571. }
  572. func AddDoctor(doctor models.SgjPatientDocinfo) error {
  573. err := service.PatientWriteDB().Create(&doctor).Error
  574. return err
  575. }
  576. func AddDoctorInfo(doctor models.SgjPatientEditdoctor) error {
  577. err := service.PatientWriteDB().Create(&doctor).Error
  578. return err
  579. }
  580. func AddImages(enviroimages *models.SgjPatientEnviroimages) error {
  581. err := service.PatientWriteDB().Create(&enviroimages).Error
  582. return err
  583. }
  584. func AddOffEnvironment(officenviroment models.SgjPatientOffenvironment) error {
  585. err := service.PatientWriteDB().Create(&officenviroment).Error
  586. return err
  587. }
  588. func GetRationImages(orgID int64) (rot []*models.SgjPatientRotation, err error) {
  589. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Order("sort").Find(&rot).Error
  590. fmt.Println("错误是什么", err)
  591. return
  592. }
  593. func GetHospitalInfo(orgID int64) (models.SgjPatientHospital, error) {
  594. hospital := models.SgjPatientHospital{}
  595. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&hospital).Error
  596. fmt.Println("错误是什么", err)
  597. return hospital, err
  598. }
  599. func GetOfficeInfo(orgID int64) (models.SgjPatientOffices, error) {
  600. offices := models.SgjPatientOffices{}
  601. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offices).Error
  602. fmt.Println("错误是什么", err)
  603. return offices, err
  604. }
  605. func GetQueryDocInfo(orgID int64) (doc []*models.SgjUserStaffInfo, err error) {
  606. err = service.UserReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&doc).Error
  607. fmt.Println("错误是什么", err)
  608. return
  609. }
  610. func GetQueryDocHead(orgID int64) (doc []*models.SgjPatientEditdoctor, err error) {
  611. err = service.PatientReadDB().Where("user_org_id = ? AND status = ? AND img_show = ?", orgID, 1, 1).Order("doc_sort").Find(&doc).Error
  612. return
  613. }
  614. func GetOffEnvironment(orgID int64) (models.SgjPatientOffenvironment, error) {
  615. offenvironment := models.SgjPatientOffenvironment{}
  616. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offenvironment).Error
  617. fmt.Println("错误是什么", err)
  618. return offenvironment, err
  619. }
  620. func AddWorkTime(connecmodel *models.SgjPatientWorktime) error {
  621. err := service.PatientWriteDB().Create(&connecmodel).Error
  622. return err
  623. }
  624. func AddRideWay(connecmodel models.SgjPatientRideway) error {
  625. err := service.PatientWriteDB().Create(&connecmodel).Error
  626. return err
  627. }
  628. func AddConnetion(connection models.SgjPatientConnection) error {
  629. err := service.PatientWriteDB().Create(&connection).Error
  630. return err
  631. }
  632. func GetQueryConnection(orgID int64) (conection []*models.SgjPatientConnection, err error) {
  633. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&conection).Error
  634. return
  635. }
  636. func DeleteRideWay(orgid int64, id int64) error {
  637. 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
  638. return err
  639. }
  640. func DeleteConnecWay(orgid int64, id int64) error {
  641. 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
  642. return err
  643. }
  644. func DeleteWorkTime(orgid int64, id int64) error {
  645. 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
  646. return err
  647. }
  648. func EditConnecWay(orgid int64, id int64) (models.SgjPatientConnection, error) {
  649. sgj := models.SgjPatientConnection{}
  650. err := service.PatientReadDB().Model(&sgj).Where("user_org_id = ? AND id =?", orgid, id).Find(&sgj).Error
  651. return sgj, err
  652. }
  653. func UpadateConnec(connection *models.SgjPatientConnection, orgID int64, id int64) {
  654. 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})
  655. }
  656. func GetUserModel(orgid int64) (model []*models.SgjPatientOrdmodel, err error) {
  657. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error
  658. return
  659. }
  660. func GetQueryNewModel(orgid int64) (model []*models.SgjPatientModel, err error) {
  661. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error
  662. fmt.Println("错误是什么", err)
  663. return
  664. }
  665. func GetEditModel(orgid int64, id int64) (models.SgjPatientWorktime, error) {
  666. worktime := models.SgjPatientWorktime{}
  667. err := service.PatientReadDB().Model(&worktime).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&worktime).Error
  668. return worktime, err
  669. }
  670. func GetEditRideWay(orgid int64, id int64) (models.SgjPatientRideway, error) {
  671. rideway := models.SgjPatientRideway{}
  672. err := service.PatientReadDB().Model(&rideway).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&rideway).Error
  673. return rideway, err
  674. }
  675. func UpdateWorkTime(mid int64, orgID int64, worktime models.SgjPatientWorktime) error {
  676. 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
  677. return err
  678. }
  679. func UpdateOrdeModel(id int64, orgID int64, ordmodel models.SgjPatientOrdmodel) error {
  680. 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
  681. return err
  682. }
  683. func UpdateRideWay(id int64, orgID int64, rideway models.SgjPatientRideway) error {
  684. 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, "ride_way": rideway.RideWay, "mtime": time.Now().Unix()}).Error
  685. return err
  686. }
  687. func QueryDocById(orgID int64, id int64) (models.SgjUserStaffInfo, error) {
  688. info := models.SgjUserStaffInfo{}
  689. err := service.UserWriteDB().Model(&info).Where("user_org_id = ? AND id = ?", orgID, id).Find(&info).Error
  690. return info, err
  691. }
  692. func DeleteDoctor(id int64, orgID int64) error {
  693. err := service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "img_show": 0, "modleid": 0, "mtime": time.Now().Unix()}).Error
  694. return err
  695. }
  696. func EditHospital(mid int64, orgID int64) (models.SgjPatientHospital, error) {
  697. hospital := models.SgjPatientHospital{}
  698. err := service.PatientReadDB().Model(&hospital).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Find(&hospital).Error
  699. return hospital, err
  700. }
  701. func UpdateHospital(id int64, OrgId int64, hospital models.SgjPatientHospital) error {
  702. 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
  703. return err
  704. }
  705. func UpdateModel(modelid int64, orgId int64, model models.SgjPatientModel) error {
  706. 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
  707. return err
  708. }
  709. func EditOffice(mid int64, orgID int64) (models.SgjPatientOffices, error) {
  710. offices := models.SgjPatientOffices{}
  711. err := service.PatientReadDB().Model(&offices).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Find(&offices).Error
  712. return offices, err
  713. }
  714. func DeletemodleById(id int64, orgID int64) error {
  715. 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
  716. return err
  717. }
  718. func DeleteHospitalByModelid(mid int64, orgID int64) error {
  719. 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
  720. return err
  721. }
  722. func DeleteOfficeByModelid(mid int64, orgID int64) error {
  723. 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
  724. return err
  725. }
  726. func DeleteEditPicLinkByModelid(mid int64, orgID int64) error {
  727. 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
  728. return err
  729. }
  730. func DeleteEnviroments(mid int64, orgID int64) error {
  731. 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
  732. return err
  733. }
  734. func DeleteConrotation(mid int64, orgID int64) error {
  735. 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
  736. return err
  737. }
  738. func DeletePatentEditMargin(mid int64, orgID int64) error {
  739. err := service.PatientWriteDB().Model(models.SgjPatientEditmargin{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "img_show": 0, "mtime": time.Now().Unix()}).Error
  740. return err
  741. }
  742. func UpdateOffices(id int64, orgID int64, offices models.SgjPatientOffices) error {
  743. 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
  744. return err
  745. }
  746. func GetHospital(Orgid int64) (hostital []*models.SgjPatientHospital, err error) {
  747. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", Orgid, 1).Order("sort").Find(&hostital).Error
  748. return
  749. }
  750. func GetData(orgid int64) (model []*models.SgjPatientModel, err error) {
  751. db := service.PatientReadDB().Table("sgj_patient_model as m").Where(" m.status = ?", 1)
  752. dbs := service.PatientReadDB().Table("sgj_patient_editpiclink as s")
  753. fmt.Println("db是什么?", db)
  754. if orgid > 0 {
  755. db = db.Where("user_org_id = ? ", orgid)
  756. }
  757. err = db.Preload("Hospitals").Preload("Offices").Preload("OfficeEnviroment").
  758. Preload("Editdoctor").Preload("Editmargin").Preload("Enviroimages").Preload("PatientEditpiclink", func(db *gorm.DB) *gorm.DB {
  759. return dbs.Select("s.id,s.images,s.sort,s.piclink,s.linkaddress,s.user_org_id,s.status,s.ctime,s.mtime,s.modeid,s.img_show,s.linkid").Order("sort")
  760. }).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
  761. fmt.Println("err二二err二二err二二err二二err二二err", err)
  762. return
  763. }
  764. func GetPatientNavigation(orgid int64) (navigation []*models.SgjPatientNavigation, err error) {
  765. err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
  766. return navigation, err
  767. }
  768. func AddNavgation(navigation *models.SgjPatientNavigation) error {
  769. err := service.PatientReadDB().Create(&navigation).Error
  770. return err
  771. }
  772. func UpdateDoctorsInfo(orgID int64, ids []int64, editdoctor models.SgjPatientEditdoctor) (err error) {
  773. if len(ids) == 1 {
  774. err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? and user_org_id = ?", ids[0], orgID).Update(map[string]interface{}{"modleid": editdoctor.Modleid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error
  775. } else {
  776. err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id IN(?) and user_org_id = ?", ids, orgID).Update(map[string]interface{}{"modleid": editdoctor.Modleid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error
  777. }
  778. return
  779. }
  780. func QueryEditDoc(mid int64, orgid int64) (models.SgjPatientDocinfo, error) {
  781. editdotor := models.SgjPatientDocinfo{}
  782. err := service.PatientReadDB().Model(&editdotor).Where("modelid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdotor).Error
  783. return editdotor, err
  784. }
  785. func QueryModelByid(id int64, orgid int64) (models.SgjPatientModel, error) {
  786. model := models.SgjPatientModel{}
  787. err := service.PatientReadDB().Model(&model).Where("id = ? AND user_org_id = ? AND status =?", id, orgid, 1).Find(&model).Error
  788. return model, err
  789. }
  790. func QuerEditDocByModleid(mid int64, orgid int64) (editdoctor []models.SgjPatientEditdoctor, err error) {
  791. err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdoctor).Error
  792. return editdoctor, err
  793. }
  794. func QuerEditDocByid(mid int64, orgid int64) (editdoctor []*models.SgjPatientEditdoctor, err error) {
  795. err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("doc_sort").Find(&editdoctor).Error
  796. return
  797. }
  798. func QueryEditImages(orgid int64, id int64) (models.SgjPatientEditdoctor, error) {
  799. editdoctor := models.SgjPatientEditdoctor{}
  800. err := service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editdoctor).Error
  801. return editdoctor, err
  802. }
  803. func QueryEditDoctor(id int64, orgid int64) (models.SgjPatientEditdoctor, error) {
  804. docinfo := models.SgjPatientEditdoctor{}
  805. err := service.PatientReadDB().Model(&docinfo).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&docinfo).Error
  806. return docinfo, err
  807. }
  808. func UpDateEditdoctor(id int64, orgid int64, editdoctor models.SgjPatientEditdoctor) error {
  809. 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
  810. return err
  811. }
  812. func Upadatedocdata(orgid int64, id int64, docinfo models.SgjPatientDocinfo) error {
  813. 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
  814. return err
  815. }
  816. func GetQueryModel(id, orgid int64) (models.SgjPatientModel, error) {
  817. model := models.SgjPatientModel{}
  818. err := service.PatientReadDB().Model(&model).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&model).Error
  819. return model, err
  820. }
  821. func QuerOfficeEnviroment(id int64, orgid int64) (models.SgjPatientOffenvironment, error) {
  822. offenvironment := models.SgjPatientOffenvironment{}
  823. err := service.PatientReadDB().Model(&offenvironment).Where("modelid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  824. return offenvironment, err
  825. }
  826. func QueryOfficeformById(modeid int64, orgid int64) (patientenviroimages []*models.SgjPatientEnviroimages, err error) {
  827. err = service.PatientReadDB().Model(&patientenviroimages).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&patientenviroimages).Error
  828. return
  829. }
  830. func UpdateOfficeEnvironment(id int64, orgid int64) (models.SgjPatientOffenvironment, error) {
  831. offenvironment := models.SgjPatientOffenvironment{}
  832. err := service.PatientReadDB().Model(&offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  833. return offenvironment, err
  834. }
  835. func UpdatePatientOffenvironment(id int64, orgid int64, offenvironment models.SgjPatientOffenvironment) error {
  836. 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
  837. return err
  838. }
  839. func QueryHispitalDetail(orgid int64, id int64) (models.SgjPatientHospital, error) {
  840. hospital := models.SgjPatientHospital{}
  841. err := service.PatientReadDB().Model(&hospital).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&hospital).Error
  842. return hospital, err
  843. }
  844. func GetOfficeDetail(orgid int64, id int64) (models.SgjPatientOffices, error) {
  845. offices := models.SgjPatientOffices{}
  846. err := service.PatientReadDB().Model(&offices).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&offices).Error
  847. return offices, err
  848. }
  849. func GetDoctorDetail(orgid int64, id int64) (editdoctor []*models.SgjPatientEditdoctor, err error) {
  850. err = service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Order("doc_sort").Find(&editdoctor).Error
  851. return
  852. }
  853. func GetOfficEnviromentDetail(orgid int64, id int64) (offenvironment []models.SgjPatientEnviroimages, err error) {
  854. err = service.PatientReadDB().Model(&offenvironment).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, id, 1).Order("sort").Find(&offenvironment).Error
  855. return offenvironment, err
  856. }
  857. func AddNavigation(navigation *models.SgjPatientNavigation) error {
  858. err := service.PatientWriteDB().Create(&navigation).Error
  859. return err
  860. }
  861. func GetNavigationList(orgid int64) (navigation []*models.SgjPatientNavigation, err error) {
  862. err = service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
  863. return
  864. }
  865. func AddShareInfo(share *models.SgjPatientShare) error {
  866. err := service.PatientWriteDB().Create(&share).Error
  867. return err
  868. }
  869. func GetShareInfo(orgid int64) (models.SgjPatientShare, error) {
  870. share := models.SgjPatientShare{}
  871. err := service.PatientReadDB().Model(&share).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&share).Error
  872. return share, err
  873. }
  874. func DeleteNavitionById(orgID int64, id int64) error {
  875. 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
  876. return err
  877. }
  878. func AddConnecWay(connectway *models.SgjPatientConnectway) error {
  879. err := service.PatientWriteDB().Create(&connectway).Error
  880. return err
  881. }
  882. func AddOrdModel(ordmodel *models.SgjPatientOrdmodel) error {
  883. err := service.PatientWriteDB().Create(&ordmodel).Error
  884. return err
  885. }
  886. func AddPatientOrdModel(ordmodel *models.PatientOrdmodel) error {
  887. err := service.PatientWriteDB().Create(&ordmodel).Error
  888. return err
  889. }
  890. func AddHosAddress(hosaddress *models.SgjPatientHosaddress) error {
  891. err := service.PatientWriteDB().Create(&hosaddress).Error
  892. return err
  893. }
  894. func QueryOrdeModelByID(orgid int64) (models.SgjPatientOrdmodel, error) {
  895. ordmodel := models.SgjPatientOrdmodel{}
  896. err := service.PatientReadDB().Where("user_org_id = ? AND status = ? ", orgid, 1).Last(&ordmodel).Error
  897. return ordmodel, err
  898. }
  899. func UpdateConrotaions(orgid int64, ids []int64, conrotation models.SgjPatientConrotation) (err error) {
  900. if len(ids) == 1 {
  901. 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
  902. } else {
  903. 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
  904. }
  905. return
  906. }
  907. func DeleteModle(orgid int64, id int64) error {
  908. 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
  909. return err
  910. }
  911. func DeleteModleByModeID(orgid int64, mid int64) error {
  912. 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
  913. return err
  914. }
  915. func GetOrederModel(orgid int64) (model []*models.SgjPatientOrdmodel, err error) {
  916. db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1)
  917. con := service.PatientReadDB().Table("sgj_patient_conrotation as s")
  918. if orgid > 0 {
  919. db = db.Where("user_org_id = ?", orgid)
  920. }
  921. err = db.Preload("Hosaddress").Preload("Connectway").Preload("Worktime").Preload("Rideway").Preload("Oldration").Preload("Conrotation", func(db *gorm.DB) *gorm.DB {
  922. return con.Select("s.id,s.images,s.sort,s.piclink,s.linkaddress,s.user_org_id,s.status,s.ctime,s.mtime,s.modeid,s.img_show,s.linkid").Order("sort")
  923. }).Select("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error
  924. fmt.Println("sql错误是什么", err)
  925. return
  926. }
  927. func AddRotationpic(conrotation models.SgjPatientConrotation) error {
  928. err := service.PatientWriteDB().Create(&conrotation).Error
  929. return err
  930. }
  931. func GetRotationImages(orgid int64) (conrotation []models.SgjPatientConrotation, err error) {
  932. err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1, 1).Order("sort").Find(&conrotation).Error
  933. return conrotation, err
  934. }
  935. func AddrotationImage(oldrotation *models.SgjPatientOldrotation) error {
  936. err := service.PatientWriteDB().Create(&oldrotation).Error
  937. return err
  938. }
  939. func UpdateConrotation(orgid int64, ids []int64, conrotation models.SgjPatientConrotation) (err error) {
  940. if len(ids) == 1 {
  941. 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
  942. } else {
  943. 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
  944. }
  945. return
  946. }
  947. func AddImageslink(editpiclink *models.SgjPatientEditpiclink) error {
  948. err := service.PatientWriteDB().Create(&editpiclink).Error
  949. return err
  950. }
  951. func GetEnImages(orgid int64) (enviroimages []models.SgjPatientEnviroimages, err error) {
  952. err = service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND status = ? AND imgshow = ? ", orgid, 1, 1).Order("sort").Find(&enviroimages).Error
  953. return enviroimages, err
  954. }
  955. func UpdateImages(orgid int64, ids []int64, enviroimages models.SgjPatientEnviroimages) (err error) {
  956. if len(ids) == 1 {
  957. 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
  958. } else {
  959. 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
  960. }
  961. return
  962. }
  963. func GetEditEnvirimagesById(orgid int64, id int64) (models.SgjPatientEnviroimages, error) {
  964. enviroimages := models.SgjPatientEnviroimages{}
  965. err := service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND id =? AND status = ?", orgid, id, 1).Find(&enviroimages).Error
  966. return enviroimages, err
  967. }
  968. func UpdateEnviroimages(id int64, orgid int64, enviroimages models.SgjPatientEnviroimages) (err error) {
  969. 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
  970. return err
  971. }
  972. func GetEditImages(orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) {
  973. err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1, 1).Order("sort").Find(&editpiclink).Error
  974. return editpiclink, err
  975. }
  976. func AddMagicNavi(editmargin *models.SgjPatientEditmargin) error {
  977. err := service.PatientWriteDB().Create(&editmargin).Error
  978. return err
  979. }
  980. func GetMagicImages(orgid int64) (editmargin []models.SgjPatientEditmargin, err error) {
  981. err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1, 1).Find(&editmargin).Error
  982. return editmargin, err
  983. }
  984. func AddMarginChart(macnavigation *models.SgjPatientMacnavigation) error {
  985. err := service.PatientWriteDB().Create(&macnavigation).Error
  986. return err
  987. }
  988. func DeleteRotations(id int64, orgid int64) error {
  989. 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
  990. return err
  991. }
  992. func UpdateRotationImages(orgid int64, id int64) (models.SgjPatientEditpiclink, error) {
  993. editpiclink := models.SgjPatientEditpiclink{}
  994. err := service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editpiclink).Error
  995. return editpiclink, err
  996. }
  997. func SaveRotationImages(id int64, orgid int64, editpiclink models.SgjPatientEditpiclink) error {
  998. 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
  999. return err
  1000. }
  1001. func EditNavigation(orgid int64, id int64) (models.SgjPatientNavigation, error) {
  1002. navigation := models.SgjPatientNavigation{}
  1003. err := service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&navigation).Error
  1004. return navigation, err
  1005. }
  1006. func UpdateNavtion(id int64, orgid int64, navigation models.SgjPatientNavigation) error {
  1007. 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, "nonavimages": navigation.Nonavimages, "jumpset": navigation.Jumpset, "navaddress": navigation.Navaddress, "linkid": navigation.Linkid, "linktype": navigation.Linktype, "mtime": time.Now().Unix()}).Error
  1008. return err
  1009. }
  1010. func DeleteImages(id int64, orgid int64) error {
  1011. 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
  1012. return err
  1013. }
  1014. func DeleteSingleImages(id int64, orgid int64) error {
  1015. 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
  1016. return err
  1017. }
  1018. func AddActivity(addactivity *models.SgjPatientAddactivity) error {
  1019. err := service.PatientWriteDB().Create(&addactivity).Error
  1020. return err
  1021. }
  1022. func QueryActivity(id int64, orgid int64) (models.SgjPatientAddactivity, error) {
  1023. addactivity := models.SgjPatientAddactivity{}
  1024. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&addactivity).Error
  1025. return addactivity, err
  1026. }
  1027. func UpdateActivit(id int64, orgid int64, addactivity models.SgjPatientAddactivity) error {
  1028. 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
  1029. return err
  1030. }
  1031. func DeleteMargin(id int64, orgid int64) error {
  1032. 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
  1033. return err
  1034. }
  1035. func GetEditRotationImages(id int64, orgid int64) (models.SgjPatientOrdmodel, error) {
  1036. oldrotation := models.SgjPatientOrdmodel{}
  1037. err := service.PatientReadDB().Model(oldrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&oldrotation).Error
  1038. return oldrotation, err
  1039. }
  1040. func GetEditConrotion(id int64, orgid int64) (conrotation []models.SgjPatientConrotation, err error) {
  1041. err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&conrotation).Error
  1042. return conrotation, err
  1043. }
  1044. func EditVisibleById(id int64, orgid int64) (models.SgjPatientConrotation, error) {
  1045. conrotation := models.SgjPatientConrotation{}
  1046. err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error
  1047. return conrotation, err
  1048. }
  1049. func UpdatedConAddress(id int64, orgid int64) (models.SgjPatientConlinkaddress, error) {
  1050. conlinkaddress := models.SgjPatientConlinkaddress{}
  1051. err := service.PatientWriteDB().Model(&conlinkaddress).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"defineaddress": ""}).Error
  1052. return conlinkaddress, err
  1053. }
  1054. func UpdateEditpic(id int64, orgid int64, conrotation models.SgjPatientConrotation) error {
  1055. 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, "linkid": conrotation.Linkid}).Error
  1056. return err
  1057. }
  1058. func GetPatientConrotationLast(orgid int64) (models.SgjPatientConrotation, error) {
  1059. conrotation := models.SgjPatientConrotation{}
  1060. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conrotation).Error
  1061. return conrotation, err
  1062. }
  1063. func UpdateConLinkAddress(orgid int64, conid int64, conlinkaddress models.SgjPatientConlinkaddress) error {
  1064. err := service.PatientWriteDB().Model(&conlinkaddress).Where("user_org_id = ? and status = ? and con_id = ?", orgid, 1, conid).Update(map[string]interface{}{"mtime": time.Now().Unix()}).Error
  1065. return err
  1066. }
  1067. func AddEditpic(conrotation *models.SgjPatientConrotation) error {
  1068. err := service.PatientWriteDB().Create(&conrotation).Error
  1069. return err
  1070. }
  1071. func QueryOldrotion(id int64, orgid int64) (models.SgjPatientOldrotation, error) {
  1072. conrotation := models.SgjPatientOldrotation{}
  1073. err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ? ", id, orgid).Order("sort").Find(&conrotation).Error
  1074. return conrotation, err
  1075. }
  1076. func QueryConRotation(mid int64, orgid int64) (conrotation []models.SgjPatientConrotation, err error) {
  1077. err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("sort").Find(&conrotation).Error
  1078. return conrotation, err
  1079. }
  1080. func UpdateConrotaionById(id int64, orgid int64, oldrotation models.SgjPatientOldrotation) error {
  1081. 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
  1082. return err
  1083. }
  1084. func GetPatientRotaion(id int64, orgid int64) (models.SgjPatientRotation, error) {
  1085. rotation := models.SgjPatientRotation{}
  1086. err := service.PatientReadDB().Model(&rotation).Where("model_id = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&rotation).Error
  1087. return rotation, err
  1088. }
  1089. func GetPatientModel(id int64, orgid int64) (models.SgjPatientModel, error) {
  1090. model := models.SgjPatientModel{}
  1091. err := service.PatientReadDB().Model(&model).Where("id = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&model).Error
  1092. return model, err
  1093. }
  1094. func GetPatientRotationById(id int64, orgid int64) (models.SgjPatientRotation, error) {
  1095. rotation := models.SgjPatientRotation{}
  1096. err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id =?", id, orgid).Find(&rotation).Error
  1097. return rotation, err
  1098. }
  1099. func QueryEditpiclink(id int64, orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) {
  1100. err = service.PatientReadDB().Model(editpiclink).Where("modeid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Order("sort").Find(&editpiclink).Error
  1101. return editpiclink, err
  1102. }
  1103. func GetEditSingleVisible(id int64, orgid int64) (models.SgjPatientEditpiclink, error) {
  1104. editpiclink := models.SgjPatientEditpiclink{}
  1105. err := service.PatientReadDB().Model(&editpiclink).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error
  1106. return editpiclink, err
  1107. }
  1108. func GetQueryEditpiclink(modeid int64, orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) {
  1109. err = service.PatientReadDB().Model(&editpiclink).Where("modeid=? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Order("sort").Find(&editpiclink).Error
  1110. return editpiclink, err
  1111. }
  1112. func UpdatedPatientLinkAddress(id int64, orgid int64) (models.SgjPatientLinkaddress, error) {
  1113. linkaddress := models.SgjPatientLinkaddress{}
  1114. err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"defineaddress": "", "status": 0}).Error
  1115. return linkaddress, err
  1116. }
  1117. func UpdateEditPatPicLink(id int64, orgid int64, editpiclink models.SgjPatientEditpiclink) error {
  1118. 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, "linkid": editpiclink.Linkid, "mtime": time.Now().Unix()}).Error
  1119. return err
  1120. }
  1121. func UpdateEditPicLinkTwo(moid int64, orgid int64) error {
  1122. err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("modeid = ? AND user_org_id = ? AND status = ?", moid, orgid, 1).Update(map[string]interface{}{"img_show": 0}).Error
  1123. return err
  1124. }
  1125. func GetPatientRotations(id int64, orgid int64) (models.SgjPatientRotation, error) {
  1126. rotation := models.SgjPatientRotation{}
  1127. err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&rotation).Error
  1128. return rotation, err
  1129. }
  1130. func UpdateRotationByid(id int64, orgid int64, rotation models.SgjPatientRotation) error {
  1131. 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
  1132. return err
  1133. }
  1134. func UpdateModelById(id int64, orgid int64, model models.SgjPatientModel) error {
  1135. 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
  1136. return err
  1137. }
  1138. func QuerEditMarginById(id int64, orgid int64) (models.SgjPatientEditmargin, error) {
  1139. editmargin := models.SgjPatientEditmargin{}
  1140. err := service.PatientReadDB().Model(editmargin).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Find(&editmargin).Error
  1141. return editmargin, err
  1142. }
  1143. func UpdateMarginById(id int64, orgid int64, editmargin models.SgjPatientEditmargin) error {
  1144. 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
  1145. return err
  1146. }
  1147. func GetActivitiesById(orgid int64) (models.SgjPatientAddactivity, error) {
  1148. addactivity := models.SgjPatientAddactivity{}
  1149. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error
  1150. fmt.Println("查询活动列表错误", err)
  1151. return addactivity, err
  1152. }
  1153. func GetAllActivities(orgid int64, limit int64) (activity []models.Activity, err error) {
  1154. err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Limit(limit).Find(&activity).Error
  1155. return
  1156. }
  1157. func GetArticleType(orgid int64) (category []models.ArticleCategory, err error) {
  1158. err = service.PatientReadDB().Model(category).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&category).Error
  1159. return category, err
  1160. }
  1161. func AddActiclelist(articlelist *models.SgjPatientArticlelist) error {
  1162. err := service.PatientWriteDB().Model(articlelist).Create(&articlelist).Error
  1163. return err
  1164. }
  1165. func GetArticlelist(orgid int64) (models.SgjPatientArticlelist, error) {
  1166. articlelist := models.SgjPatientArticlelist{}
  1167. err := service.PatientReadDB().Where("user_org_id = ? AND Status = ?", orgid, 1).Last(&articlelist).Error
  1168. fmt.Println("错误", err)
  1169. return articlelist, err
  1170. }
  1171. func GetAllArticles(orgid int64, limit int64) (articlelist []models.Articles, err error) {
  1172. err = service.PatientReadDB().Model(articlelist).Where("user_org_id = ? AND Status = ? AND article_status = ?", orgid, 1, 1).Order("ctime desc").Limit(limit).Find(&articlelist).Error
  1173. return
  1174. }
  1175. func GetArticlelistById(modeid int64, orgID int64) (models.SgjPatientArticlelist, error) {
  1176. articlelist := models.SgjPatientArticlelist{}
  1177. err := service.PatientReadDB().Model(articlelist).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&articlelist).Error
  1178. return articlelist, err
  1179. }
  1180. func GetAllActivitiById(modeid int64, orgID int64) (models.SgjPatientAddactivity, error) {
  1181. addactivity := models.SgjPatientAddactivity{}
  1182. err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&addactivity).Error
  1183. return addactivity, err
  1184. }
  1185. func UpdateArticeDetail(id int64, orgid int64, articlelist models.SgjPatientArticlelist) error {
  1186. 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
  1187. return err
  1188. }
  1189. func GetMacImagesByModeid(modeid int64, orgid int64) (macnavigation []models.SgjPatientEditmargin, err error) {
  1190. err = service.PatientReadDB().Model(macnavigation).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&macnavigation).Error
  1191. return macnavigation, err
  1192. }
  1193. func GetModelById(id int64, orgid int64) (models.SgjPatientModel, error) {
  1194. model := models.SgjPatientModel{}
  1195. err := service.PatientReadDB().Model(model).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&model).Error
  1196. return model, err
  1197. }
  1198. func GetOffENvironmentById(id int64, orgid int64) (models.SgjPatientOffenvironment, error) {
  1199. offenvironment := models.SgjPatientOffenvironment{}
  1200. err := service.PatientReadDB().Model(offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
  1201. return offenvironment, err
  1202. }
  1203. func AddOfficeThree(enviroimages *models.SgjPatientEnviroimages) error {
  1204. err := service.PatientWriteDB().Model(&enviroimages).Create(&enviroimages).Error
  1205. return err
  1206. }
  1207. func GetQueryImages(mid int64, orgid int64) (enviroimages []models.SgjPatientEnviroimages, err error) {
  1208. err = service.PatientReadDB().Model(enviroimages).Where("modeid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("sort").Find(&enviroimages).Error
  1209. return enviroimages, err
  1210. }
  1211. func GetOfficeTwoVisible(orgid int64, id int64) (models.SgjPatientEnviroimages, error) {
  1212. enviroimages := models.SgjPatientEnviroimages{}
  1213. err := service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&enviroimages).Error
  1214. return enviroimages, err
  1215. }
  1216. func UpdateOfficeTwo(orgid int64, id int64, enviroimages models.SgjPatientEnviroimages) error {
  1217. 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
  1218. return err
  1219. }
  1220. func GetQueryEnviroimage(orgid int64, mid int64) (enviroimages []models.SgjPatientEnviroimages, err error) {
  1221. err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, mid, 1).Find(&enviroimages).Error
  1222. return enviroimages, err
  1223. }
  1224. func DeleteOfficeById(id int64, orgid int64) error {
  1225. 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
  1226. return err
  1227. }
  1228. func GetArticleById(classid int64, orgid int64) (articlelist []models.Articles, err error) {
  1229. err = service.PatientReadDB().Model(models.Articles{}).Where("class_id = ? AND user_org_id = ? AND status = ?", classid, orgid, 1).Find(&articlelist).Error
  1230. return
  1231. }
  1232. func GetAllActivity(orgid int64) (activtity []models.Activity, err error) {
  1233. err = service.PatientReadDB().Model(models.Activity{}).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&activtity).Error
  1234. return
  1235. }
  1236. //func AddLinkAddress(linkaddress *models.SgjPatientLinkaddress) error {
  1237. // err := service.PatientWriteDB().Create(&linkaddress).Error
  1238. // return err
  1239. //}
  1240. func AddLinkAddress(linkaddress *models.SgjPatientLinkaddress) error {
  1241. err := service.PatientWriteDB().Create(&linkaddress).Error
  1242. return err
  1243. }
  1244. func GetLinkAddress(orgid int64, id int64) (models.SgjPatientLinkaddress, error) {
  1245. linkaddress := models.SgjPatientLinkaddress{}
  1246. err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND id = ? AND status = ? ", orgid, id, 1).Find(&linkaddress).Error
  1247. return linkaddress, err
  1248. }
  1249. func QuerylinkAddress(id int64, orgid int64) (models.SgjPatientLinkaddress, error) {
  1250. linkaddress := models.SgjPatientLinkaddress{}
  1251. err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&linkaddress).Error
  1252. return linkaddress, err
  1253. }
  1254. func GetAllConnecway(orgid int64) (connect []models.SgjPatientConnection, err error) {
  1255. err = service.PatientReadDB().Model(&connect).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&connect).Error
  1256. return
  1257. }
  1258. func GetConnecway(orgid int64, id int64) (models.SgjPatientOrdmodel, error) {
  1259. ordmodel := models.SgjPatientOrdmodel{}
  1260. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND status = ? AND id = ?", orgid, 1, id).Find(&ordmodel).Error
  1261. return ordmodel, err
  1262. }
  1263. func GetConnecwayById(orgid int64, id int64) (models.SgjPatientConnection, error) {
  1264. connection := models.SgjPatientConnection{}
  1265. err := service.PatientReadDB().Model(&connection).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&connection).Error
  1266. return connection, err
  1267. }
  1268. func UpdateConnectway(id int64, orgid int64, connection models.SgjPatientConnection) error {
  1269. 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
  1270. return err
  1271. }
  1272. func AddConnectways(connection *models.SgjPatientConnection) error {
  1273. err := service.PatientWriteDB().Create(&connection).Error
  1274. return err
  1275. }
  1276. func UpdateConnectways(id int64, orgid int64, connectway models.SgjPatientConnectway) error {
  1277. 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
  1278. return err
  1279. }
  1280. func GetHostpitalIntroduction(orgid int64, id int64) (models.SgjPatientOrdmodel, error) {
  1281. ordmodel := models.SgjPatientOrdmodel{}
  1282. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&ordmodel).Error
  1283. return ordmodel, err
  1284. }
  1285. func GetHostpitaAddress(orgid int64, moid int64) (models.SgjPatientHosaddress, error) {
  1286. hosaddress := models.SgjPatientHosaddress{}
  1287. err := service.PatientReadDB().Model(&hosaddress).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, moid, 1).Find(&hosaddress).Error
  1288. return hosaddress, err
  1289. }
  1290. func UpdateHosAddress(id int64, orgid int64, hosaddress models.SgjPatientHosaddress) error {
  1291. 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
  1292. return err
  1293. }
  1294. func AddConlinkaddress(conlinkaddress *models.SgjPatientConlinkaddress) error {
  1295. err := service.PatientWriteDB().Create(&conlinkaddress).Error
  1296. return err
  1297. }
  1298. func GetConLinkAddressById(orgid int64) (models.SgjPatientConlinkaddress, error) {
  1299. conlinkaddress := models.SgjPatientConlinkaddress{}
  1300. err := service.PatientReadDB().Model(&conlinkaddress).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conlinkaddress).Error
  1301. return conlinkaddress, err
  1302. }
  1303. func GetLinkAddressDetail(orgid int64, id int64) (models.SgjPatientConlinkaddress, error) {
  1304. conlinkaddress := models.SgjPatientConlinkaddress{}
  1305. err := service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&conlinkaddress).Error
  1306. return conlinkaddress, err
  1307. }
  1308. //func UpdatePicFformThree(orgid int64,id int64,conlinkaddress models.SgjPatientConlinkaddress) error {
  1309. //
  1310. // 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
  1311. // return err
  1312. //}
  1313. func GetEnImagesTwo(orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) {
  1314. err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&editpiclink).Error
  1315. return editpiclink, err
  1316. }
  1317. func GetEnImagesThree(orgid int64) (conrotation []models.SgjPatientConrotation, err error) {
  1318. err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&conrotation).Error
  1319. return conrotation, err
  1320. }
  1321. func AddMagiclinkData(magiclink *models.SgjPatientMagiclink) error {
  1322. err := service.PatientWriteDB().Create(&magiclink).Error
  1323. return err
  1324. }
  1325. func GetPatienModelByModelId(id int64, orgid int64) (models.PatientModel, error) {
  1326. model := models.PatientModel{}
  1327. err := service.PatientReadDB().Model(&model).Where("id=? AND user_org_id = ?", id, orgid).Find(&model).Error
  1328. return model, err
  1329. }
  1330. func GetMacLinkAddressTwo(orgid int64) (patientMagiclink []models.SgjPatientMagiclink, err error) {
  1331. err = service.PatientReadDB().Model(&patientMagiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&patientMagiclink).Error
  1332. return patientMagiclink, err
  1333. }
  1334. func UpdateEditMagin(orgid int64, ids []int64, editmargin models.SgjPatientEditmargin) (err error) {
  1335. if len(ids) == 1 {
  1336. 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
  1337. } else {
  1338. 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
  1339. }
  1340. return
  1341. }
  1342. func AddMacgicform(editmargin *models.SgjPatientEditmargin) error {
  1343. err := service.PatientWriteDB().Create(&editmargin).Error
  1344. return err
  1345. }
  1346. func GetMacImagesDetail(orgid int64, modeid int64) (editmargin []models.SgjPatientEditmargin, err error) {
  1347. err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND modeid = ?", orgid, 1, modeid).Find(&editmargin).Error
  1348. return editmargin, err
  1349. }
  1350. func DeletMacImagesDetail(id int64, orgid int64) error {
  1351. 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
  1352. return err
  1353. }
  1354. func GetEditMacImageDetailById(orgid int64, id int64) (models.SgjPatientEditmargin, error) {
  1355. editmargin := models.SgjPatientEditmargin{}
  1356. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, id).Find(&editmargin).Error
  1357. return editmargin, err
  1358. }
  1359. func UpdateEditMacFormById(id int64, orgid int64, editmargin models.SgjPatientEditmargin) (err error) {
  1360. 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
  1361. return err
  1362. }
  1363. func GetLikeMacAddressById(orgid int64, id int64) (models.SgjPatientMagiclink, error) {
  1364. magiclink := models.SgjPatientMagiclink{}
  1365. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, id).Find(&magiclink).Error
  1366. return magiclink, err
  1367. }
  1368. func GetAllArticeList(orgid int64) (articles []models.Articles, err error) {
  1369. err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&articles).Error
  1370. return articles, err
  1371. }
  1372. func AddActicles(articles *models.Articles) error {
  1373. err := service.PatientWriteDB().Create(&articles).Error
  1374. return err
  1375. }
  1376. func UpdateLinkAddress(id int64, orgid int64, magiclink models.SgjPatientMagiclink) error {
  1377. err := service.PatientWriteDB().Model(&models.SgjPatientMagiclink{}).Where("id = ? AND user_org_id = ? ", id, orgid).Update(map[string]interface{}{"linktype": magiclink.Linktype, "instationlink": magiclink.Instationlink, "phone": magiclink.Phone, "outstationlink": magiclink.Outstationlink, "linkaddress": magiclink.Linkaddress, "mtime": time.Now().Unix()}).Error
  1378. return err
  1379. }
  1380. func GetUpdateLinkAddress(id int64, orgid int64) (models.SgjPatientMagiclink, error) {
  1381. editpiclink := models.SgjPatientMagiclink{}
  1382. err := service.PatientReadDB().Model(&editpiclink).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error
  1383. return editpiclink, err
  1384. }
  1385. func GetMacLinkAddress(orgid int64) (magiclink []models.SgjPatientMagiclink, err error) {
  1386. err = service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND status =?", orgid, 1).Find(&magiclink).Error
  1387. return magiclink, err
  1388. }
  1389. func AddMacLinkAddress(magiclink *models.SgjPatientMagiclink) error {
  1390. err := service.PatientWriteDB().Create(&magiclink).Error
  1391. return err
  1392. }
  1393. func GetMacLinkAddressByLastData(orgid int64) (models.SgjPatientMagiclink, error) {
  1394. magiclink := models.SgjPatientMagiclink{}
  1395. err := service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&magiclink).Error
  1396. return magiclink, err
  1397. }
  1398. func AddNavitaionLinkAddress(navgationlink *models.PatientNavgationlink) error {
  1399. err := service.PatientWriteDB().Create(&navgationlink).Error
  1400. return err
  1401. }
  1402. func GetPatientLinkAddress(id int64, orgid int64) (models.SgjPatientLinkaddress, error) {
  1403. linkaddress := models.SgjPatientLinkaddress{}
  1404. err := service.PatientReadDB().Where(" id = ? AND user_org_id = ?", id, orgid).Find(&linkaddress).Error
  1405. return linkaddress, err
  1406. }
  1407. func GetCountImages(orgid int64) (edipiclink []models.SgjPatientEditpiclink, total int64, err error) {
  1408. err = service.PatientReadDB().Where("user_org_id = ? AND img_show = ? AND status = ?", orgid, 1, 1).Find(&edipiclink).Count(&total).Error
  1409. return edipiclink, total, err
  1410. }
  1411. func GetDeleteImages(orgid int64, modeid int64) (edipiclink []models.SgjPatientEditpiclink, total int64, err error) {
  1412. err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Find(&edipiclink).Count(&total).Error
  1413. return edipiclink, total, err
  1414. }
  1415. func GetTotalCount(orgid int64) (conrotation []models.SgjPatientConrotation, total int64, err error) {
  1416. err = service.PatientReadDB().Where("user_org_id = ? AND img_show = ? AND status = ?", orgid, 1, 1).Find(&conrotation).Count(&total).Error
  1417. return conrotation, total, err
  1418. }
  1419. func GetCountPicImages(orgid int64, modeid int64) (edipiclink []models.SgjPatientEditpiclink, total int64, err error) {
  1420. err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Find(&edipiclink).Count(&total).Error
  1421. return edipiclink, total, err
  1422. }
  1423. func GetPicImages(orgid int64, modeid int64) (editpiclink []models.SgjPatientEditpiclink, err error) {
  1424. err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Order("sort").Find(&editpiclink).Error
  1425. return editpiclink, err
  1426. }
  1427. func QueryEditpiclinkCount(mid int64, orgid int64) (editpiclink []models.SgjPatientEditpiclink, total int64, err error) {
  1428. err = service.PatientWriteDB().Where("modeid = ? AND user_org_id =? AND status = ?", mid, orgid, 1).Find(&editpiclink).Count(&total).Error
  1429. return editpiclink, total, err
  1430. }
  1431. func AddNavgationlink(navgationlink *models.PatientNavgationlink) error {
  1432. err := service.PatientWriteDB().Create(&navgationlink).Error
  1433. return err
  1434. }
  1435. func GetNavgationlinkLastData(orgid int64) (models.PatientNavgationlink, error) {
  1436. navgationlink := models.PatientNavgationlink{}
  1437. err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&navgationlink).Error
  1438. return navgationlink, err
  1439. }
  1440. func GetNavgationlinkAddressBylinkId(orgid int64, linkid int64) (models.PatientNavgationlink, error) {
  1441. navgationlink := models.PatientNavgationlink{}
  1442. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, linkid).Find(&navgationlink).Error
  1443. return navgationlink, err
  1444. }
  1445. func GetNavgationLinkById(id int64, orgid int64) (*models.PatientNavgationlink, error) {
  1446. var pat models.PatientNavgationlink
  1447. var err error
  1448. err = service.PatientReadDB().Model(&models.PatientNavgationlink{}).Where(" id = ? AND user_org_id = ?", id, orgid).Find(&pat).Error
  1449. if err == gorm.ErrRecordNotFound {
  1450. return nil, err
  1451. }
  1452. if err != nil {
  1453. return nil, err
  1454. }
  1455. return &pat, nil
  1456. }
  1457. func AddNavigationlink(navgationlink *models.PatientNavgationlink) error {
  1458. err := service.PatientWriteDB().Create(&navgationlink).Error
  1459. return err
  1460. }
  1461. func UpdateditnavigationLink(id int64, orgid int64, navgationlink models.PatientNavgationlink) error {
  1462. err := service.PatientWriteDB().Model(&navgationlink).Where("id = ? AND user_org_id =?", id, orgid).Update(map[string]interface{}{"linktype": navgationlink.Linktype, "navitionlinktype": navgationlink.Navitionlinktype, "phone": navgationlink.Phone, "outstationlink": navgationlink.Outstationlink, "linkaddress": navgationlink.Linkaddress, "mtime": time.Now().Unix()}).Error
  1463. return err
  1464. }
  1465. func AddEditDoctor(editdoctor *models.SgjPatientEditdoctor) error {
  1466. err := service.PatientWriteDB().Create(&editdoctor).Error
  1467. return err
  1468. }
  1469. func QuerEditDoctorInfo(mid int64, orgid int64) (editdoctor []models.SgjPatientEditdoctor, err error) {
  1470. err = service.PatientWriteDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdoctor).Error
  1471. return editdoctor, err
  1472. }
  1473. func GetModel(orgid int64) (*models.SgjPatientModel, error) {
  1474. var model models.SgjPatientModel
  1475. var err error
  1476. err = service.PatientReadDB().Model(&models.SgjPatientModel{}).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&model).Error
  1477. if err == gorm.ErrRecordNotFound {
  1478. return nil, err
  1479. }
  1480. if err != nil {
  1481. return nil, err
  1482. }
  1483. return &model, nil
  1484. }
  1485. func AddPatientModelTwo(model *models.SgjPatientModel) error {
  1486. err := service.PatientWriteDB().Create(&model).Error
  1487. return err
  1488. }
  1489. func GetQueryModelByLastData(orgid int64) (models.SgjPatientModel, error) {
  1490. model := models.SgjPatientModel{}
  1491. err := service.PatientReadDB().Model(&model).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&model).Error
  1492. return model, err
  1493. }
  1494. func AddPatientEdit(editpiclink *models.SgjPatientEditpiclink) error {
  1495. err := service.PatientWriteDB().Create(&editpiclink).Error
  1496. return err
  1497. }
  1498. func AddHospital(hospital *models.SgjPatientHospital) error {
  1499. err := service.PatientWriteDB().Create(&hospital).Error
  1500. return err
  1501. }
  1502. func AddEditMargin(editmargin *models.SgjPatientEditmargin) error {
  1503. err := service.PatientWriteDB().Create(&editmargin).Error
  1504. return err
  1505. }
  1506. func AddPatientOffices(offices *models.SgjPatientOffices) error {
  1507. err := service.PatientWriteDB().Create(&offices).Error
  1508. return err
  1509. }
  1510. func GetDefaultNavigation(orgid int64) (navigation []models.SgjPatientNavigation, err error) {
  1511. err = service.PatientReadDB().Model(navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
  1512. return navigation, err
  1513. }
  1514. func AddDefaultData(navigation *models.SgjPatientNavigation) error {
  1515. err := service.PatientWriteDB().Create(&navigation).Error
  1516. return err
  1517. }
  1518. func GetAllModelTitle(orgid int64) (models []models.SgjPatientModel, err error) {
  1519. err = service.PatientReadDB().Model(models).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&models).Error
  1520. return models, err
  1521. }
  1522. func GetDoctorDetailInfo(id int64, orgid int64) (models.SgjPatientEditdoctor, error) {
  1523. editdoctor := models.SgjPatientEditdoctor{}
  1524. err := service.PatientReadDB().Model(&editdoctor).Where("id=? AND user_org_id = ?", id, orgid).Find(&editdoctor).Error
  1525. return editdoctor, err
  1526. }
  1527. func GetArticleListDetail(id int64, orgid int64) (models.Articles, error) {
  1528. articles := models.Articles{}
  1529. err := service.PatientReadDB().Model(&articles).Where("id=? AND user_org_id =?", id, orgid).Find(&articles).Error
  1530. return articles, err
  1531. }
  1532. func GetActivitiesListDetail(id int64, orgid int64) (models.Activity, error) {
  1533. activity := models.Activity{}
  1534. err := service.PatientReadDB().Model(&activity).Where("id=? AND user_org_id = ?", id, orgid).Find(&activity).Error
  1535. return activity, err
  1536. }
  1537. func GetLinkAddressByLinkId(orgid int64, linkid int64) (models.SgjPatientLinkaddress, error) {
  1538. linkaddress := models.SgjPatientLinkaddress{}
  1539. err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&linkaddress).Error
  1540. return linkaddress, err
  1541. }
  1542. func GetMagicLinkAddressById(orgid int64, linkid int64) (models.SgjPatientMagiclink, error) {
  1543. magiclink := models.SgjPatientMagiclink{}
  1544. err := service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&magiclink).Error
  1545. return magiclink, err
  1546. }
  1547. func GetMagicClickByLinkID(orgid int64, linkid int64) (models.SgjPatientMagiclink, error) {
  1548. magiclink := models.SgjPatientMagiclink{}
  1549. err := service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&magiclink).Error
  1550. return magiclink, err
  1551. }
  1552. func GetEditRotationEmages(id int64, orgid int64) (models.SgjPatientConrotation, error) {
  1553. conrotation := models.SgjPatientConrotation{}
  1554. err := service.PatientReadDB().Where("id = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error
  1555. return conrotation, err
  1556. }
  1557. func GetOutRotationLink(orgid int64, linkid int64) (models.SgjPatientConlinkaddress, error) {
  1558. conlinkaddress := models.SgjPatientConlinkaddress{}
  1559. err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, linkid).Find(&conlinkaddress).Error
  1560. return conlinkaddress, err
  1561. }
  1562. func UpdatedConlinkAddress(id int64, orgid int64, conlinkaddress models.SgjPatientConlinkaddress) error {
  1563. err := service.PatientReadDB().Model(&conlinkaddress).Where("id=? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"defineaddress": conlinkaddress.Defineaddress, "mtime": time.Now().Unix()}).Error
  1564. return err
  1565. }
  1566. func AddConlinkAddress(conlinkaddress *models.SgjPatientConlinkaddress) error {
  1567. err := service.PatientWriteDB().Create(&conlinkaddress).Error
  1568. return err
  1569. }
  1570. func UpdatedConrotation(id int64, orgid int64, conrotation models.SgjPatientConrotation) error {
  1571. err := service.PatientReadDB().Model(&conrotation).Where("id=? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"images": conrotation.Images, "sort": conrotation.Sort, "piclink": conrotation.Piclink, "linkaddress": conrotation.Linkaddress, "mtime": time.Now().Unix()}).Error
  1572. return err
  1573. }
  1574. func GetRotationVisibleByLinkId(id int64, orgid int64) (models.SgjPatientLinkaddress, error) {
  1575. conlinkaddress := models.SgjPatientLinkaddress{}
  1576. err := service.PatientReadDB().Where("id = ? AND user_org_id = ?", id, orgid).Find(&conlinkaddress).Error
  1577. return conlinkaddress, err
  1578. }
  1579. func UpdatedRotationVisble(id int64, orgid int64, linkaddress models.SgjPatientLinkaddress) error {
  1580. err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"defineaddress": linkaddress.Defineaddress, "mtime": time.Now().Unix()}).Error
  1581. return err
  1582. }
  1583. func GetAritclesData(orgid int64) (articles []models.Articles, err error) {
  1584. err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&articles).Error
  1585. return articles, err
  1586. }
  1587. func GetArititys(orgid int64) (activity []models.Activity, err error) {
  1588. err = service.PatientReadDB().Model(&activity).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&activity).Error
  1589. return activity, err
  1590. }
  1591. func AddActivitys(activity *models.Activity) error {
  1592. err := service.PatientReadDB().Create(&activity).Error
  1593. return err
  1594. }
  1595. func GetContactUsModel(orgid int64) (oldmodels []models.PatientOrdmodel, err error) {
  1596. err = service.PatientReadDB().Model(&oldmodels).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&oldmodels).Error
  1597. return oldmodels, err
  1598. }
  1599. func GetPatientOrdModelByLastData(orgid int64) (models.PatientOrdmodel, error) {
  1600. ordmodel := models.PatientOrdmodel{}
  1601. err := service.PatientReadDB().Model(&ordmodel).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&ordmodel).Error
  1602. return ordmodel, err
  1603. }
  1604. func AddConRotation(conrotation *models.SgjPatientConrotation) error {
  1605. err := service.PatientWriteDB().Create(&conrotation).Error
  1606. return err
  1607. }
  1608. func GetOrgName(orgid int64) (models.Org, error) {
  1609. org := models.Org{}
  1610. err := service.UserReadDB().Model(&org).Where("id= ? and status = 1", orgid).Find(&org).Error
  1611. return org, err
  1612. }