BigdataTestController.java 1.91 KB
package com.yoho.search.restapi.tools;

import com.yoho.search.core.personalized.service.BidataServiceCaller;
import com.yoho.search.core.personalized.service.PersonalVersionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "/tools")
public class BigdataTestController {

    @Autowired
    private PersonalVersionManager personalVersionManager;
    @Autowired
    private BidataServiceCaller bidataServiceCaller;

    @RequestMapping(value = "/bigdataServiceTest")
    public Map<String, Object> bigdataServiceTets(Integer uid) {
        Map<String, Object> results = new HashMap<>();

        //大数据目前推荐的版本
        String bigDataRecomDateStr = personalVersionManager.getBigDataRecomDateStr();
        results.put("bigDataRecomDateStr", bigDataRecomDateStr == null ? "" : bigDataRecomDateStr);
        results.put("bigDataRecomDateStrFeatures", bidataServiceCaller.getUserVectorFeature(uid.toString(), bigDataRecomDateStr));

        //zk中目前的版本
        String currentVersionInZk = personalVersionManager.getCurrentVersionInZk();
        results.put("currentVersionInZk", currentVersionInZk == null ? "" : currentVersionInZk);
        results.put("currentVersionInZkFeatures", bidataServiceCaller.getUserVectorFeature(uid.toString(), currentVersionInZk));

        //用户性别偏好
        results.put("userGenderFeature", bidataServiceCaller.getUserGenderFeature(uid.toString()));
        //用户尺码偏好
        results.put("userFavoriteSizes", bidataServiceCaller.getUserFavoriteSizes(uid.toString()));
        //用户个性化因子
        results.put("userPersionalFactor", bidataServiceCaller.queryUserPersionalFactor(uid, null, null));
        return results;
    }

}