package com.sptg.permissions.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.permissions.api.dto.AreaDto;
import com.sptg.permissions.api.entity.AppArea;
import com.sptg.permissions.api.entity.Area;
import com.sptg.permissions.api.feigns.fallback.AreaFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * title: AreaFeign
 * package: com.sptg.permissions.api.feigns
 * description: 全国省市区街道-对外服务接口
 *
 *                  
 *                
 */
@FeignClient(value = "smart-house-permissions",fallbackFactory = AreaFeignFallbackFactory.class)
public interface AreaFeign {

    /**
     * 功能描述: 根据父级编号获取子节点列表
     * @param parentCode 父级编号
     * @return List<Area>
     *                  
     *                      
     */
    @GetMapping(value = "/area/getSubList/{parentCode}")
    List<Area> getSubList(@PathVariable(value = "parentCode") Serializable parentCode);

    /**
     * 功能描述: 根据区域编号查询区域信息
     * @param code 区域编号
     * @return Area 区域信息
     *                  
     *                       
     */
    @GetMapping(value = "/area/selectByCode/{code}")
    Area selectByCode(@PathVariable(value = "code") Serializable code);

    /**
     * 功能描述: 根据区域编号列表获取区域列表
     * @param idList 区域编号列表
     * @return List<Area>
     *                  
     *                     
     */
    @PostMapping(value = "/area/getListByIds")
    List<Area> getListByIds(@RequestBody List<Long> idList);

    /**
     * 功能描述:根据名称和层级查找区域
     * @param dto
     * @return Map<String ,Object>
     *             
     *                     
     */
    @PostMapping(value = "/area/selectByNameAndLayer")
    Map<String ,Object> selectByNameAndLayer(@RequestBody AreaDto dto);

    /**
     * 根据名称查询城市和省份
     * @param name 城市名称或省份名称
     * @return 当参数为城市名称时,集合大小为2,[ 城市,省份 ];当参数为省份名称时,集合大小为1,[ 省份 ];若不存在,则返回空!
     */
    @GetMapping(value = "/area/getCityAndProvinceByName")
    List<Area> getCityAndProvinceByName(@RequestParam(value = "name") String name);
    @GetMapping(value = "/area/getAll")
    List<AppArea> selectAll();
    @PostMapping(value = "/area/pagingQuery")
    ResultBean<Page<Area>> pagingQuery(@RequestBody AreaDto areaDto);
    @PostMapping(value = "/area/addArea")
    ResultBean<Boolean> addArea(@RequestBody AreaDto areaDto);
    @GetMapping(value = "/area/getById/{id}")
    Area getById(@PathVariable(value = "id") Serializable id);
    @PostMapping(value = "/area/delete")
    ResultBean<Boolean> delete(@RequestBody Area area);
}
