package com.fs.app.controller;


import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;
import com.fs.his.domain.FsCity;
import com.fs.his.domain.FsStore;
import com.fs.his.service.IFsCityService;
import com.fs.his.service.IFsDoctorService;
import com.fs.his.service.IFsStoreService;
import com.fs.his.utils.CityTreeUtil;
import com.fs.his.vo.CityVO;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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


@Api("店铺接口")
@RestController
@RequestMapping(value="/app/store")
public class StoreController extends  AppBaseController {
	@Autowired
	private IFsStoreService storeService;
	@Autowired
	private IFsDoctorService doctorService;
	@Autowired
	private IFsCityService fsCityService;

	@Login
	@ApiOperation("获取店铺数据")
	@GetMapping("/getStoreList")
	public R getStoreList(HttpServletRequest request){

		FsStore map=new FsStore();
		map.setStatus(1);
		map.setIsAudit(1);
		List<FsStore> stores=storeService.selectFsStoreListByDoctorId(Long.parseLong(getDoctorId()));
		return R.ok().put("data", stores);

	}

	@ApiOperation("获取城市数据")
	@GetMapping("/getCitys")
	public R getCitys(){
		List<FsCity> list=fsCityService.selectFsCity();
		List<com.fs.his.vo.CityVO> cityVOS = Lists.newArrayList();
		for (FsCity city : list){
			com.fs.his.vo.CityVO cityVO = new CityVO();
			cityVO.setValue(Long.parseLong(city.getCityId()));
			cityVO.setLabel(city.getCityName());
			cityVO.setPid(Long.parseLong(city.getParentId()));
			cityVOS.add(cityVO);
		}
		return R.ok().put("data", CityTreeUtil.list2TreeConverter(cityVOS, 0));
	}
}
