scrm-go

micro_controller.go 11KB

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