package jnpf.doclibrary;

import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import jnpf.base.ActionResult;
import jnpf.doclibrary.fallback.StoreFallback;
import jnpf.entity.StoreEntity;
import jnpf.model.store.Store;
import jnpf.model.store.StorePositionInfoVo;
import jnpf.model.store.StoreUserNumVo;
import jnpf.model.store.dto.StoreAbnormalIdsQueryDTO;
import jnpf.model.store.dto.StorePageByIdsNoDsQueryDTO;
import jnpf.model.store.dto.StorePageByIdsQueryDTO;
import jnpf.model.store.vo.StoreBaseListVO;
import jnpf.model.store.vo.StoreLocationVO;
import jnpf.model.store.vo.UserStoreListVo;
import jnpf.model.vo.StoreExecutionVo;
import jnpf.util.NoDataSourceBind;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 门店内部调用api
 *
 * @author yanwenfu
 * @create 2023-07-12
 */
@FeignClient(name = "jnpf-ftb", fallback = StoreFallback.class, path = "/Store")
public interface StoreApi {

    /**
     * 查询门店下岗位的成员数量
     * @param storeId 门店id
     * @param positionList 岗位id集合
     * @return java.util.List<jnpf.model.store.StorePositionInfoVo>
     */
    @GetMapping(value = "/storePositionInfo/list")
    List<StorePositionInfoVo> getStorePositionInfoList(@RequestParam(value = "storeId") String storeId, @RequestParam(value = "positionList") List<String> positionList);

    /**
     * 查询门店下的成员数量
     * @param storeIds 门店ids
     * @return java.util.List<jnpf.model.store.StorePositionInfoVo>
     */
    @GetMapping(value = "/storePositionInfo/getUserNum")
    List<StoreUserNumVo> getUserNum(@RequestParam(value = "storeIds") List<String> storeIds);

    /**
     * 获取用户门店列表信息
     * @return 返回值
     */
    @GetMapping(value = "/userStoreList")
    ActionResult<List<Store>> getUserStoreList();

    /**
     * 获取用户门店列表信息(值班)
     *
     * @return 返回值
     */
    @GetMapping(value = "/userStoreListDuty")
    ActionResult<List<Store>> getUserStoreListDuty();

    /**
     * 查询用户所属的门店
     * @param userId 用户id
     * @return jnpf.base.ActionResult<java.util.List < jnpf.model.store.Store>>
     */
    @GetMapping(value = "/listByUserId/{userId}")
    List<Store> getListByUserId(@PathVariable(value = "userId") String userId);

    @GetMapping(value = "/getAllUserStores")
    List<UserStoreListVo> getAllUserStores();

    /**
     * 根据门店ids查询门店信息
     * @param storeIds 门店ids
     * @return java.util.List<jnpf.model.store.Store>
     */
    @GetMapping(value = "/listByIds")
    List<Store> getListByIds(@RequestParam(value = "storeIds") List<String> storeIds);

    @GetMapping("/getList")
    ActionResult<List<Store>> getList(@RequestParam("selectKey") String selectKey,
                                      @RequestParam("organizeid") String organizeId,
                                      @RequestParam("longitude") String longitude,
                                      @RequestParam("latitude") String latitude);

    /**
     * 查询组织下的门店
     * @param organizeId 组织id
     * @return java.util.List<jnpf.model.store.Store>
     */
    @GetMapping(value = "/list")
    List<Store> getStoreList(@RequestParam(value = "organizeId", required = false) String organizeId);

    /**
     * 查询组织下的门店(返回了上级组织)
     * @param organizeId 组织id
     * @return java.util.List<jnpf.model.store.Store>
     */
    @GetMapping(value = "/orgList")
    List<Store> getOrgStoreList(@RequestParam(value = "organizeId", required = false) String organizeId, @RequestParam(value = "queryStoreIds", required = false) List<String> queryStoreIds);

    /**
     * 查询门店信息
     * @param id 门店id
     * @return jnpf.model.store.Store
     */
    @GetMapping("/info/{id}")
    Store getStoreInfo(@PathVariable("id") String id);

