package com.tzld.piaoquan.ad.engine.service.remote;

import com.tzld.piaoquan.recommend.server.client.ModelClient;
import com.tzld.piaoquan.recommend.server.client.ModelType;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


/**
 * @author dyp
 */

@Slf4j
@Service
public class ModelRemoteService {

    @Autowired
    private ModelClient client;

    public Score getScore(Long videoId, String mid, String uid, String city, String province) {
        if (StringUtils.isBlank(mid)) {
            return null;
        }
        Map<String, Double> scoreMap = client.getScore(videoId, mid, uid, city, province);
        Score score = new Score();
        score.setStr(scoreMap.get(ModelType.STR.getKey()));
        score.setRos(scoreMap.get(ModelType.ROS.getKey()));
        return score;
    }

    @Data
    public static class Score {
        private double str;
        private double ros;
    }

}
