home.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package controllers
  2. import (
  3. "hongze/hongze_api/models"
  4. "hongze/hongze_api/services"
  5. )
  6. //首页
  7. type HomeController struct {
  8. BaseAuthController
  9. }
  10. type HomeCommonController struct {
  11. BaseCommonController
  12. }
  13. // @Title 首页列表接口
  14. // @Description 首页列表接口
  15. // @Success 200 {object} models.HomeList
  16. // @router /list [get]
  17. func (this *HomeController) ListHome() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. user := this.User
  24. if user == nil {
  25. br.Msg = "请登录"
  26. br.ErrMsg = "请登录,用户信息为空"
  27. br.Ret = 408
  28. return
  29. }
  30. list, err := services.HomeList(user.UserId, user.CompanyId)
  31. if err != nil {
  32. br.Msg = "获取数据失败"
  33. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  34. return
  35. }
  36. for i := 0; i < len(list); i++ {
  37. item := list[i]
  38. for k := 0; k < len(item.Child); k++ {
  39. if item.ClassifyName == "权益研报" {
  40. if item.Child[k].Child.ClassifyNameSecond == "近期路演精华" {
  41. list[i].Child[k].TitleType = "路演精华"
  42. } else {
  43. list[i].Child[k].TitleType = "权益"
  44. }
  45. } else {
  46. list[i].Child[k].TitleType = "FICC"
  47. }
  48. }
  49. }
  50. br.Ret = 200
  51. br.Success = true
  52. br.Msg = "获取数据成功"
  53. br.Data = list
  54. }
  55. // @Title 首页列表接口
  56. // @Description 首页列表接口
  57. // @Success 200 {object} models.Banner
  58. // @router /banner [get]
  59. func (this *HomeController) ListBanner() {
  60. br := new(models.BaseResponse).Init()
  61. defer func() {
  62. this.Data["json"] = br
  63. this.ServeJSON()
  64. }()
  65. list, err := models.GetHomeBannerList("")
  66. if err != nil {
  67. br.Msg = "获取数据失败"
  68. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  69. return
  70. }
  71. br.Ret = 200
  72. br.Success = true
  73. br.Msg = "获取数据成功"
  74. br.Data = list
  75. }