package com.tzld.longarticle.recommend.server.service;

import com.tzld.longarticle.recommend.server.model.RecommendRequest;
import com.tzld.longarticle.recommend.server.model.RecommendResponse;
import com.tzld.longarticle.recommend.server.service.rank.RankParam;
import com.tzld.longarticle.recommend.server.service.rank.RankResult;
import com.tzld.longarticle.recommend.server.service.rank.RankService;
import com.tzld.longarticle.recommend.server.service.recall.RecallParam;
import com.tzld.longarticle.recommend.server.service.recall.RecallResult;
import com.tzld.longarticle.recommend.server.service.recall.RecallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dyp
 */
@Service
@Slf4j
public class RecommendService {


    @Autowired
    private RecallService recallService;
    @Autowired
    private RankService rankService;


    public RecommendParam genRecommendParam(RecommendRequest request) {
        RecommendParam param = new RecommendParam();
        return param;
    }

    public RecommendResponse recommend(RecommendRequest request) {

        RecommendParam param = genRecommendParam(request);
        RecallResult recallResult = recallService.recall(convertToRecallParam(param));
        RankResult rankResult = rankService.rank(convertToRankParam(param, recallResult));
        // MergeResult mergeResult = mergeService.merge(convertToMergeParam(param, rankResult));

        RecommendResponse response = new RecommendResponse();

        return response;
    }

    public RecallParam convertToRecallParam(RecommendParam param) {
        RecallParam recallParam = new RecallParam();
        return recallParam;
    }


    public RankParam convertToRankParam(RecommendParam param, RecallResult recallResult) {
        RankParam rankParam = new RankParam();
        rankParam.setRecallResult(recallResult);
        return rankParam;
    }

}
