package logic

import (
	"app.yhyue.com/moapp/jybase/encrypt"
	"context"
	"jyBXCore/rpc/type/bxcore"

	"jyBXCore/api/internal/svc"
	"jyBXCore/api/internal/types"

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

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

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

func (l *PushStatisticsLogic) PushStatistics(req *types.PtatisticsListReq) (resp *types.CommonResp, err error) {
	// todo: add your logic here and delete this line
	for k, v := range req.EntUserIdArr {
		req.EntUserIdArr[k] = encrypt.SE.Decode4Hex(v)
	}
	res, err := l.svcCtx.BxCore.PushStatistics(l.ctx, &bxcore.StatisticsListReq{
		EntId:        req.EntId,
		EntUserId:    req.EntUserId,
		PositionId:   req.PositionId,
		EntUserIdArr: req.EntUserIdArr,
		DeptId:       req.DeptId,
		StartTime:    req.StartTime,
		EndTime:      req.EndTime,
	})
	if err != nil {
		return nil, err
	}
	return &types.CommonResp{
		Data: res.Data,
	}, nil
}
