package com.fs.store.controller;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.R;
import com.fs.store.domain.FsCity;
import com.fs.store.service.IFsCityService;
import com.fs.store.utils.CityTreeUtil;
import com.fs.store.vo.CityVO;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.Cacheable;

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

/**
 * 城市Controller
 *
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/city")
public class FsCityController extends BaseController
{
    @Autowired
    private IFsCityService fsCityService;

//
//    @GetMapping("/getAllList")
//    @Cacheable("citys")
//    public R getAllList(FsCity fsCity)
//    {
//        List<FsCity> list = fsCityService.selectFsCityList(fsCity);
//        return R.ok().put("data",list);
//    }


    @ApiOperation("获取城市数据")
    @GetMapping("/getCitys")
    @Cacheable("citys")
    public R getCitys(HttpServletRequest request){
        List<FsCity> list=fsCityService.selectFsCitys();
//        List<CityVO> cityVOS = Lists.newArrayList();
////        for (FsCity city : list){
////            CityVO cityVO = new CityVO();
////            cityVO.setValue(city.getCityId());
////            cityVO.setLabel(city.getName());
////            cityVO.setPid(city.getParentId());
////            cityVOS.add(cityVO);
////        }
        return R.ok().put("data", list);

    }
}
