package logic

import (
	"context"
	"jyBXCore/rpc/service"
	"jyBXCore/rpc/util"

	"jyBXCore/rpc/internal/svc"
	"jyBXCore/rpc/type/bxcore"

	"github.com/zeromicro/go-zero/core/logx"
)

type ParticipatePersonsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewParticipatePersonsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ParticipatePersonsLogic {
	return &ParticipatePersonsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 当前部门/企业下参标人员信息
func (l *ParticipatePersonsLogic) ParticipatePersons(in *bxcore.ParticipatePersonsReq) (*bxcore.ParticipatePersonsRes, error) {
	b, _ := util.IsAllowedParticipate(in.AppId, in.MgoUserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
	if !b {
		return &bxcore.ParticipatePersonsRes{
			ErrCode: -1,
			ErrMsg:  "没有权限",
			Data:    nil,
		}, nil
	}
	return service.GetParticipatePersonInfo(in), nil
}
