scrm-go

site_controller.go 40KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. package site
  2. import (
  3. "github.com/astaxie/beego"
  4. "SCRM/controllers"
  5. "fmt"
  6. "encoding/json"
  7. "SCRM/utils"
  8. "SCRM/enums"
  9. "strconv"
  10. "SCRM/service/site_service"
  11. "SCRM/models"
  12. "time"
  13. "strings"
  14. )
  15. func siteRouters() {
  16. beego.Router("/api/site/addrotationchart",&Microwebsite{},"Post:AddRotaionChart")
  17. beego.Router("/api/site/savehispital",&Microwebsite{},"Post:SaveHispital")
  18. beego.Router("/api/site/addoffices",&Microwebsite{},"Post:AddOffices")
  19. beego.Router("/api/site/adddoctor",&Microwebsite{},"Post:AddDoctor")
  20. beego.Router("/api/site/adddoctorinfo",&Microwebsite{},"Post:AddDoctorInfo")
  21. beego.Router("/api/site/getrationimages",&Microwebsite{},"Get:GetRationImages")
  22. beego.Router("/api/site/gethospitalinfo",&Microwebsite{},"Get:GetHospitalinfo")
  23. beego.Router("/api/site/getofficeinfo",&Microwebsite{},"Get:GetOfficeInfo")
  24. beego.Router("/api/site/getdoctorinfo",&Microwebsite{},"Get:GetDoctorInfo")
  25. beego.Router("/api/site/keenvironment",&Microwebsite{},"Post:AddKeEnvironment")
  26. beego.Router("/api/site/getOffEnvironment",&Microwebsite{},"Get:GetOffEnvironment")
  27. beego.Router("/api/site/addrotationupload",&Microwebsite{},"Post:AddRotationUpload")
  28. beego.Router("/api/site/addworktime",&Microwebsite{},"Post:AddWorkTime")
  29. beego.Router("/api/site/addrideway",&Microwebsite{},"Post:AddRideway")
  30. beego.Router("/api/site/addconnection",&Microwebsite{},"Post:AddConnection")
  31. beego.Router("/api/site/queryconnetion",&Microwebsite{},"Get:GetQueryConnection")
  32. beego.Router("/api/site/delete",&Microwebsite{},"Get:DeleteConnecWay")
  33. beego.Router("/api/site/editconnecway",&Microwebsite{},"Get:EditConnecWay")
  34. beego.Router("/api/site/saveconnection",&Microwebsite{},"Post:SaveConnection")
  35. beego.Router("/api/site/addcontract",&Microwebsite{},"Post:AddContract")
  36. beego.Router("/api/site/getuserdmodel",&Microwebsite{},"Post:GetUserdModel")
  37. beego.Router("/api/site/eidtmodel",&Microwebsite{},"Get:GetEditModel")
  38. beego.Router("/api/site/editrideway",&Microwebsite{},"Get:EditRideWay")
  39. beego.Router("/api/site/saveworktime",&Microwebsite{},"Post:SaveWorktTime")
  40. beego.Router("/api/site/saverideway",&Microwebsite{},"Post:Saverideway")
  41. beego.Router("/api/site/getquerynewmodel",&Microwebsite{},"Post:GetQueryNewModel")
  42. beego.Router("/api/site/getquerydocinfo",&Microwebsite{},"Post:GetQueryDocInfo")
  43. beego.Router("/api/site/change",&Microwebsite{},"Get:Change")
  44. beego.Router("/api/site/getquerydochead",&Microwebsite{},"Post:GetQueryDocHead")
  45. beego.Router("/api/site/editdoctor",&Microwebsite{},"Get:Editdoctor")
  46. beego.Router("/api/site/savedocinfo",&Microwebsite{},"Post:SaveDocInfo")
  47. beego.Router("/api/site/deletedoctor",&Microwebsite{},"Get:DeleteDoctor")
  48. beego.Router("/api/site/edithospital",&Microwebsite{},"Get:EditHospital")
  49. beego.Router("/api/site/savehostpital",&Microwebsite{},"Post:SaveHospital")
  50. beego.Router("api/site/editoffice",&Microwebsite{},"Get:EditOffice")
  51. beego.Router("/api/site/deletemodlebyid",&Microwebsite{},"Get:Deletemodlebyid")
  52. beego.Router("/api/site/saveoffice",&Microwebsite{},"Post:SaveOffice")
  53. beego.Router("/api/site/gethospital",&Microwebsite{},"Post:GetHospital")
  54. beego.Router("/api/site/getdata",&Microwebsite{},"Post:GetData")
  55. }
  56. type Microwebsite struct {
  57. controllers.BaseAuthAPIController
  58. }
  59. //轮播图
  60. func (this *Microwebsite) AddRotaionChart() {
  61. adminUserInfo := this.GetAdminUserInfo()
  62. userOrgID := int64(adminUserInfo.CurrentOrgId)
  63. dataBody := make(map[string]interface{}, 0)
  64. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  65. fmt.Println("错误是什么呢",err)
  66. fmt.Println("机构ID",userOrgID)
  67. if err != nil {
  68. utils.ErrorLog(err.Error())
  69. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  70. return
  71. }
  72. title := dataBody["title"].(string)
  73. if len(title) == 0 {
  74. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  75. return
  76. }
  77. fmt.Println("姓名:",title)
  78. sort := dataBody["sort"].(string)
  79. if len(sort) == 0 {
  80. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  81. return
  82. }
  83. sortt, err := strconv.ParseInt(sort, 10, 64)
  84. fmt.Println("排序:",sortt)
  85. rotationImages := dataBody["rotationImages"]
  86. //图片数组转为字符串保存到数据库
  87. replace := strings.Replace(strings.Trim(fmt.Sprint(rotationImages), "[]"), " ", ",", -1)
  88. fmt.Println("姓名:",rotationImages)
  89. fmt.Println("字符串",replace)
  90. model := models.SgjPatientModel{
  91. Title: title,
  92. Sort: sortt,
  93. UserOrgId: userOrgID,
  94. Status: 1,
  95. Ctime: time.Now().Unix(),
  96. ModeType: 1,
  97. }
  98. //fmt.Println(model)
  99. site_service.AddPatientModel(&model)
  100. fmt.Println("rotation是什么",model)
  101. patientModel, err := site_service.QueryModel(userOrgID)
  102. fmt.Println("patientModel是什麽",patientModel)
  103. rotation := models.SgjPatientRotation{
  104. Title: title,
  105. Sort: sortt,
  106. RotationImages: replace,
  107. UserOrgId: userOrgID,
  108. Status: 1,
  109. Ctime: time.Now().Unix(),
  110. ModelId:patientModel.ID,
  111. }
  112. site_service.AddRotation(rotation)
  113. if err !=nil{
  114. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
  115. return
  116. }
  117. this.ServeSuccessJSON(map[string]interface{}{
  118. "rotation":rotation,
  119. })
  120. }
  121. //医院介绍
  122. func (this *Microwebsite) SaveHispital() {
  123. adminUserInfo := this.GetAdminUserInfo()
  124. userOrgID := int64(adminUserInfo.CurrentOrgId)
  125. dataBody := make(map[string]interface{}, 0)
  126. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  127. fmt.Println("错误是什么呢",err)
  128. fmt.Println("机构ID",userOrgID)
  129. if err != nil {
  130. utils.ErrorLog(err.Error())
  131. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  132. return
  133. }
  134. title := dataBody["title"].(string)
  135. if len(title) == 0 {
  136. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  137. return
  138. }
  139. fmt.Println("姓名:",title)
  140. sort := dataBody["sort"].(string)
  141. if len(sort) == 0 {
  142. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  143. return
  144. }
  145. sortt, err := strconv.ParseInt(sort, 10, 64)
  146. fmt.Println("排序:",sortt)
  147. introduction := dataBody["introduction"].(string)
  148. if len(introduction) == 0 {
  149. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医院介绍不能为空")
  150. return
  151. }
  152. fmt.Println("姓名是什么?",title,"排序是什么",sortt,"医院介绍不能为空",introduction)
  153. model := models.SgjPatientModel{
  154. Title: title,
  155. Sort: sortt,
  156. UserOrgId: userOrgID,
  157. Ctime: time.Now().Unix(),
  158. Status: 1,
  159. ModeType: 2,
  160. }
  161. site_service.AddPatientModel(&model)
  162. patientModel, err := site_service.QueryModel(userOrgID)
  163. hospital := models.SgjPatientHospital{
  164. Title: title,
  165. Sort: sortt,
  166. Introduction: introduction,
  167. UserOrgId: userOrgID,
  168. Ctime: time.Now().Unix(),
  169. Status: 1,
  170. Modleid: patientModel.ID,
  171. }
  172. err = site_service.AddHispital(hospital)
  173. if err !=nil{
  174. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
  175. return
  176. }
  177. this.ServeSuccessJSON(map[string]interface{}{
  178. "hospital":hospital,
  179. })
  180. }
  181. //添加科室
  182. func (this *Microwebsite) AddOffices() {
  183. adminUserInfo := this.GetAdminUserInfo()
  184. userOrgID := int64(adminUserInfo.CurrentOrgId)
  185. dataBody := make(map[string]interface{}, 0)
  186. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  187. fmt.Println("错误是什么呢",err)
  188. fmt.Println("机构ID",userOrgID)
  189. if err != nil {
  190. utils.ErrorLog(err.Error())
  191. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  192. return
  193. }
  194. title := dataBody["title"].(string)
  195. if len(title) == 0 {
  196. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  197. return
  198. }
  199. fmt.Println("姓名:",title)
  200. sort := dataBody["sort"].(string)
  201. if len(sort) == 0 {
  202. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  203. return
  204. }
  205. sortt, err := strconv.ParseInt(sort, 10, 64)
  206. fmt.Println("排序:",sortt)
  207. introduction := dataBody["introduction"].(string)
  208. if len(introduction) == 0 {
  209. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医院介绍不能为空")
  210. return
  211. }
  212. fmt.Println("姓名是什么?",title,"排序是什么",sortt,"医院介绍不能为空",introduction)
  213. model := models.SgjPatientModel{
  214. Title: title,
  215. Sort: sortt,
  216. UserOrgId: userOrgID,
  217. Ctime: time.Now().Unix(),
  218. Status: 1,
  219. ModeType: 3,
  220. }
  221. site_service.AddPatientModel(&model)
  222. patientModel, err := site_service.QueryModel(userOrgID)
  223. offices := models.SgjPatientOffices{
  224. Title: title,
  225. Sort: sortt,
  226. Introduction: introduction,
  227. UserOrgId: userOrgID,
  228. Ctime: time.Now().Unix(),
  229. Status: 1,
  230. Modleid:patientModel.ID,
  231. }
  232. err = site_service.AddOffices(offices)
  233. if err !=nil{
  234. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
  235. return
  236. }
  237. this.ServeSuccessJSON(map[string]interface{}{
  238. "offices":offices,
  239. })
  240. }
  241. //添加名医
  242. func (this *Microwebsite) AddDoctor() {
  243. adminUserInfo := this.GetAdminUserInfo()
  244. userOrgID := int64(adminUserInfo.CurrentOrgId)
  245. dataBody := make(map[string]interface{}, 0)
  246. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  247. fmt.Println("错误是什么呢",err)
  248. fmt.Println("机构ID",userOrgID)
  249. if err != nil {
  250. utils.ErrorLog(err.Error())
  251. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  252. return
  253. }
  254. title := dataBody["title"].(string)
  255. if len(title) == 0 {
  256. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  257. return
  258. }
  259. fmt.Println("姓名:",title)
  260. sort := dataBody["sort"].(string)
  261. if len(sort) == 0 {
  262. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  263. return
  264. }
  265. sortt, err := strconv.ParseInt(sort, 10, 64)
  266. fmt.Println("排序:",sortt)
  267. images := dataBody["docimages"]
  268. replace := strings.Replace(strings.Trim(fmt.Sprint(images), "[]"), " ", ",", -1)
  269. //if len(image) == 0 {
  270. // this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医院介绍不能为空")
  271. // return
  272. //}
  273. fmt.Println("姓名是什么?",title,"排序是什么",sortt,"图片",replace)
  274. model := models.SgjPatientModel{
  275. Title: title,
  276. Sort: sortt,
  277. UserOrgId: userOrgID,
  278. Ctime: time.Now().Unix(),
  279. Status: 1,
  280. ModeType: 4,
  281. }
  282. site_service.AddPatientModel(&model)
  283. patientModel, err := site_service.QueryModel(userOrgID)
  284. doctor := models.SgjPatientDoctor{
  285. Title: title,
  286. Sort: sortt,
  287. Images: replace,
  288. UserOrgId:userOrgID,
  289. Ctime:time.Now().Unix(),
  290. Status:1,
  291. Modelid:patientModel.ID,
  292. }
  293. err = site_service.AddDoctor(doctor)
  294. if err !=nil{
  295. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
  296. return
  297. }
  298. this.ServeSuccessJSON(map[string]interface{}{
  299. "doctor":doctor,
  300. })
  301. }
  302. //添加名医介绍
  303. func (this *Microwebsite) AddDoctorInfo() {
  304. adminUserInfo := this.GetAdminUserInfo()
  305. userOrgID := int64(adminUserInfo.CurrentOrgId)
  306. dataBody := make(map[string]interface{}, 0)
  307. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  308. fmt.Println("错误是什么呢",err)
  309. fmt.Println("机构ID",userOrgID)
  310. if err != nil {
  311. utils.ErrorLog(err.Error())
  312. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  313. return
  314. }
  315. docname := dataBody["name"].(string)
  316. if len(docname) == 0 {
  317. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生姓名不能为空")
  318. return
  319. }
  320. fmt.Println("医生姓名:",docname)
  321. docHead := dataBody["dochead"].(string)
  322. if len(docHead) == 0 {
  323. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生头像不能为空")
  324. return
  325. }
  326. fmt.Println("医生头像:",docHead)
  327. sort := dataBody["sort"].(string)
  328. if len(sort) == 0 {
  329. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  330. return
  331. }
  332. sortt, err := strconv.ParseInt(sort, 10, 64)
  333. fmt.Println("排序:",sortt)
  334. docpositional := int64(dataBody["user_title"].(float64))
  335. if docpositional <= 0 {
  336. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生职位不能为空")
  337. return
  338. }
  339. fmt.Println("医生职位",docpositional)
  340. docintroduction := dataBody["content"].(string)
  341. fmt.Println("医生简介",docintroduction)
  342. if len(docintroduction) == 0 {
  343. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生简介不能为空")
  344. return
  345. }
  346. fmt.Println("医生姓名",docname,"医生职位",docpositional,"医生头像",docHead,"医生简介",docintroduction)
  347. doctor := models.SgjPatientDoctor{
  348. Docname: docname,
  349. Dochead: docHead,
  350. DocPosition: docpositional,
  351. Docintroduction: docintroduction,
  352. Ctime: time.Now().Unix(),
  353. UserOrgId: userOrgID,
  354. DocSort:sortt,
  355. Status: 1,
  356. }
  357. err = site_service.AddDoctorInfo(doctor)
  358. if err !=nil{
  359. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医生失败")
  360. return
  361. }
  362. this.ServeSuccessJSON(map[string]interface{}{
  363. "doctor":doctor,
  364. })
  365. }
  366. //新增科室环境
  367. func (this *Microwebsite) AddKeEnvironment() {
  368. adminUserInfo := this.GetAdminUserInfo()
  369. userOrgID := int64(adminUserInfo.CurrentOrgId)
  370. dataBody := make(map[string]interface{}, 0)
  371. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  372. fmt.Println("错误是什么呢",err)
  373. fmt.Println("机构ID",userOrgID)
  374. if err != nil {
  375. utils.ErrorLog(err.Error())
  376. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  377. return
  378. }
  379. title := dataBody["title"].(string)
  380. if len(title) == 0 {
  381. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  382. return
  383. }
  384. fmt.Println("标题:",title)
  385. sort := dataBody["sort"].(string)
  386. if len(sort) == 0 {
  387. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  388. return
  389. }
  390. sortt, err := strconv.ParseInt(sort, 10, 64)
  391. fmt.Println("排序:",sortt)
  392. keImages := dataBody["keImages"]
  393. //图片数组转为字符串保存到数据库
  394. replace := strings.Replace(strings.Trim(fmt.Sprint(keImages), "[]"), " ", ",", -1)
  395. fmt.Println("图片:",keImages)
  396. fmt.Println("字符串",replace)
  397. model := models.SgjPatientModel{
  398. Title: title,
  399. Sort: sortt,
  400. UserOrgId: userOrgID,
  401. Ctime: time.Now().Unix(),
  402. Status: 1,
  403. ModeType: 5,
  404. }
  405. site_service.AddPatientModel(&model)
  406. patientModel, err := site_service.QueryModel(userOrgID)
  407. officenviroment := models.SgjPatientOffenvironment{
  408. Title: title,
  409. Sort: sortt,
  410. Keimages: replace,
  411. Mtime: time.Now().Unix(),
  412. UserOrgId: userOrgID,
  413. Status: 1,
  414. Modelid:patientModel.ID,
  415. }
  416. err = site_service.AddOffEnvironment(officenviroment)
  417. if err !=nil{
  418. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加科室环境失败")
  419. return
  420. }
  421. this.ServeSuccessJSON(map[string]interface{}{
  422. "offenvironment":officenviroment,
  423. })
  424. }
  425. //获取轮播图
  426. func (this *Microwebsite) GetRationImages() {
  427. adminUserInfo := this.GetAdminUserInfo()
  428. userOrgID := int64(adminUserInfo.CurrentOrgId)
  429. rotation, err := site_service.GetRationImages(userOrgID)
  430. if err !=nil{
  431. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取轮播图失败")
  432. return
  433. }
  434. fmt.Println("错误是什么",err)
  435. fmt.Println("获取的数据",rotation)
  436. this.ServeSuccessJSON(map[string]interface{}{
  437. "rotationImages":rotation,
  438. })
  439. }
  440. //获取医院信息
  441. func (this * Microwebsite) GetHospitalinfo() {
  442. adminUserInfo := this.GetAdminUserInfo()
  443. userOrgID := int64(adminUserInfo.CurrentOrgId)
  444. hospital, err := site_service.GetHospitalInfo(userOrgID)
  445. fmt.Println("数据是什么",hospital)
  446. if err !=nil{
  447. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取轮播图失败")
  448. return
  449. }
  450. this.ServeSuccessJSON(map[string]interface{}{
  451. "hospital":hospital,
  452. })
  453. }
  454. //获取科室信息
  455. func (this * Microwebsite) GetOfficeInfo() {
  456. adminUserInfo := this.GetAdminUserInfo()
  457. userOrgID := int64(adminUserInfo.CurrentOrgId)
  458. offices, err := site_service.GetOfficeInfo(userOrgID)
  459. fmt.Println("科室介绍数据是什么",offices)
  460. if err !=nil{
  461. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取轮播图失败")
  462. return
  463. }
  464. this.ServeSuccessJSON(map[string]interface{}{
  465. "offices":offices,
  466. })
  467. }
  468. //获取名医介绍
  469. func (this * Microwebsite) GetDoctorInfo() {
  470. adminUserInfo := this.GetAdminUserInfo()
  471. userOrgID := int64(adminUserInfo.CurrentOrgId)
  472. doc, err := site_service.GetDoctorInfo(userOrgID)
  473. if err !=nil{
  474. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
  475. return
  476. }
  477. this.ServeSuccessJSON(map[string]interface{}{
  478. "doctor":doc,
  479. })
  480. }
  481. func (this * Microwebsite) GetQueryDocInfo(){
  482. adminUserInfo := this.GetAdminUserInfo()
  483. userOrgID := int64(adminUserInfo.CurrentOrgId)
  484. doc, err := site_service.GetQueryDocInfo(userOrgID)
  485. if err !=nil{
  486. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
  487. return
  488. }
  489. this.ServeSuccessJSON(map[string]interface{}{
  490. "doctor":doc,
  491. })
  492. }
  493. func (this * Microwebsite) GetQueryDocHead() {
  494. adminUserInfo := this.GetAdminUserInfo()
  495. userOrgID := int64(adminUserInfo.CurrentOrgId)
  496. docHead, err := site_service.GetQueryDocHead(userOrgID)
  497. if err !=nil{
  498. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
  499. return
  500. }
  501. this.ServeSuccessJSON(map[string]interface{}{
  502. "docHead":docHead,
  503. })
  504. }
  505. //获取科室环境
  506. func (this * Microwebsite) GetOffEnvironment() {
  507. adminUserInfo := this.GetAdminUserInfo()
  508. userOrgID := int64(adminUserInfo.CurrentOrgId)
  509. offenvironment, err := site_service.GetOffEnvironment(userOrgID)
  510. fmt.Println("错误是什么",err)
  511. fmt.Println("科室环境数据",offenvironment)
  512. if err !=nil{
  513. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
  514. return
  515. }
  516. this.ServeSuccessJSON(map[string]interface{}{
  517. "offenvironment":offenvironment,
  518. })
  519. }
  520. //添加联系我们的轮播图
  521. func (this * Microwebsite) AddRotationUpload() {
  522. adminUserInfo := this.GetAdminUserInfo()
  523. userOrgID := int64(adminUserInfo.CurrentOrgId)
  524. dataBody := make(map[string]interface{}, 0)
  525. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  526. fmt.Println("错误是什么呢",err)
  527. fmt.Println("机构ID",userOrgID)
  528. if err != nil {
  529. utils.ErrorLog(err.Error())
  530. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  531. return
  532. }
  533. title := dataBody["title"].(string)
  534. if len(title) == 0 {
  535. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  536. return
  537. }
  538. fmt.Println("姓名:",title)
  539. sort := dataBody["sort"].(string)
  540. if len(sort) == 0 {
  541. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  542. return
  543. }
  544. sortt, err := strconv.ParseInt(sort, 10, 64)
  545. fmt.Println("排序:",sortt)
  546. rotationImages := dataBody["rotationImages"]
  547. //图片数组转为字符串保存到数据库
  548. replace := strings.Replace(strings.Trim(fmt.Sprint(rotationImages), "[]"), " ", ",", -1)
  549. fmt.Println("姓名:",rotationImages)
  550. fmt.Println("字符串",replace)
  551. connecmodel := models.SgjPatientConnecmodel{
  552. Title: title,
  553. Sort: sortt,
  554. RotationImages: replace,
  555. UserOrgId: userOrgID,
  556. Status: 1,
  557. ModeType: 1,
  558. Ctime: time.Now().Unix(),
  559. }
  560. err = site_service.AddRotationUpload(&connecmodel)
  561. if err !=nil{
  562. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
  563. return
  564. }
  565. this.ServeSuccessJSON(map[string]interface{}{
  566. "connecmodel":connecmodel,
  567. })
  568. }
  569. //添加工作时间
  570. func (this * Microwebsite) AddWorkTime() {
  571. adminUserInfo := this.GetAdminUserInfo()
  572. userOrgID := int64(adminUserInfo.CurrentOrgId)
  573. dataBody := make(map[string]interface{}, 0)
  574. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  575. fmt.Println("错误是什么呢", err)
  576. fmt.Println("机构ID", userOrgID)
  577. if err != nil {
  578. utils.ErrorLog(err.Error())
  579. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  580. return
  581. }
  582. title := dataBody["title"].(string)
  583. if len(title) == 0 {
  584. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  585. return
  586. }
  587. sort := dataBody["sort"].(string)
  588. if len(sort) == 0 {
  589. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  590. return
  591. }
  592. sortt, err := strconv.ParseInt(sort, 10, 64)
  593. fmt.Println("排序:", sortt)
  594. worktime := dataBody["worktime"].(string)
  595. if len(worktime) == 0 {
  596. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "工作时间不能为空")
  597. return
  598. }
  599. sgjworktime := models.SgjPatientConnecmodel{
  600. Title: title,
  601. Sort: sortt,
  602. Status: 1,
  603. UserOrgId: userOrgID,
  604. Worktime: worktime,
  605. ModeType: 4,
  606. Ctime: time.Now().Unix(),
  607. }
  608. //添加模块
  609. err = site_service.AddWorkTime(sgjworktime);
  610. if err !=nil{
  611. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加乘车方式失败")
  612. return
  613. }
  614. this.ServeSuccessJSON(map[string]interface{}{
  615. "sgjworktime":sgjworktime,
  616. })
  617. }
  618. //添加乘车方式
  619. func (this * Microwebsite) AddRideway() {
  620. adminUserInfo := this.GetAdminUserInfo()
  621. userOrgID := int64(adminUserInfo.CurrentOrgId)
  622. dataBody := make(map[string]interface{}, 0)
  623. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  624. fmt.Println("错误是什么呢", err)
  625. fmt.Println("机构ID", userOrgID)
  626. if err != nil {
  627. utils.ErrorLog(err.Error())
  628. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  629. return
  630. }
  631. title := dataBody["title"].(string)
  632. if len(title) == 0 {
  633. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  634. return
  635. }
  636. fmt.Println("姓名:", title)
  637. sort := dataBody["sort"].(string)
  638. if len(sort) == 0 {
  639. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  640. return
  641. }
  642. sortt, err := strconv.ParseInt(sort, 10, 64)
  643. fmt.Println("排序:", sortt)
  644. content := dataBody["content"].(string)
  645. if len(content) == 0 {
  646. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "乘车方式不能为空")
  647. return
  648. }
  649. rideway := models.SgjPatientConnecmodel{
  650. Title: title,
  651. Sort: sortt,
  652. UserOrgId: userOrgID,
  653. Rideway:content,
  654. Status: 1,
  655. ModeType: 5,
  656. Ctime: time.Now().Unix(),
  657. }
  658. err = site_service.AddRideWay(rideway)
  659. if err !=nil{
  660. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加乘车方式失败")
  661. return
  662. }
  663. this.ServeSuccessJSON(map[string]interface{}{
  664. "rideway":rideway,
  665. })
  666. }
  667. //添加联系方式
  668. func (this * Microwebsite) AddConnection() {
  669. adminUserInfo := this.GetAdminUserInfo()
  670. userOrgID := int64(adminUserInfo.CurrentOrgId)
  671. dataBody := make(map[string]interface{}, 0)
  672. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  673. fmt.Println("错误是什么呢", err)
  674. if err != nil {
  675. utils.ErrorLog(err.Error())
  676. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  677. return
  678. }
  679. title := dataBody["title"].(string)
  680. if len(title) == 0 {
  681. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  682. return
  683. }
  684. fmt.Println("姓名:", title)
  685. connecway :=int64( dataBody["connecway"].(float64))
  686. if connecway < 0{
  687. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "联系方式不能为空")
  688. return
  689. }
  690. fmt.Println("联系方式",connecway)
  691. content := dataBody["content"].(string)
  692. if len(content) == 0 {
  693. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  694. return
  695. }
  696. fmt.Println("内容",content)
  697. connection := models.SgjPatientConnection{
  698. Title: title,
  699. Connecway: connecway,
  700. Content: content,
  701. Status: 1,
  702. Ctime: time.Now().Unix(),
  703. UserOrgId:userOrgID,
  704. }
  705. err = site_service.AddConnetion(connection);
  706. if err !=nil{
  707. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加联系方式失败")
  708. return
  709. }
  710. this.ServeSuccessJSON(map[string]interface{}{
  711. "connection":connection,
  712. })
  713. }
  714. //获取联系方式
  715. func (this * Microwebsite) GetQueryConnection() {
  716. adminUserInfo := this.GetAdminUserInfo()
  717. userOrgID := int64(adminUserInfo.CurrentOrgId)
  718. conection, err := site_service.GetQueryConnection(userOrgID)
  719. fmt.Println("conections是啥",conection)
  720. if err !=nil{
  721. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加乘车方式失败")
  722. return
  723. }
  724. this.ServeSuccessJSON(map[string]interface{}{
  725. "conection":conection,
  726. })
  727. }
  728. //删除联系人
  729. func (this * Microwebsite) DeleteConnecWay() {
  730. adminUserInfo := this.GetAdminUserInfo()
  731. userOrgID := int64(adminUserInfo.CurrentOrgId)
  732. id, _ := this.GetInt64("id")
  733. fmt.Println("id是啥?",id)
  734. err := site_service.DeleteConnecWay(userOrgID, id)
  735. if err !=nil{
  736. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  737. return
  738. }
  739. returnData := make(map[string]interface{}, 0)
  740. returnData["msg"] = "ok"
  741. this.ServeSuccessJSON(returnData)
  742. return
  743. }
  744. //编辑联系人
  745. func (this *Microwebsite) EditConnecWay() {
  746. adminUserInfo := this.GetAdminUserInfo()
  747. id, _ := this.GetInt64("id")
  748. fmt.Println("id是啥?",id)
  749. userOrgID := int64(adminUserInfo.CurrentOrgId)
  750. connection, err := site_service.EditConnecWay(userOrgID, id)
  751. if err !=nil{
  752. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  753. return
  754. }
  755. this.ServeSuccessJSON(map[string]interface{}{
  756. "connection":connection,
  757. })
  758. }
  759. func (this *Microwebsite) SaveConnection() {
  760. adminUserInfo := this.GetAdminUserInfo()
  761. userOrgID := int64(adminUserInfo.CurrentOrgId)
  762. fmt.Println("机构ID",userOrgID)
  763. id, _ := this.GetInt64("id")
  764. fmt.Println("id是啥?",id)
  765. dataBody := make(map[string]interface{}, 0)
  766. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  767. if err != nil {
  768. utils.ErrorLog(err.Error())
  769. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  770. return
  771. }
  772. title := dataBody["title"].(string)
  773. fmt.Println("title",title)
  774. if len(title) == 0 {
  775. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  776. return
  777. }
  778. connecway := int64(dataBody["connecway"].(float64))
  779. fmt.Println("connecway",connecway)
  780. content := dataBody["content"].(string)
  781. fmt.Println("content",content)
  782. if len(content) == 0 {
  783. this.ServeFailJsonSend(enums.ErrorCodeParamWrong,"联系方式不能为空")
  784. return
  785. }
  786. connection := models.SgjPatientConnection{
  787. Title: title,
  788. Connecway: connecway,
  789. Content: content,
  790. }
  791. site_service.UpadateConnec(&connection,userOrgID,id)
  792. this.ServeSuccessJSON(map[string]interface{}{
  793. "connection":connection,
  794. })
  795. }
  796. //新增联系方式
  797. func (this *Microwebsite) AddContract() {
  798. }
  799. func (this *Microwebsite) GetUserdModel() {
  800. adminUserInfo := this.GetAdminUserInfo()
  801. userOrgID := int64(adminUserInfo.CurrentOrgId)
  802. model, err := site_service.GetUserModel(userOrgID)
  803. if err !=nil{
  804. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  805. return
  806. }
  807. fmt.Println("err")
  808. fmt.Println("模型是什么",model)
  809. this.ServeSuccessJSON(map[string]interface{}{
  810. "model":model,
  811. })
  812. }
  813. func (this *Microwebsite) GetQueryNewModel() {
  814. adminUserInfo := this.GetAdminUserInfo()
  815. userOrgID := int64(adminUserInfo.CurrentOrgId)
  816. model, err := site_service.GetQueryNewModel(userOrgID)
  817. fmt.Println("查询新增模块数据是什么?",model)
  818. if err !=nil{
  819. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  820. return
  821. }
  822. fmt.Println("err")
  823. fmt.Println("返回新增模块模型是什么",model)
  824. this.ServeSuccessJSON(map[string]interface{}{
  825. "model":model,
  826. })
  827. }
  828. func (this *Microwebsite) GetEditModel() {
  829. adminUserInfo := this.GetAdminUserInfo()
  830. id, _ := this.GetInt64("id")
  831. fmt.Println("模块id是啥?",id)
  832. userOrgID := int64(adminUserInfo.CurrentOrgId)
  833. connecmodel, err := site_service.GetEditModel(userOrgID, id)
  834. if err !=nil{
  835. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  836. return
  837. }
  838. this.ServeSuccessJSON(map[string]interface{}{
  839. "connecmodel":connecmodel,
  840. })
  841. }
  842. func (this *Microwebsite) EditRideWay() {
  843. adminUserInfo := this.GetAdminUserInfo()
  844. id, _ := this.GetInt64("id")
  845. fmt.Println("模块id是啥?",id)
  846. userOrgID := int64(adminUserInfo.CurrentOrgId)
  847. connecmodel, err := site_service.GetEditModel(userOrgID, id)
  848. if err !=nil{
  849. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  850. return
  851. }
  852. this.ServeSuccessJSON(map[string]interface{}{
  853. "connecmodel":connecmodel,
  854. })
  855. }
  856. //保存编辑后的工作时间
  857. func (this *Microwebsite) SaveWorktTime() {
  858. adminUserInfo := this.GetAdminUserInfo()
  859. id, _ := this.GetInt64("id")
  860. fmt.Println("模块id是啥?",id)
  861. userOrgID := int64(adminUserInfo.CurrentOrgId)
  862. dataBody := make(map[string]interface{}, 0)
  863. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  864. if err != nil {
  865. utils.ErrorLog(err.Error())
  866. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  867. return
  868. }
  869. title := dataBody["title"].(string)
  870. if len(title) == 0 {
  871. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  872. return
  873. }
  874. fmt.Println("姓名:", title)
  875. sort := int64(dataBody["sort"].(float64))
  876. if sort <= 0 {
  877. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  878. return
  879. }
  880. //sortt, err := strconv.ParseInt(sort, 10, 64)
  881. fmt.Println("排序:", sort)
  882. worktime := dataBody["worktime"].(string)
  883. fmt.Println("工作时间",worktime)
  884. if len(worktime) == 0 {
  885. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  886. return
  887. }
  888. connecmodel := models.SgjPatientConnecmodel{
  889. Title: title,
  890. Sort: sort,
  891. Worktime: worktime,
  892. }
  893. site_service.UpdateWorkTime(id,userOrgID,connecmodel);
  894. if err !=nil{
  895. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  896. return
  897. }
  898. this.ServeSuccessJSON(map[string]interface{}{
  899. "connecmodel":connecmodel,
  900. })
  901. }
  902. //保存编辑后的乘车方式
  903. func (this *Microwebsite) Saverideway() {
  904. adminUserInfo := this.GetAdminUserInfo()
  905. id, _ := this.GetInt64("id")
  906. fmt.Println("模块id是啥?",id)
  907. userOrgID := int64(adminUserInfo.CurrentOrgId)
  908. dataBody := make(map[string]interface{}, 0)
  909. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  910. if err != nil {
  911. utils.ErrorLog(err.Error())
  912. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  913. return
  914. }
  915. title := dataBody["title"].(string)
  916. if len(title) == 0 {
  917. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  918. return
  919. }
  920. fmt.Println("标题:", title)
  921. sort := int64(dataBody["sort"].(float64))
  922. if sort <= 0 {
  923. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  924. return
  925. }
  926. //sortt, err := strconv.ParseInt(sort, 10, 64)
  927. fmt.Println("排序:", sort)
  928. rideway := dataBody["rideway"].(string)
  929. fmt.Println("工作时间",rideway)
  930. if len(rideway) == 0 {
  931. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  932. return
  933. }
  934. ridewaymodel := models.SgjPatientConnecmodel{
  935. Title: title,
  936. Sort: sort,
  937. Rideway: rideway,
  938. }
  939. err = site_service.UpdateRideWay(id, userOrgID, ridewaymodel)
  940. fmt.Println("错误是什么?",err)
  941. if err !=nil{
  942. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  943. return
  944. }
  945. this.ServeSuccessJSON(map[string]interface{}{
  946. "ridewaymodel":ridewaymodel,
  947. })
  948. }
  949. //编辑医生信息
  950. func (this *Microwebsite) Editdoctor() {
  951. adminUserInfo := this.GetAdminUserInfo()
  952. id, _ := this.GetInt64("id")
  953. fmt.Println("医生id是啥?",id)
  954. userOrgID := int64(adminUserInfo.CurrentOrgId)
  955. fmt.Println("机构id",userOrgID)
  956. docinfo, err := site_service.EditDoctorInfo(id, userOrgID)
  957. fmt.Println("错误是什么",err)
  958. fmt.Println("docinfo",docinfo)
  959. if err !=nil{
  960. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  961. return
  962. }
  963. this.ServeSuccessJSON(map[string]interface{}{
  964. "docinfo":docinfo,
  965. })
  966. }
  967. func (this *Microwebsite) Change() {
  968. adminUserInfo := this.GetAdminUserInfo()
  969. id, _ := this.GetInt64("id")
  970. fmt.Println("医生id是啥?",id)
  971. userOrgID := int64(adminUserInfo.CurrentOrgId)
  972. fmt.Println("机构id",userOrgID)
  973. docinfo, err := site_service.QueryDocById(userOrgID, id)
  974. if err !=nil{
  975. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  976. return
  977. }
  978. this.ServeSuccessJSON(map[string]interface{}{
  979. "docinfo":docinfo,
  980. })
  981. }
  982. func (this *Microwebsite) SaveDocInfo() {
  983. adminUserInfo := this.GetAdminUserInfo()
  984. id, _ := this.GetInt64("id")
  985. fmt.Println("保存id是啥?",id)
  986. userOrgID := int64(adminUserInfo.CurrentOrgId)
  987. fmt.Println("机构id",userOrgID)
  988. dataBody := make(map[string]interface{}, 0)
  989. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  990. if err != nil {
  991. utils.ErrorLog(err.Error())
  992. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  993. return
  994. }
  995. docname := dataBody["docname"].(string)
  996. if len(docname) == 0 {
  997. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
  998. return
  999. }
  1000. fmt.Println("姓名:",docname)
  1001. docpostion := int64(dataBody["doc_position"].(float64))
  1002. if docpostion < 0 {
  1003. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "职称不能为空")
  1004. return
  1005. }
  1006. fmt.Println("职位",docpostion)
  1007. dochead := dataBody["dochead"].(string)
  1008. if len(dochead) == 0 {
  1009. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "头像不能为空")
  1010. return
  1011. }
  1012. fmt.Println("头像",dochead)
  1013. docsort := int64(dataBody["doc_sort"].(float64))
  1014. if docsort <= 0 {
  1015. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
  1016. return
  1017. }
  1018. fmt.Println("排序",docsort)
  1019. docintroduction := dataBody["docintroduction"].(string)
  1020. if len(docintroduction) == 0 {
  1021. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "头像不能为空")
  1022. return
  1023. }
  1024. fmt.Println("简介",docintroduction)
  1025. doctor := models.SgjPatientDoctor{
  1026. Docname: docname,
  1027. DocPosition: docpostion,
  1028. Dochead: dochead,
  1029. DocSort: docsort,
  1030. Docintroduction: docintroduction,
  1031. }
  1032. err = site_service.UpdateDocInfo(id, userOrgID, doctor)
  1033. if err !=nil{
  1034. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1035. return
  1036. }
  1037. this.ServeSuccessJSON(map[string]interface{}{
  1038. "doctor":doctor,
  1039. })
  1040. }
  1041. func (this *Microwebsite) DeleteDoctor() {
  1042. adminUserInfo := this.GetAdminUserInfo()
  1043. id, _ := this.GetInt64("id")
  1044. fmt.Println("保存id是啥?",id)
  1045. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1046. err := site_service.DeleteDoctor(id, userOrgID)
  1047. if err !=nil{
  1048. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除成功")
  1049. return
  1050. }
  1051. returnData := make(map[string]interface{}, 0)
  1052. returnData["msg"] = "ok"
  1053. this.ServeSuccessJSON(returnData)
  1054. return
  1055. }
  1056. func (this *Microwebsite) EditHospital() {
  1057. adminUserInfo := this.GetAdminUserInfo()
  1058. id, _ := this.GetInt64("id")
  1059. fmt.Println("保存id是啥?",id)
  1060. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1061. hospital, err := site_service.EditHospital(id, userOrgID)
  1062. fmt.Println("参训是什么",hospital)
  1063. fmt.Println(err)
  1064. if err !=nil{
  1065. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1066. return
  1067. }
  1068. this.ServeSuccessJSON(map[string]interface{}{
  1069. "hospital":hospital,
  1070. })
  1071. }
  1072. func (this *Microwebsite) SaveHospital() {
  1073. adminUserInfo := this.GetAdminUserInfo()
  1074. id, _ := this.GetInt64("id")
  1075. fmt.Println("保存id是啥?",id)
  1076. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1077. fmt.Println(userOrgID)
  1078. dataBody := make(map[string]interface{}, 0)
  1079. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1080. if err != nil {
  1081. utils.ErrorLog(err.Error())
  1082. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1083. return
  1084. }
  1085. title := dataBody["title"].(string)
  1086. if len(title) == 0 {
  1087. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  1088. return
  1089. }
  1090. fmt.Println("标题:", title)
  1091. sort := int64(dataBody["sort"].(float64))
  1092. fmt.Println("sort是神",sort)
  1093. if sort <= 0 {
  1094. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  1095. return
  1096. }
  1097. fmt.Println("排序:", sort)
  1098. introduction := dataBody["introduction"].(string)
  1099. if len(introduction) == 0 {
  1100. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  1101. return
  1102. }
  1103. modleid := int64(dataBody["modleid"].(float64))
  1104. if modleid <= 0 {
  1105. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块ID不能为空")
  1106. return
  1107. }
  1108. fmt.Println("模块id",modleid)
  1109. hospital := models.SgjPatientHospital{
  1110. Title: title,
  1111. Sort: sort,
  1112. Introduction: introduction,
  1113. }
  1114. err = site_service.UpdateHospital(id, userOrgID, hospital)
  1115. model := models.SgjPatientModel{
  1116. Title: title,
  1117. Sort: sort,
  1118. }
  1119. fmt.Println(hospital)
  1120. Modelerr := site_service.UpdateModel(modleid, userOrgID, model)
  1121. fmt.Println("错误是什么",Modelerr)
  1122. fmt.Println("错误是什么",err)
  1123. if err !=nil{
  1124. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1125. return
  1126. }
  1127. this.ServeSuccessJSON(map[string]interface{}{
  1128. "hospital":hospital,
  1129. "model":model,
  1130. })
  1131. }
  1132. func (this *Microwebsite) EditOffice() {
  1133. adminUserInfo := this.GetAdminUserInfo()
  1134. id, _ := this.GetInt64("id")
  1135. fmt.Println("保存id是啥?",id)
  1136. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1137. offices, err := site_service.EditOffice(id, userOrgID)
  1138. if err !=nil{
  1139. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1140. return
  1141. }
  1142. this.ServeSuccessJSON(map[string]interface{}{
  1143. "offices":offices,
  1144. })
  1145. }
  1146. func (this *Microwebsite) Deletemodlebyid() {
  1147. adminUserInfo := this.GetAdminUserInfo()
  1148. id, _ := this.GetInt64("id")
  1149. fmt.Println("保存id是啥?",id)
  1150. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1151. err := site_service.DeletemodleById(id, userOrgID)
  1152. modelid := site_service.DeleteHospitalByModelid(id, userOrgID)
  1153. byModelid := site_service.DeleteOfficeByModelid(id, userOrgID)
  1154. fmt.Println(modelid,byModelid)
  1155. if err !=nil{
  1156. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除成功")
  1157. return
  1158. }
  1159. returnData := make(map[string]interface{}, 0)
  1160. returnData["msg"] = "ok"
  1161. this.ServeSuccessJSON(returnData)
  1162. return
  1163. }
  1164. func (this *Microwebsite) SaveOffice() {
  1165. adminUserInfo := this.GetAdminUserInfo()
  1166. id, _ := this.GetInt64("id")
  1167. fmt.Println("科室介绍id是啥?",id)
  1168. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1169. fmt.Println(userOrgID)
  1170. dataBody := make(map[string]interface{}, 0)
  1171. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1172. if err != nil {
  1173. utils.ErrorLog(err.Error())
  1174. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1175. return
  1176. }
  1177. title := dataBody["title"].(string)
  1178. if len(title) == 0 {
  1179. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  1180. return
  1181. }
  1182. fmt.Println("标题:", title)
  1183. sort := int64(dataBody["sort"].(float64))
  1184. fmt.Println("sort是神",sort)
  1185. if sort <= 0 {
  1186. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
  1187. return
  1188. }
  1189. fmt.Println("排序:", sort)
  1190. introduction := dataBody["introduction"].(string)
  1191. if len(introduction) == 0 {
  1192. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
  1193. return
  1194. }
  1195. modleid := int64(dataBody["modleid"].(float64))
  1196. if modleid <= 0 {
  1197. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块ID不能为空")
  1198. return
  1199. }
  1200. fmt.Println("模块ID",modleid)
  1201. offices := models.SgjPatientOffices{
  1202. Title: title,
  1203. Sort: sort,
  1204. Introduction: introduction,
  1205. }
  1206. updateOffices := site_service.UpdateOffices(id, userOrgID, offices)
  1207. model := models.SgjPatientModel{
  1208. Title: title,
  1209. Sort: sort,
  1210. }
  1211. updateModel := site_service.UpdateModel(modleid, userOrgID, model)
  1212. fmt.Println(updateModel)
  1213. if updateOffices !=nil{
  1214. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1215. return
  1216. }
  1217. this.ServeSuccessJSON(map[string]interface{}{
  1218. "offices":offices,
  1219. "model":model,
  1220. })
  1221. }
  1222. func (this *Microwebsite) GetHospital() {
  1223. adminUserInfo := this.GetAdminUserInfo()
  1224. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1225. hostital, err := site_service.GetHospital(userOrgID)
  1226. if err !=nil{
  1227. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1228. return
  1229. }
  1230. this.ServeSuccessJSON(map[string]interface{}{
  1231. "hostital":hostital,
  1232. })
  1233. }
  1234. func (this *Microwebsite) GetData() {
  1235. adminUserInfo := this.GetAdminUserInfo()
  1236. userOrgID := int64(adminUserInfo.CurrentOrgId)
  1237. fmt.Println("机构ID" ,userOrgID)
  1238. model, err := site_service.GetData(userOrgID)
  1239. fmt.Println("错误是什么",err)
  1240. if err !=nil{
  1241. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1242. return
  1243. }
  1244. this.ServeSuccessJSON(map[string]interface{}{
  1245. "patientModels":model,
  1246. })
  1247. }