HrDistributionController.java 2.95 KB
package com.yoho.search.restapi.others;

import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.others.hongren.SearchHongRenService;
import com.yoho.search.service.scene.general.SortGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/hr")
public class HrDistributionController {

    @Autowired
    private SortGroupService sortGroupService;
    @Autowired
    private SearchHongRenService searchHongRenService;
    /**
     * 对分类进行分组查询
     * @param request
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/sortgroup")
    public SearchApiResult sortGroup(HttpServletRequest request) {
        Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
        if (!checkRequestParam(paramMap)) {
            return new SearchApiResult().setCode(400).setMessage("入参缺少hrShopId参数");
        }
        return sortGroupService.sortGroup(paramMap);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/shopList")
    public SearchApiResult getShopList(HttpServletRequest request) {
        Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
        if (!checkRequestParam(paramMap)) {
            return new SearchApiResult().setCode(400).setMessage("入参缺少hrShopId参数");
        }
        return searchHongRenService.shopList(paramMap);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/productList")
    public SearchApiResult productList(HttpServletRequest request) {
        Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
        if (!checkRequestParam(paramMap)) {
            return new SearchApiResult().setCode(400).setMessage("入参缺少hrShopId参数");
        }
        SearchApiResult searchApiResult = searchHongRenService.productList(paramMap);
        return searchApiResult;
    }

    @RequestMapping(method = RequestMethod.GET, value = "/productListForFuzzy")
    public SearchApiResult fuzzyProductList(HttpServletRequest request) {
        Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
        if (!checkRequestParam(paramMap)) {
            return new SearchApiResult().setCode(400).setMessage("入参缺少hrShopId参数");
        }
        SearchApiResult searchApiResult = searchHongRenService.productListForFuzzy(paramMap);
        return searchApiResult;
    }

    private boolean checkRequestParam(Map<String, String> paramMap) {
        return paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_HR_SHOP);
    }


}