    /**
     * 查询门店信息
     * @param id 门店id
     * @return jnpf.model.store.Store
     */
    @GetMapping("/getStoreInfoNoData")
    StoreEntity getStoreInfoNoData(@RequestParam("id") String id, @RequestParam("tenantId") String tenantId);

    /**
     * 根据门店ids分页查询门店记录
     * @param storeIds 门店ids
     * @param currentPage 当前页码
     * @param pageSize 每页条数
     * @return com.github.pagehelper.PageInfo<jnpf.model.vo.StoreExecutionVo>
     */
    @PostMapping(value = "/store/pageByIds")
    PageInfo<StoreExecutionVo> getStorePageByIds(@RequestBody StorePageByIdsQueryDTO query);

    /**
     * 根据门店ids分页查询门店记录
     * @param storeIds 门店ids
     * @param currentPage 当前页码
     * @param pageSize 每页条数
     * @return com.github.pagehelper.PageInfo<jnpf.model.vo.StoreExecutionVo>
     */
    @PostMapping(value = "/store/pageByIdsNoDataSource")
    PageInfo<StoreExecutionVo> getStorePageByIdsNoDataSource(@RequestBody StorePageByIdsNoDsQueryDTO query);

    /**
     * 查询异常的门店
     * @param storeIds 门店ids
     * @return java.util.List<java.lang.String>
     */
    @PostMapping(value = "/store/abnormal/record")
    List<String> getAbnormalStoreIds(@RequestBody StoreAbnormalIdsQueryDTO query);

    /**
     * 根据组织ids查询门店列表
     * @param organizeIdList 组织ids
     * @return java.util.List<jnpf.model.store.Store>
     */
    @PostMapping(value = "/store/list/byOrganizeList")
    List<Store> getStoreListByOrganizeList(@RequestBody List<String> organizeIdList);

    /**
     * 查询门店信息(未绑定数据库)
     * @param tenantId 租户id
     * @param storeIds 门店ids
     * @return java.util.List<jnpf.model.store.Store>
     */
    @GetMapping(value = "/store/list/noDataSource")
    List<Store> getListByIdsNoDataSource(@RequestParam(value = "tenantId") String tenantId, @RequestParam(value = "storeIds") List<String> storeIds);

    /**
     * 校验是否是值班人
     * @param userId 用户Id
     */
    @GetMapping(value = "/store/checkStoreUser")
    boolean checkStoreUser(@RequestParam(value = "userId") String userId);

    @Operation(description = "[列表] 目标组织,及其子组织所有已启用的门店")
    @GetMapping(value = "/store/list/organizeChildren")
    ActionResult<List<StoreBaseListVO>> getStoreListByOrganizeIdAndChildOrganize(@RequestParam(value = "organizeId") String organizeId, @RequestParam(required = false, value = "disabled") Boolean disabled);


    /**
     * 查询门店下岗位的成员数量
     * @param storeId 门店id
     * @param positionList 岗位id集合
     * @return java.util.List<jnpf.model.store.StorePositionInfoVo>
     */
    @NoDataSourceBind
    @GetMapping(value = "/storePositionInfo/list/nodata")
    List<StorePositionInfoVo> getStorePositionInfoListNodata(@RequestParam(value = "storeId") String storeId, @RequestParam(value = "positionList") List<String> positionList, @RequestParam(value = "tenantId") String tenantId);

    /**
     * 查询用户所属的门店
     * @param userId 用户id
     * @return jnpf.base.ActionResult<java.util.List < jnpf.model.store.Store>>
     */
    @GetMapping(value = "/listByUserId/nodata/{userId}")
    @NoDataSourceBind
    List<Store> getListByUserIdNodata(@PathVariable(value = "userId") String userId, @RequestParam(value = "tenantId") String tenantId);

    /**
     * 获取门店位置信息
     * @param storeId 门店id
     * @return jnpf.model.store.vo.StoreLocationVO
     */
    @GetMapping(value = "/getStoreLocation")
    StoreLocationVO getStoreLocation(@RequestParam(value = "storeId") String storeId);
}
