Browse Source

fix:添加report接口

zqbao 9 months ago
parent
commit
dcaf49bfb1
3 changed files with 63 additions and 1 deletions
  1. 52 0
      controllers/report.go
  2. 9 0
      routers/commentsRouter.go
  3. 2 1
      utils/constants.go

+ 52 - 0
controllers/report.go

@@ -308,6 +308,58 @@ func (this *ReportController) Detail() {
 	br.Msg = "获取成功"
 }
 
+// @Title 研报详情
+// @Description 研报详情接口
+// @Param   ReportId   query   int  true       "报告id"
+// @Success 200 {object} models.ReportDetailResp
+// @router /detail/noUser [get]
+func (this *ReportController) DetailNoUser() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	reportId, err := this.GetInt("ReportId")
+	if err != nil {
+		br.Msg = "参数获取失败"
+		br.ErrMsg = "参数获取失败,Err:" + err.Error()
+		return
+	}
+	if reportId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,报告id小于等于0"
+		return
+	}
+
+	report, err := models.GetReportById(reportId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Ret = 200
+			br.Data = new(response.ReportDetailResp)
+			br.Success = true
+			br.Msg = "该报告已删除或不存在"
+			return
+		}
+		br.Msg = "该报告已删除"
+		br.ErrMsg = "获取报告详情失败,Err:" + err.Error()
+		return
+	}
+	report.ContentSub = html.UnescapeString(report.ContentSub)
+	report.Content = ""
+	if report == nil {
+		br.Msg = "报告不存在"
+		return
+	}
+	resp := new(response.ReportDetailResp)
+	resp.Report = report
+	resp.Status = utils.ReportPermissionStatusNoUser
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
 // @Title List
 // @Description create users
 // @Param	body		body 	models.User	true		"body for user content"

+ 9 - 0
routers/commentsRouter.go

@@ -97,6 +97,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ReportController"] = append(beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "DetailNoUser",
+            Router: `/detail/noUser`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ReportController"] = append(beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ReportController"],
         beego.ControllerComments{
             Method: "List",

+ 2 - 1
utils/constants.go

@@ -21,11 +21,12 @@ const (
 	ReportPermissionStatusNoPermission = 2 //没有该品种权限
 	ReportPermissionStatusNo           = 3 //没有权限
 	ReportPermissionStatusHas          = 4 //有该品种权限
+	ReportPermissionStatusNoUser       = 5 //没有获得用户信息
 )
 
 // 缓存key
 const (
-	CACHE_WX_ACCESS_TOKEN_HZ = "wx:accesstoken:dw" //东吴公众号 微信accessToken
+	CACHE_WX_ACCESS_TOKEN_DW = "wx:accesstoken:dw" //东吴公众号 微信accessToken
 )
 const (
 	APPNAME = "东吴小程序桥接服务"