package basic

import (
	"context"

	"git.apinb.com/bsm-sdk/core/errcode"
	"git.apinb.com/bsm-sdk/core/printer"
	"git.apinb.com/bsm-sdk/core/service"
	"bsm/full/module/social/group/internal/impl"
	pb "bsm/full/module/social/group/pb"
)

// 获取群组信息
func Get(ctx context.Context, in *pb.IdentRequest) (reply *pb.GroupItem, err error) {
	// parse authorization meta.
	_, err = service.ParseMetaCtx(ctx, nil)
	if err != nil {
		return nil, err
	}
	err = impl.DBService.Where("identity=?", in.Identity).First(&reply).Error
	if err != nil {
		printer.Error(err.Error())
		return nil, errcode.ErrDB
	}
	return &pb.GroupItem{}, nil
}
