package friend_circle import ( "applet/app/e" "applet/app/md/friend_circles" "applet/app/svc" svc2 "applet/app/svc/friend_circle" "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" "fmt" "github.com/gin-gonic/gin" "strconv" "time" ) // MySelfList // @Summary 通用请求-对象存储-上传许可链接(获取) // @Tags 对象存储 // @Description 上传许可链接(获取) // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Param req body friend_circles.MySelfListReq true "签名上传url" // @Success 200 {object} friend_circles.MySelfListResp "返回数据" // @Failure 400 {object} md.Response "具体错误" // @Router /api/v1/comm/getOssUrl [POST] func MySelfList(c *gin.Context) { var args friend_circles.MySelfListReq err := c.ShouldBindJSON(&args) if err != nil { err = svc.HandleValidateErr(err) err1 := err.(e.E) e.OutErr(c, err1.Code, err1.Error()) return } resp, err := svc2.MySelfList(c, args) if err != nil { e.OutErr(c, e.ERR, err.Error()) return } e.OutSuc(c, resp, nil) } // IsCanPublish // @Summary 朋友圈-是否可以发布朋友圈 // @Tags 朋友圈 // @Description 是否可以发布朋友圈 // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Success 200 {string} "success" // @Failure 400 {object} md.Response "具体错误" // @Router /api/v1/circleFriends/isCanPublish [GET] func IsCanPublish(c *gin.Context) { isCan, err := svc2.IsCanPublish(c) if err != nil { fmt.Println("IsPublish:::::", err.Error()) } resp := friend_circles.IsCanCommentResp{IsCan: isCan} e.OutSuc(c, resp, nil) } // Publish // @Summary 朋友圈-发布朋友圈 // @Tags 朋友圈 // @Description 发布朋友圈 // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Param req body comm.PublishReq true "请求参数" // @Success 200 {string} "success" // @Failure 400 {object} md.Response "具体错误" // @Router /api/v1/circleFriends/public [POST] func Publish(c *gin.Context) { var req *friend_circles.PublishReq if err1 := c.ShouldBindJSON(&req); err1 != nil { e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) return } isCan, err := svc2.IsCanPublish(c) if err != nil { e.OutErr(c, e.ERR, err.Error()) return } if !isCan { e.OutErr(c, e.ERR, "当前不允许发朋友圈") return } //插入es记录 user := svc.GetUser(c) now := time.Now() createDocRet, err := es.CreateDoc(md.EggFriendCircleEsIndex, strconv.FormatInt(user.Id, 10)+"_"+utils.Int64ToStr(now.Unix()), md.EggFriendCircleEs{ Uid: user.Id, Kind: 1, Content: req.Content, Image: utils.SerializeStr(req.ImageList), Video: req.Video, LikesNums: 0, ShareNums: 0, CommentNums: 0, State: 0, IsTopUp: 0, CreatedAt: now.Format("2006-01-02 15:04:05"), UpdatedAt: now.Format("2006-01-02 15:04:05"), }) fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) e.OutSuc(c, "success", nil) } // CommentList // @Summary 朋友圈-评论列表 // @Tags 朋友圈 // @Description 评论列表 // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Param circle_index_id query string true "朋友圈文档记录" // @Success 200 {string} "success" // @Failure 400 {object} md.Response "具体错误" // @Router /api/v1/circleFriends/commentList [GET] func CommentList(c *gin.Context) { circleIndexId := c.DefaultQuery("circle_index_id", "") //查找朋友圈记录 doc, err := es.FirstDoc(md.EggFriendCircleEsIndex, circleIndexId) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } if !doc.Found { // 表示没找到数据 e.OutErr(c, e.ERR_NOT_FAN, "朋友圈文档记录不存在") return } resp, err := svc2.CommentList(circleIndexId) if err != nil { e.OutErr(c, e.ERR, err.Error()) return } e.OutSuc(c, resp, nil) } // CommentDetail // @Summary 朋友圈-评论详情 // @Tags 朋友圈 // @Description 评论详情 // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Param comment_index_id query string true "评论文档记录" // @Success 200 {string} "success" // @Failure 400 {object} md.Response "具体错误" // @Router /api/v1/circleFriends/commentDetail [GET] func CommentDetail(c *gin.Context) { commentIndexId := c.DefaultQuery("comment_index_id", "") //查找评论记录 doc1, err1 := es.FirstDoc(md.EggFriendCircleCommentEsAlias, commentIndexId) if err1 != nil { e.OutErr(c, e.ERR_DB_ORM, err1.Error()) return } if !doc1.Found { // 表示没找到数据 e.OutErr(c, e.ERR_NOT_FAN, "评论文档记录不存在") return } resp, err := svc2.CommentDetail(commentIndexId) if err != nil { e.OutErr(c, e.ERR, err.Error()) return } e.OutSuc(c, resp, nil) } func Delete(c *gin.Context) { e.OutSuc(c, "success", nil) } func Share(c *gin.Context) { e.OutSuc(c, "success", nil) } func Like(c *gin.Context) { e.OutSuc(c, "success", nil) } func CancelLike(c *gin.Context) { e.OutSuc(c, "success", nil) }