|
@@ -2,6 +2,7 @@ package controllers
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "fmt"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"hongze/hongze_web_mfyx/models"
|
|
|
"hongze/hongze_web_mfyx/services"
|
|
@@ -1312,6 +1313,185 @@ func (this *YanxuanSpecialController) Check() {
|
|
|
br.Msg = "校验成功"
|
|
|
}
|
|
|
|
|
|
+// @Title 专栏文章点赞/取消点赞
|
|
|
+// @Description 专栏文章点赞/取消点赞接口
|
|
|
+// @Param request body models.TopCygxYanxuanSpecialMessageReq true "type json string"
|
|
|
+// @Success Ret=200 {object}
|
|
|
+// @router /like [post]
|
|
|
+func (this *YanxuanSpecialController) Like() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,用户信息为空"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var req models.LikeCygxYanxuanSpecialSpecialLikeReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ yanxuanSpecialId := req.YanxuanSpecialId
|
|
|
+ doType := req.DoType
|
|
|
+ userId := user.UserId
|
|
|
+ // 研选专栏
|
|
|
+ yanxuanSpecialBySpeciaDetail, err := models.GetYanxuanSpecialBySpecialId(yanxuanSpecialId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ total, err := models.GetCygxYanxuanSpecialSpecialLikeCountByUidYid(userId, yanxuanSpecialId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败!"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("total", total)
|
|
|
+ if doType == 1 {
|
|
|
+ if total == 0 {
|
|
|
+ item := new(models.CygxYanxuanSpecialSpecialLike)
|
|
|
+ item.UserId = userId
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.YanxuanSpecialId = yanxuanSpecialId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ item.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+ err = models.AddCygxCygxYanxuanSpecialSpecialLike(item, yanxuanSpecialBySpeciaDetail.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "点赞失败!"
|
|
|
+ br.ErrMsg = "点赞失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if total > 0 {
|
|
|
+ err = models.DeleteCygxYanxuanSpecialSpecialLike(userId, yanxuanSpecialId, yanxuanSpecialBySpeciaDetail.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "点赞失败!"
|
|
|
+ br.ErrMsg = "点赞失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 作者粉丝列表
|
|
|
+// @Description 作者粉丝列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Success 200 {object} models.AddEnglishReportResp
|
|
|
+// @router /author/fans_list [get]
|
|
|
+func (this *YanxuanSpecialController) FanList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,用户信息为空"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+ resp := new(models.CygxYanxuanSpecialFollowListResp)
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = " AND follow_user_id = ? "
|
|
|
+ pars = append(pars, user.UserId)
|
|
|
+ //作者粉丝数量
|
|
|
+ total, err := models.GetCygxYanxuanSpecialFollowCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败!"
|
|
|
+ br.ErrMsg = "获取信息失败,GetCygxYanxuanSpecialFollowCountErr:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ condition += " ORDER BY cygx_yanxuan_special_follow_id DESC "
|
|
|
+ list, err := models.GetCygxYanxuanSpecialFollowList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败!"
|
|
|
+ br.ErrMsg = "获取信息失败,GetCygxYanxuanSpecialFollowList:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(list) > 0 {
|
|
|
+ var userIds []int
|
|
|
+ for _, v := range list {
|
|
|
+ userIds = append(userIds, v.UserId)
|
|
|
+ }
|
|
|
+ //用户头像
|
|
|
+ listUser, err := models.GetWxUserListByUserIdsArr(userIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapUserImg := make(map[int]string)
|
|
|
+ for _, v := range listUser {
|
|
|
+ if v.Headimgurl != "" {
|
|
|
+ mapUserImg[v.UserId] = v.Headimgurl
|
|
|
+ } else {
|
|
|
+ mapUserImg[v.UserId] = utils.DefaultHeadimgurl
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range list {
|
|
|
+ item := new(models.CygxYanxuanSpecialFollowResp)
|
|
|
+ if v.CompanyName != "" {
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ } else {
|
|
|
+ item.CompanyName = "潜在客户"
|
|
|
+ }
|
|
|
+ if v.RealName != "" {
|
|
|
+ item.RealName = v.RealName
|
|
|
+ } else {
|
|
|
+ item.RealName = "--"
|
|
|
+ }
|
|
|
+ item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
|
|
|
+ item.Headimgurl = mapUserImg[v.UserId]
|
|
|
+ resp.List = append(resp.List, item)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ resp.List = make([]*models.CygxYanxuanSpecialFollowResp, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.Paging = page
|
|
|
+ br.Data = resp
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
//留言
|
|
|
//点赞
|
|
|
//列表
|