package com.cool.store.controller;

import com.cool.store.response.ResponseResult;
import com.cool.store.service.RegionService;
import com.cool.store.service.ZoneService;
import com.cool.store.vo.region.RegionBaseInfoVO;
import com.cool.store.vo.region.RegionUserAndSubRegionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author zhangchenbiao
 * @FileName: RegionController
 * @Description:
 * @date 2023-06-12 15:53
 */
@RestController
@RequestMapping({"/v1/region" })
@Slf4j
@Api(tags = "组织架构")
public class RegionController {

    @Resource
    private RegionService regionService;
    @Resource
    private ZoneService zoneService;

    @GetMapping("/getRegionList")
    public ResponseResult<List<RegionBaseInfoVO>> getRegionBaseInfoList(){
        List<RegionBaseInfoVO> resultList = new ArrayList<>(Arrays.asList(regionService.getRegionBaseInfoList()));
        return ResponseResult.success(resultList);
    }


    @ApiOperation("查询所有被绑定战区的组织机构")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "intent-意向区域   dev 开发区域", required = false)
    })
    @GetMapping("/queryAllBingZoneRegionList")
    public ResponseResult<List<String>> queryAllBingZoneRegionList(@RequestParam(value = "type",required = false)String type){
        return ResponseResult.success(zoneService.queryAllBingZoneRegionList(type));
    }

    @ApiOperation("获取部门下的人和部门")
    @GetMapping("/getRegionUserAndSubRegion")
    public ResponseResult<RegionUserAndSubRegionVO> getRegionUserAndSubRegion(@RequestParam(value = "regionId")String regionId){
        return ResponseResult.success(regionService.getRegionUserAndSubRegion(regionId));
    }

}
