|
@@ -0,0 +1,150 @@
|
|
|
+package pc
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
+ "hongze/hongze_yb/controller/response"
|
|
|
+ models "hongze/hongze_yb/models/response/pc"
|
|
|
+ "hongze/hongze_yb/models/tables/rddp/banner"
|
|
|
+ "hongze/hongze_yb/models/tables/rddp/classify"
|
|
|
+ "hongze/hongze_yb/models/tables/rddp/report"
|
|
|
+ "hongze/hongze_yb/services/pc"
|
|
|
+ userService "hongze/hongze_yb/services/user"
|
|
|
+ "strconv"
|
|
|
+)
|
|
|
+
|
|
|
+// Banner 首页banner图
|
|
|
+func Banner(c *gin.Context) {
|
|
|
+ banner,err := banner.GetHomeBannerList()
|
|
|
+ if err != nil {
|
|
|
+ response.Fail(err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("查询成功", banner, c )
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// LatestRelease 上新公告
|
|
|
+func LatestRelease(c *gin.Context) {
|
|
|
+ classifyIdString := c.DefaultQuery("ClassifyId","")
|
|
|
+ if classifyIdString == "" {
|
|
|
+ response.Fail("请输入classifyId", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ classifyId, err := strconv.Atoi(classifyIdString)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("请输入正确classifyId", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyInfo, err := classify.GetByClassifyId(classifyId)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("分类查询出错", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ response.OkData("查询成功", classifyInfo, c )
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ClassifyDetail 专栏详情
|
|
|
+func ClassifyDetail(c *gin.Context) {
|
|
|
+ reqClassifyIdSecond := c.DefaultQuery("classify_id_second", "")
|
|
|
+ if reqClassifyIdSecond == "" {
|
|
|
+ response.Fail("请输入二级分类标识", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ classifyIdSecond, err := strconv.Atoi(reqClassifyIdSecond)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("请输入正确的二级分类标识", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userinfo := userService.GetInfoByClaims(c)
|
|
|
+
|
|
|
+ detail, err := pc.GetClassifyDetail(userinfo, classifyIdSecond)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail(err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("查询成功", detail, c )
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ClassifyDetailBanner 专栏详情banner图
|
|
|
+func ClassifyDetailBanner(c *gin.Context) {
|
|
|
+ reqReportId := c.DefaultQuery("reportId", "")
|
|
|
+ if reqReportId == "" {
|
|
|
+ response.Fail("请输入二级分类标识", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportId, err := strconv.Atoi(reqReportId)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("报告ID格式有误", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportInfo, err := report.GetByReportId(reportId)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("报告查询出错", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if reportInfo.Id == 0 {
|
|
|
+ response.Fail("报告不存在", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if reportInfo.State != 2 {
|
|
|
+ response.Fail("报告未发布", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ classifyInfo, err := classify.GetByClassifyId(reportInfo.ClassifyIdSecond)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("分类查询出错", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("查询成功", classifyInfo, c )
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// Recommend 专栏详情页更多推荐
|
|
|
+func Recommend(c *gin.Context) {
|
|
|
+ reqReportId := c.DefaultQuery("reportId", "")
|
|
|
+ if reqReportId == "" {
|
|
|
+ response.Fail("请输入二级分类标识", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportId, err := strconv.Atoi(reqReportId)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("报告ID格式有误", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportInfo, err := report.GetByReportId(reportId)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("报告查询出错", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if reportInfo.Id == 0 {
|
|
|
+ response.Fail("报告不存在", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if reportInfo.State != 2 {
|
|
|
+ response.Fail("报告未发布", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ reportType := 0
|
|
|
+ if reportInfo.ClassifyNameFirst == "权益研报" {
|
|
|
+ reportType = 1
|
|
|
+ } else {
|
|
|
+ reportType = 2
|
|
|
+ }
|
|
|
+ recommendList, err := models.GetRecommendList(reportId, reportType)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("获取报告详情失败"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ response.OkData("查询成功", recommendList, c )
|
|
|
+ return
|
|
|
+}
|