scrm-go

site_microwebsite_service.go 80KB

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