micro_controller.go 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. package micro
  2. import (
  3. "SCRM/enums"
  4. "SCRM/service/micro_service"
  5. "fmt"
  6. "github.com/astaxie/beego"
  7. )
  8. func microRouters() {
  9. beego.Router("/api/site/getdatabyorgid", &Micro{}, "Get:GetDataByOrgId")
  10. beego.Router("/api/site/getdatatwo", &Micro{}, "Get:GetDatatwo")
  11. beego.Router("/api/site/getdatathree", &Micro{}, "Get:GetOfficeDetail")
  12. beego.Router("/api/site/getdatafour", &Micro{}, "Get:GetDoctorDetail")
  13. beego.Router("/api/site/getdatafive", &Micro{}, "Get:GetOfficEnviromentDetail")
  14. beego.Router("/api/site/getarticlelist", &Micro{}, "Get:GetArticlelist")
  15. beego.Router("/api/site/getactivities", &Micro{}, "Get:GetActivities")
  16. beego.Router("/api/site/getdatasix", &Micro{}, "Get:GetArticlistDetail")
  17. beego.Router("/api/site/getdataseven", &Micro{}, "Get:GetActivitesDetail")
  18. beego.Router("/api/site/getdefalutnavigationdata", &Micro{}, "Get:GetDefalutNavigationData")
  19. beego.Router("/api/site/getdataeight", &Micro{}, "Get:GetOrderData")
  20. beego.Router("/api/site/getdatanight", &Micro{}, "Get:GetContactWay")
  21. beego.Router("/api/site/singleactivitinfo", &Micro{}, "Get:GetActivitDetail")
  22. beego.Router("/api/site/singlearticleinfo", &Micro{}, "Get:GetArticlesDetail")
  23. beego.Router("/api/site/singledoctorinfo", &Micro{}, "Get:GetDoctorInfo")
  24. beego.Router("/api/site/getdata", &Micro{}, "Get:GetData")
  25. beego.Router("/api/site/getenviromentimages", &Micro{}, "Get:GetEnviromentImages")
  26. beego.Router("/api/site/getalldoctors", &Micro{}, "Get:GetAllDoctors")
  27. }
  28. type Micro struct {
  29. beego.Controller
  30. //controllers.BaseAPIController
  31. }
  32. func (this *Micro) ServeFailJsonSend(code int, msg string) {
  33. this.Data["json"] = enums.MakeFailResponseJSON(msg, code)
  34. this.ServeJSON()
  35. }
  36. func (this *Micro) ServeSuccessJSON(data map[string]interface{}) {
  37. this.Data["json"] = enums.MakeSuccessResponseJSON(data)
  38. this.ServeJSON()
  39. }
  40. func (this *Micro) GetDataByOrgId() {
  41. fmt.Println("我的 ")
  42. orgid, _ := this.GetInt64("orgid")
  43. fmt.Println("小明id", orgid)
  44. model, err := micro_service.GetData(orgid)
  45. fmt.Println("model是什么", model)
  46. fmt.Println("err", err)
  47. if err != nil {
  48. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  49. return
  50. }
  51. this.ServeSuccessJSON(map[string]interface{}{
  52. "patientModels": model,
  53. })
  54. }
  55. func (this *Micro) GetData() {
  56. // fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
  57. fmt.Println("我的 ")
  58. orgid, _ := this.GetInt64("orgid")
  59. fmt.Println("小明id", orgid)
  60. model, err := micro_service.GetData(orgid)
  61. fmt.Println("model是什么", model)
  62. fmt.Println("err", err)
  63. if err != nil {
  64. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  65. return
  66. }
  67. this.ServeSuccessJSON(map[string]interface{}{
  68. "patientModels": model,
  69. })
  70. }
  71. func (this *Micro) GetDatatwo() {
  72. fmt.Println("获取医院详情")
  73. id, err := this.GetInt64("id")
  74. fmt.Println(err)
  75. fmt.Println("id是什么", id)
  76. orgid, _ := this.GetInt64("orgid")
  77. fmt.Println("机构id", orgid)
  78. hospital, err := micro_service.QueryHispitalDetail(orgid, id)
  79. if err != nil {
  80. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  81. return
  82. }
  83. this.ServeSuccessJSON(map[string]interface{}{
  84. "hospital": hospital,
  85. })
  86. }
  87. func (this *Micro) GetOfficeDetail() {
  88. id, err := this.GetInt64("id")
  89. fmt.Println(err)
  90. fmt.Println("id是什么", id)
  91. orgid, _ := this.GetInt64("orgid")
  92. fmt.Println("机构id", orgid)
  93. offices, err := micro_service.GetOfficeDetail(orgid, id)
  94. if err != nil {
  95. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  96. return
  97. }
  98. this.ServeSuccessJSON(map[string]interface{}{
  99. "offices": offices,
  100. })
  101. }
  102. func (this *Micro) GetDoctorDetail() {
  103. id, err := this.GetInt64("id")
  104. fmt.Println(err)
  105. fmt.Println("id是什么", id)
  106. orgid, _ := this.GetInt64("orgid")
  107. fmt.Println("机构id", orgid)
  108. editdoctor, err := micro_service.GetDoctorDetail(orgid, id)
  109. if err != nil {
  110. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  111. return
  112. }
  113. this.ServeSuccessJSON(map[string]interface{}{
  114. "editdoctor": editdoctor,
  115. })
  116. }
  117. func (this *Micro) GetOfficEnviromentDetail() {
  118. id, err := this.GetInt64("id")
  119. fmt.Println(err)
  120. fmt.Println("id是什么", id)
  121. orgid, _ := this.GetInt64("orgid")
  122. fmt.Println("机构id", orgid)
  123. offenvironment, err := micro_service.GetOfficEnviromentDetail(orgid, id)
  124. fmt.Println("错误", err)
  125. fmt.Println("offenvironment", offenvironment)
  126. if err != nil {
  127. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  128. return
  129. }
  130. this.ServeSuccessJSON(map[string]interface{}{
  131. "offenvironment": offenvironment,
  132. })
  133. }
  134. func (this *Micro) GetArticlelist() {
  135. //adminUserInfo := this.GetAdminUserInfo()
  136. //userOrgID := int64(adminUserInfo.CurrentOrgId)
  137. //fmt.Println("机构id",userOrgID)
  138. orgid, _ := this.GetInt64("orgid")
  139. //micro_service.GetArticlelistlimit(orgid)
  140. articlelist, err := micro_service.GetlastLimit(orgid)
  141. articlelists, err := micro_service.GetAllArticeList(orgid, articlelist.Number)
  142. fmt.Println("文章列表", articlelists)
  143. fmt.Println("错误", err)
  144. if err != nil {
  145. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更改数据失败")
  146. return
  147. }
  148. this.ServeSuccessJSON(map[string]interface{}{
  149. "articlelists": articlelists,
  150. })
  151. }
  152. func (this *Micro) GetActivities() {
  153. orgid, _ := this.GetInt64("orgid")
  154. fmt.Println("活动id", orgid)
  155. //addactivity, err := micro_service.GetActivitiesById(orgid)
  156. addactivity, err := micro_service.GetLastActivitiesLast(orgid)
  157. activity, err := micro_service.GetAllActivities(orgid, addactivity.Number)
  158. if err != nil {
  159. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更改数据失败")
  160. return
  161. }
  162. this.ServeSuccessJSON(map[string]interface{}{
  163. "activity": activity,
  164. })
  165. }
  166. func (this *Micro) GetArticlistDetail() {
  167. id, _ := this.GetInt64("id")
  168. fmt.Println("id是设么", id)
  169. orgid, _ := this.GetInt64("orgid")
  170. fmt.Println("文章id", orgid)
  171. articlelist, err := micro_service.GetArticlelistById(id, orgid)
  172. fmt.Println(articlelist, err)
  173. //fmt.Println(err)
  174. //articlelists, err := micro_service.GetAllArticles(orgid, articlelist.Number)
  175. articleslist, err := micro_service.GetAllPushArticles(orgid)
  176. fmt.Println("报错了么", err)
  177. if err != nil {
  178. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  179. return
  180. }
  181. this.ServeSuccessJSON(map[string]interface{}{
  182. "articlelists": articleslist,
  183. })
  184. }
  185. func (this *Micro) GetActivitesDetail() {
  186. id, _ := this.GetInt64("id")
  187. fmt.Println("id是设么", id)
  188. orgid, _ := this.GetInt64("orgid")
  189. fmt.Println("活动id", orgid)
  190. //addactivity, err := micro_service.GetAllActivitiById(id, orgid)
  191. // fmt.Println("err",err)
  192. //addactivity, err := micro_service.GetLastActivitiesLast(orgid)
  193. // //activity, err := micro_service.GetAllActivities(orgid,addactivity.Number)
  194. activity, err := micro_service.GetAllActivitiestwo(orgid)
  195. if err != nil {
  196. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  197. return
  198. }
  199. this.ServeSuccessJSON(map[string]interface{}{
  200. "activity": activity,
  201. })
  202. }
  203. func (this *Micro) GetDefalutNavigationData() {
  204. orgid, _ := this.GetInt64("orgid")
  205. fmt.Println("活动id", orgid)
  206. navigation, err := micro_service.GetDefalutNavigationData(orgid)
  207. if err != nil {
  208. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  209. return
  210. }
  211. this.ServeSuccessJSON(map[string]interface{}{
  212. "navigation": navigation,
  213. })
  214. }
  215. func (this *Micro) GetOrderData() {
  216. orgid, _ := this.GetInt64("orgid")
  217. fmt.Println("活动id", orgid)
  218. ordmodel, err := micro_service.GetOrederModel(orgid)
  219. fmt.Println("ordemodel是社没什么", ordmodel)
  220. if err != nil {
  221. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  222. return
  223. }
  224. this.ServeSuccessJSON(map[string]interface{}{
  225. "ordmodel": ordmodel,
  226. })
  227. }
  228. func (this *Micro) GetContactWay() {
  229. orgid, _ := this.GetInt64("orgid")
  230. fmt.Println("联系方式id", orgid)
  231. connect, err := micro_service.GetAllConnecway(orgid)
  232. if err != nil {
  233. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  234. return
  235. }
  236. this.ServeSuccessJSON(map[string]interface{}{
  237. "connect": connect,
  238. })
  239. }
  240. func (this *Micro) GetActivitDetail() {
  241. id, _ := this.GetInt64("id")
  242. fmt.Println("活动id", id)
  243. orgid, _ := this.GetInt64("orgid")
  244. fmt.Println("机构id", orgid)
  245. activity, err := micro_service.GetActivitDetail(id, orgid)
  246. if err != nil {
  247. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  248. return
  249. }
  250. this.ServeSuccessJSON(map[string]interface{}{
  251. "activity": activity,
  252. })
  253. }
  254. func (this *Micro) GetArticlesDetail() {
  255. id, _ := this.GetInt64("id")
  256. fmt.Println("文章id", id)
  257. orgid, _ := this.GetInt64("orgid")
  258. fmt.Println("机构id", orgid)
  259. articles, err := micro_service.GetArticlesDetail(id, orgid)
  260. if err != nil {
  261. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  262. return
  263. }
  264. this.ServeSuccessJSON(map[string]interface{}{
  265. "articles": articles,
  266. })
  267. }
  268. func (this *Micro) GetDoctorInfo() {
  269. id, _ := this.GetInt64("id")
  270. fmt.Println("医生id", id)
  271. orgid, _ := this.GetInt64("orgid")
  272. fmt.Println("机构id", orgid)
  273. editdoctor, err := micro_service.GetDoctorInfo(id, orgid)
  274. fmt.Println("错误", err)
  275. fmt.Println("editdoctor", editdoctor)
  276. if err != nil {
  277. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  278. return
  279. }
  280. this.ServeSuccessJSON(map[string]interface{}{
  281. "editdoctor": editdoctor,
  282. })
  283. }
  284. func (this *Micro) GetRotationLinkAddress() {
  285. linkid, _ := this.GetInt64("linkid")
  286. fmt.Println("linkid", linkid)
  287. orgid, _ := this.GetInt64("orgid")
  288. fmt.Println("机构id", orgid)
  289. linkaddress, err := micro_service.GetRotationLinkAddress(orgid, linkid)
  290. fmt.Println("错误是什么", err)
  291. if err != nil {
  292. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  293. return
  294. }
  295. this.ServeSuccessJSON(map[string]interface{}{
  296. "linkaddress": linkaddress,
  297. })
  298. }
  299. func (this *Micro) GetEnviromentImages() {
  300. id, _ := this.GetInt64("id")
  301. fmt.Println("id是设么", id)
  302. orgid, _ := this.GetInt64("orgid")
  303. enviro, err := micro_service.GetEnviromentImages(id, orgid)
  304. if err != nil {
  305. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  306. return
  307. }
  308. this.ServeSuccessJSON(map[string]interface{}{
  309. "enviro": enviro,
  310. })
  311. }
  312. func (this *Micro) GetAllDoctors() {
  313. orgid, _ := this.GetInt64("orgid")
  314. fmt.Println("orgid失身东西", orgid)
  315. info, err := micro_service.GetAllDoctors(orgid)
  316. fmt.Println("info是什么", info)
  317. fmt.Println("err是什么", err)
  318. if err != nil {
  319. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  320. return
  321. }
  322. this.ServeSuccessJSON(map[string]interface{}{
  323. "info": info,
  324. })
  325. }