scrm-go

site_microwebsite_service.go 76KB

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