TestApiController.java 2.59 KB
package com.yoho.search.consumer.test;

import com.yoho.search.consumer.job.ProductHeatValueJob;
import com.yoho.search.consumer.job.ProductModelValueJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

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

@Controller
public class TestApiController {
    @Autowired
    private ProductHeatValueJob productHeatValueJob;
    @Autowired
    private ProductModelValueJob productModelValueJob;

    @RequestMapping(value = "/test")
    @ResponseBody
    public Map<String, Object> test() {
        Map<String, Object> testResult = new HashMap<String, Object>();
        testResult.put("data", null);
        testResult.put("code", 200);
        testResult.put("message", "success");
        return testResult;
    }

//    @RequestMapping(value = "/doUpdateProductIndexHeatValue")
//    @ResponseBody
//    public Map<String, Object> doUpdateProductIndexHeatValue() {
//        Map<String, Object> returnMap = new HashMap<String, Object>();
//        try {
//            returnMap.put("code", 200);
//            returnMap.put("message", "success");
//            productHeatValueJob.doUpdateProductIndexHeatValue();
//        } catch (Exception e) {
//            e.printStackTrace();
//            returnMap.put("code", 400);
//            returnMap.put("message", e.getMessage());
//        }
//        return returnMap;
//    }


    @RequestMapping(value = "/doCleanHeatValue")
    @ResponseBody
    public Map<String, Object> doCleanHeatValue() {
        Map<String, Object> returnMap = new HashMap<String, Object>();
        try {
            returnMap.put("code", 200);
            returnMap.put("message", "success");
            productHeatValueJob.clean();
        } catch (Exception e) {
            e.printStackTrace();
            returnMap.put("code", 400);
            returnMap.put("message", e.getMessage());
        }
        return returnMap;
    }

    @RequestMapping(value = "/doCleanProductModelValue")
    @ResponseBody
    public Map<String, Object> doCleanProductModelValue() {
        Map<String, Object> returnMap = new HashMap<String, Object>();
        try {
            returnMap.put("code", 200);
            returnMap.put("message", "success");
            productModelValueJob.clean();
        } catch (Exception e) {
            e.printStackTrace();
            returnMap.put("code", 400);
            returnMap.put("message", e.getMessage());
        }
        return returnMap;
    }
}