package controller import ( "context" "customer-server/model/dto" "customer-server/service" "github.com/gogf/gf/v2/frame/g" ) var XiaohongshuController = new(xiaohongshuController) type xiaohongshuController struct{} // BindAccount 绑定小红书账户 // 参数: req - 绑定账户请求,包含账户信息和授权码 // 返回: res - 处理结果 // 功能: 处理小红书账户绑定,保存授权码到客服账号 func (c *xiaohongshuController) BindAccount(ctx context.Context, req *XhsBindAccountReq) (res *dto.XhsCommonRes, err error) { if err = service.Xiaohongshu.HandleBindAccount(ctx, &req.XhsBindAccountReq); err != nil { return } res = &dto.XhsCommonRes{Code: 0, Msg: "成功", Success: true} return } // UnbindAccount 解绑小红书账户 // 参数: req - 解绑账户请求,包含账户信息和授权码 // 返回: res - 处理结果 // 功能: 处理小红书账户解绑,删除授权码从客服账号 func (c *xiaohongshuController) UnbindAccount(ctx context.Context, req *XhsUnbindAccountReq) (res *dto.XhsCommonRes, err error) { if err = service.Xiaohongshu.HandleUnbindAccount(ctx, &req.XhsUnbindAccountReq); err != nil { return } res = &dto.XhsCommonRes{Code: 0, Msg: "成功", Success: true} return } // BindKosUser 绑定小红书KOS用户 // 参数: req - KOS绑定请求,包含绑定状态和token // 返回: res - 处理结果 // 功能: 处理小红书KOS授权回调,保存授权token到客服账号 func (c *xiaohongshuController) BindKosUser(ctx context.Context, req *XhsBindKosUserReq) (res *dto.XhsCommonRes, err error) { g.Log().Infof(ctx, "[小红书] 收到KOS绑定通知: %s", req.Content) res = &dto.XhsCommonRes{Code: 0, Msg: "成功", Success: true} return } // ReceiveMessage 接收小红书消息 // 参数: req - 消息请求,包含消息内容和用户信息 // 返回: res - 处理结果 // 功能: 接收小红书消息,自动回复或转发到RAGFlow处理 func (c *xiaohongshuController) ReceiveMessage(ctx context.Context, req *XhsReceiveMessageReq) (res *dto.XhsCommonRes, err error) { if err = service.Xiaohongshu.HandleReceiveMessage(ctx, &req.XhsReceiveMessageReq); err != nil { return } res = &dto.XhsCommonRes{Code: 0, Msg: "成功", Success: true} return } // IntentCommentPush 接收意向评论推送 // 参数: req - 评论推送请求,包含评论ID、内容、用户信息 // 返回: res - 处理结果 // 功能: 接收小红书意向评论,自动回复或转发到RAGFlow处理 func (c *xiaohongshuController) IntentCommentPush(ctx context.Context, req *XhsIntentCommentPushReq) (res *dto.XhsCommonRes, err error) { g.Log().Infof(ctx, "[小红书] 收到意向评论推送: commentId=%s, content=%s", req.CommentId, req.CommentContent) res = &dto.XhsCommonRes{Code: 0, Msg: "成功", Success: true} return } // PushLead 接收留资推送 // 参数: req - 留资推送请求,包含用户留资信息 // 返回: res - 处理结果 // 功能: 接收小红书用户留资信息,记录到系统并触发后续流程 func (c *xiaohongshuController) PushLead(ctx context.Context, req *XhsPushLeadReq) (res *dto.XhsCommonRes, err error) { g.Log().Infof(ctx, "[小红书] 收到留资推送: userId=%s, pushType=%d", req.UserId, req.PushType) res = &dto.XhsCommonRes{Code: 0, Msg: "成功", Success: true} return } // ==================== 请求结构(路由元数据) ==================== type XhsBindAccountReq struct { g.Meta `path:"/api/open/im/third/bind_account" method:"post" tags:"Xiaohongshu" summary:"小红书绑定账户通知"` dto.XhsBindAccountReq } type XhsUnbindAccountReq struct { g.Meta `path:"/api/open/im/third/unbind_account" method:"post" tags:"Xiaohongshu" summary:"小红书解绑账户通知"` dto.XhsUnbindAccountReq } type XhsBindKosUserReq struct { g.Meta `path:"/api/open/im/auth/bind_user/event" method:"post" tags:"Xiaohongshu" summary:"小红书KOS绑定事件"` dto.XhsBindKosUserReq } type XhsReceiveMessageReq struct { g.Meta `path:"/api/open/im/send" method:"post" tags:"Xiaohongshu" summary:"小红书接收消息"` dto.XhsReceiveMessageReq } type XhsIntentCommentPushReq struct { g.Meta `path:"/api/open/intent/comment" method:"post" tags:"Xiaohongshu" summary:"小红书意向评论推送"` dto.XhsIntentCommentPushReq } type XhsPushLeadReq struct { g.Meta `path:"/api/open/im/push_lead" method:"post" tags:"Xiaohongshu" summary:"小红书留资推送"` dto.XhsPushLeadReq }