|
@@ -311,10 +311,10 @@ func (this *MicroRoadShowController) CommentAdd() {
|
|
|
|
|
|
// @Title 收藏
|
|
|
// @Description 收藏
|
|
|
-// @Param request body models.ArticleCollectReq true "type json string"
|
|
|
+// @Param request body models.MicroRoadshowCollectReq true "type json string"
|
|
|
// @Success 200 {object} models.FontsCollectResp
|
|
|
// @router /collect [post]
|
|
|
-func (this *ArticleController) Collect() {
|
|
|
+func (this *MicroRoadShowController) Collect() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -327,65 +327,122 @@ func (this *ArticleController) Collect() {
|
|
|
return
|
|
|
}
|
|
|
uid := user.UserId
|
|
|
- var req models.ArticleCollectReq
|
|
|
+ var req models.MicroRoadshowCollectReq
|
|
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
|
br.Msg = "参数解析异常!"
|
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- articleId := req.ArticleId
|
|
|
- detail, err := models.GetArticleDetailById(articleId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- count, err := models.GetArticleCollectCount(uid, articleId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取数据失败!"
|
|
|
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- resp := new(models.ArticleCollectResp)
|
|
|
- if count <= 0 {
|
|
|
- item := new(models.CygxArticleCollect)
|
|
|
- item.ArticleId = req.ArticleId
|
|
|
- item.UserId = uid
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.Mobile = user.Mobile
|
|
|
- item.Email = user.Email
|
|
|
- item.CompanyId = user.CompanyId
|
|
|
- item.CompanyName = user.CompanyName
|
|
|
- item.RealName = user.RealName
|
|
|
- _, err = models.AddCygxArticleCollect(item)
|
|
|
+
|
|
|
+ if req.SourceType == 1 {
|
|
|
+ _, err := models.GetCygxActivityVoiceById(req.Id)
|
|
|
if err != nil {
|
|
|
- br.Msg = "收藏失败"
|
|
|
- br.ErrMsg = "收藏失败,Err:" + err.Error()
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- br.Msg = "收藏成功"
|
|
|
- resp.Status = 1
|
|
|
- // 文章收藏消息发送
|
|
|
- go services.ArticleUserRemind(user, detail, 2)
|
|
|
- } else {
|
|
|
- err = models.RemoveArticleCollect(uid, articleId)
|
|
|
+ count, err := models.GetVoiceCollectCount(uid, req.Id)
|
|
|
if err != nil {
|
|
|
- br.Msg = "取消收藏失败"
|
|
|
- br.ErrMsg = "取消收藏失败,Err:" + err.Error()
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- br.Msg = "已取消收藏"
|
|
|
- resp.Status = 2
|
|
|
- }
|
|
|
- collectTotal, err := models.GetArticleCollectUsersCount(articleId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取数据失败"
|
|
|
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ resp := new(models.ArticleCollectResp)
|
|
|
+ if count <= 0 {
|
|
|
+ item := new(models.CygxArticleCollect)
|
|
|
+ item.ArticleId = req.Id
|
|
|
+ item.UserId = uid
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ _, err = models.AddCygxArticleCollect(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "收藏失败"
|
|
|
+ br.ErrMsg = "收藏失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = "收藏成功"
|
|
|
+ resp.Status = 1
|
|
|
+ // 文章收藏消息发送
|
|
|
+ //go services.ArticleUserRemind(user, detail, 2)
|
|
|
+ } else {
|
|
|
+ err = models.RemoveVoiceCollect(uid, req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "取消收藏失败"
|
|
|
+ br.ErrMsg = "取消收藏失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = "已取消收藏"
|
|
|
+ resp.Status = 2
|
|
|
+ }
|
|
|
+ collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.CollectCount = collectTotal
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = resp
|
|
|
+ } else if req.SourceType == 2 {
|
|
|
+ _, err := models.GetMicroRoadshowVideoById(req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ count, err := models.GetVideoCollectCount(uid, req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.ArticleCollectResp)
|
|
|
+ if count <= 0 {
|
|
|
+ item := new(models.CygxArticleCollect)
|
|
|
+ item.VideoId = req.Id
|
|
|
+ item.UserId = uid
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.Title = req.Title
|
|
|
+ _, err = models.AddCygxArticleCollect(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "收藏失败"
|
|
|
+ br.ErrMsg = "收藏失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = "收藏成功"
|
|
|
+ resp.Status = 1
|
|
|
+ // 文章收藏消息发送
|
|
|
+ //go services.ArticleUserRemind(user, detail, 2)
|
|
|
+ } else {
|
|
|
+ err = models.RemoveVideoCollect(uid, req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "取消收藏失败"
|
|
|
+ br.ErrMsg = "取消收藏失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = "已取消收藏"
|
|
|
+ resp.Status = 2
|
|
|
+ }
|
|
|
+ collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.CollectCount = collectTotal
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = resp
|
|
|
}
|
|
|
- resp.CollectCount = collectTotal
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Data = resp
|
|
|
}
|