|
@@ -93,7 +93,7 @@ func (this *MyReportController) Collect() {
|
|
br.Msg = "用户没有权限收藏"
|
|
br.Msg = "用户没有权限收藏"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- count, err := models.GetMyReportByUserIdAndReportId(user.UserId, req.ReportId)
|
|
|
|
|
|
+ count, err := models.GetMyReportCountByUserIdAndReportId(user.UserId, req.ReportId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "收藏失败"
|
|
br.Msg = "收藏失败"
|
|
br.ErrMsg = "查询收藏数量失败,Err:" + err.Error()
|
|
br.ErrMsg = "查询收藏数量失败,Err:" + err.Error()
|
|
@@ -167,7 +167,7 @@ func (this *MyReportController) CollectCancel() {
|
|
br.Msg = "用户没有权限收藏"
|
|
br.Msg = "用户没有权限收藏"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- count, err := models.GetMyReportByUserIdAndReportId(user.UserId, req.ReportId)
|
|
|
|
|
|
+ count, err := models.GetMyReportCountByUserIdAndReportId(user.UserId, req.ReportId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "取消收藏失败"
|
|
br.Msg = "取消收藏失败"
|
|
br.ErrMsg = "获取收藏信息失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取收藏信息失败,Err:" + err.Error()
|
|
@@ -188,3 +188,45 @@ func (this *MyReportController) CollectCancel() {
|
|
br.Success = true
|
|
br.Success = true
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// @Title 是否收藏研报
|
|
|
|
+// @Description 是否收藏研报
|
|
|
|
+// @Param request body request.MyReportCollectReq true "type json string"
|
|
|
|
+// @Success 200 {object} models.BaseResponse
|
|
|
|
+// @router /isCollect [post]
|
|
|
|
+func (this *MyReportController) IsCollect() {
|
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
|
+ defer func() {
|
|
|
|
+ this.Data["json"] = br
|
|
|
|
+ this.ServeJSON()
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ var req request.MyReportCollectReq
|
|
|
|
+ if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
|
|
|
|
+ br.Msg = "参数解析失败"
|
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ user := this.User
|
|
|
|
+ if user.Status != 2 {
|
|
|
|
+ br.Msg = "用户没有权限收藏"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ count, err := models.GetMyReportCountByUserIdAndReportId(user.UserId, req.ReportId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "收藏失败"
|
|
|
|
+ br.ErrMsg = "查询收藏数量失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ resp := new(response.MyReportIsCollectResp)
|
|
|
|
+ if count > 0 {
|
|
|
|
+ resp.IsCollect = true
|
|
|
|
+ } else {
|
|
|
|
+ resp.IsCollect = false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ br.Data = resp
|
|
|
|
+ br.Msg = "收藏成功"
|
|
|
|
+ br.Success = true
|
|
|
|
+ br.Ret = 200
|
|
|
|
+}
|