package com.cool.store.controller.webb;

import com.cool.store.entity.RegionDO;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName RegionController
 * @Description 区域
 */
@RestController
@RequestMapping("/pc/region")
@Api(tags = "区域信息")
@Slf4j
public class RegionController {

    @Autowired
    private RegionService regionService;

    @ApiOperation("根据意向区域找大区id")
    @GetMapping("/getBigRegionIdByAreaId")
    public ResponseResult<Long> getBigRegionIdByAreaId(@RequestParam(value = "wantShopAreaId", required = true) Long wantShopAreaId) {
        return ResponseResult.success(regionService.getBigRegionIdByAreaId(wantShopAreaId));
    }

    @ApiOperation("根据三方区域类型获取区域列表 0-根 1=大区 2=战区 3=小区（督导区 4=门店")
    @GetMapping("/listByThirdRegionType")
    public ResponseResult<List<RegionDO>> listByThirdRegionType(@RequestParam(value = "parentId", required = false) Long parentId,
                                                                @RequestParam(value = "thirdRegionType", required = false) String thirdRegionType) {
        return ResponseResult.success(regionService.listByThirdRegionType(parentId, thirdRegionType));
    }

    @ApiOperation("获取所属战区")
    @GetMapping("/getBelongWarRegionName")
    public ResponseResult<String> getBelongWarRegionName(@RequestParam(value = "regionId", required = true) Long regionId) {
        return ResponseResult.success(regionService.getBelongWarRegionName(regionId));
    }

}
