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 ProjectStatisticsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

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

func (l *ProjectStatisticsLogic) ProjectStatistics(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.ProjectStatistics(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
}
