package logic

import (
	"context"
	"fmt"

	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/api/internal/svc"
	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/api/internal/types"
	. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service"

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

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

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

func (l *WaitEmpowerDetailLogic) WaitEmpowerDetail(req *types.Req) (resp *types.Reply, err error) {
	resp = &types.Reply{}
	data, err := WaitEmpowerDetail(req.AppId, req.Function_code, req.Ent_id)
	if err != nil {
		resp.Error_msg = err.Error()
		l.Error(fmt.Sprintf("%+v", req), err)
	}
	resp.Error_code = 0
	resp.Data = map[string]interface{}{
		"start_time":     data.StartTime,
		"end_time":       data.EndTime,
		"empower_count":  data.EmpowerCount,
		"use_count":      data.UseCount,
		"limit_strategy": data.LimitStrategy,
	}
	return
}
