package com.kiisoo.ic.store.controller;

import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.service.PoiStoreService;
import com.kiisoo.ic.utils.DataImportUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 门店
 */
@Controller
@RequestMapping("/poi/store")
@Slf4j
public class PoiStoreController extends BaseController {

    @Autowired
    private PoiStoreService poiStoreService;

    /**
     * 根据用户id，区域id获取店铺
     * @return
     */
    @RequestMapping(value = "/user/shop",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> getUserShop(@RequestParam("userId")long userId, Long regionId, Long companyId){
        try {
            return data(poiStoreService.getRegionShop(userId,regionId,companyId));
        }catch (Exception e){
            log.error("获取用户店铺失败",e);
            return fail();
        }
    }

    /**
     * 查询所有店铺
     *
     * @return 店铺信息
     */
    @RequestMapping(value = "/all/list", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> listAllShop() {
        try {
            List<PoiStore> shops = poiStoreService.listAllShop();
            return data(shops);
        } catch (Exception e) {
            log.error("查询渠道店铺出错", e);
            return fail();
        }
    }


}
