123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package ChatRoomMember
- import (
- "context"
- "wechat-api/ent/wx"
- "wechat-api/hook"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetChatroomMemberListLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewGetChatroomMemberListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetChatroomMemberListLogic {
- return &GetChatroomMemberListLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *GetChatroomMemberListLogic) GetChatroomMemberList(req *types.ChatroomMemberListReq) (resp *types.ChatroomMemberListResp, err error) {
- // todo: add your logic here and delete this line
- wxInfo, err := l.svcCtx.DB.Wx.Query().Where(wx.Wxid(*req.OwnerWxid)).First(l.ctx)
- if err != nil {
- l.Error("查询微信信息失败", err)
- return
- }
- serverInfo, err := l.svcCtx.DB.Server.Get(l.ctx, wxInfo.ServerID)
- if err != nil {
- l.Error("查询服务器信息失败", err)
- return
- }
- hookClient := hook.NewHook(serverInfo.PrivateIP, serverInfo.AdminPort, wxInfo.Port)
- chatrooMmemberDetail, err := hookClient.GetChatrooMmemberDetail(*req.ChatRoom)
- if err != nil {
- l.Error("获取群成员详细信息失败", err)
- return
- }
- resp = &types.ChatroomMemberListResp{
- BaseDataInfo: types.BaseDataInfo{
- Code: 0,
- Msg: errormsg.Success,
- },
- }
- for _, v := range chatrooMmemberDetail.Member {
- resp.Data.Data = append(resp.Data.Data, types.ChatroomMemberInfo{
- Wxid: &v.Wxid,
- ChatRoom: req.ChatRoom,
- OwnerWxid: req.OwnerWxid,
- Account: &v.Nickname,
- })
- }
- return resp, nil
- }
|