2026-08-09 10:43:45 +08:00
|
|
|
package member
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-09-22 21:15:34 +08:00
|
|
|
"time"
|
2026-08-09 10:43:45 +08:00
|
|
|
|
2026-08-09 12:41:08 +08:00
|
|
|
"bsm/full/module/social/group/internal/impl"
|
|
|
|
|
"bsm/full/module/social/group/internal/models"
|
|
|
|
|
pb "bsm/full/module/social/group/pb"
|
2026-08-10 11:42:45 +08:00
|
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/printer"
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/service"
|
2026-08-09 10:43:45 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 申请加群列表
|
|
|
|
|
func JoinFetch(ctx context.Context, in *pb.Empty) (reply *pb.JoinFetchReply, err error) {
|
|
|
|
|
auth, err := service.ParseMetaCtx(ctx, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-22 21:15:34 +08:00
|
|
|
applys := make([]*pb.ApplyJoinGroupItem, 0)
|
2026-08-09 10:43:45 +08:00
|
|
|
group_ids := models.GetMasterGroup(auth.ID)
|
|
|
|
|
if len(group_ids) > 0 {
|
2026-09-22 21:15:34 +08:00
|
|
|
var records []models.GroupApply
|
|
|
|
|
if err = impl.DBService.Model(&models.GroupApply{}).Where("group_id in ?", group_ids).Find(&records).Error; err != nil {
|
2026-08-09 10:43:45 +08:00
|
|
|
printer.Error(err.Error())
|
|
|
|
|
return nil, errcode.ErrDB
|
|
|
|
|
}
|
2026-09-22 21:15:34 +08:00
|
|
|
for i := range records {
|
|
|
|
|
item := &pb.ApplyJoinGroupItem{
|
|
|
|
|
Identity: records[i].Identity,
|
|
|
|
|
GroupId: int64(records[i].GroupID),
|
|
|
|
|
Message: records[i].Message,
|
|
|
|
|
CreatedAt: records[i].CreatedAt.Format(time.DateTime),
|
|
|
|
|
Status: int32(records[i].Status),
|
2026-08-09 10:43:45 +08:00
|
|
|
}
|
2026-09-22 21:15:34 +08:00
|
|
|
// 每条申请单独分配资料卡,避免所有元素共用同一指针
|
|
|
|
|
card := &pb.PassportInfoDetailCard{}
|
|
|
|
|
if e := impl.DBService.Table("passport_extend").Select(filed).
|
|
|
|
|
Where("passport_identity = ?", records[i].FromIdentity).First(card).Error; e != nil {
|
|
|
|
|
printer.Error(e.Error())
|
|
|
|
|
// 申请人资料查不到时跳过该条,避免整份列表不可用
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
item.From = card
|
|
|
|
|
applys = append(applys, item)
|
2026-08-09 10:43:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &pb.JoinFetchReply{
|
2026-09-22 21:15:34 +08:00
|
|
|
Total: int32(len(applys)),
|
|
|
|
|
Applys: applys,
|
2026-08-09 10:43:45 +08:00
|
|
|
}, nil
|
|
|
|
|
}
|