scrm-go

site_microwebsite_service.go 77KB

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