package com.sptg.estate.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.device.api.entity.Device;
import com.sptg.estate.api.dto.AccessCardDto;
import com.sptg.estate.api.entity.AccessCard;
import com.sptg.estate.api.feigns.fallback.AccessCardFeignFallbackFactory;
import com.sptg.estate.api.vo.DevicesAccessPushVO;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * title: AccessCardFeign
 * package: com.sptg.estate.api.feigns
 * description: 门禁卡 服务接口
 *
 *
 *
 */
@FeignClient(value = "smart-house-estate",fallbackFactory = AccessCardFeignFallbackFactory.class)
public interface AccessCardFeign {

    /**
     * 功能描述:门禁卡查询列表
     * @param accessCardDto 门禁卡业务对象（含分页及查询条件）
     * @return ResultBean<Page<AccessCard>>
     *
     *
     */
    @PostMapping(value = "/accessCard/showAccessCardList")
    ResultBean<Page<AccessCard>> showAccessCardList(@RequestBody AccessCardDto accessCardDto);

    /**
     * 门禁卡查询列表
     * @param accessCardDto
     * @return
     */
    @PostMapping(value = "/accessCard/showCardList")
    ResultBean<Page<AccessCard>> showCardList(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:新增门禁卡
     *
     * @param accessCardDto 住户卡业务对象
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/accessCard/addAccessCard")
    ResultBean<Boolean> addAccessCard(@RequestBody AccessCardDto accessCardDto);


    /**
     * 功能描述:批量下发导入的门禁卡
     *
     * @param accessCardDtoList 住户卡业务对象
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/accessCard/addAccessCardBatch")
    public ResultBean<Boolean> pushAccessCardBatch(@RequestBody List<AccessCardDto> accessCardDtoList);

    /**
     * 功能描述:根据Id 查找门禁卡
     * @param id 必填
     * @return AccessCard
     *
     *
     */
    @GetMapping(value = "/accessCard/findAccessCardById/{id}")
    AccessCard findAccessCardById(@PathVariable(value = "id") Long id);

    /**
     * 功能描述:编辑门禁卡
     * @param accessCardDto 门禁卡业务对象
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/updateAccessCard")
    ResultBean<Boolean> updateAccessCard(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:删除门禁卡
     * @param accessCardDto 门禁卡业务对象
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/deleteAccessCard")
    ResultBean<Boolean> deleteAccessCard(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:批量删除门禁卡
     * @param accessCardDto 门禁卡业务对象
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/deleteCardList")
    ResultBean<Boolean> deleteCardList(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:根据条件查询门禁卡
     * @param accessCardDto 门禁卡业务对象
     * @return List<AccessCard>
     *
     *
     */
    @PostMapping(value = "/accessCard/findAccessCardByCondition")
    List<AccessCard> findAccessCardByCondition(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述: 分页查询卡列表
     * @param pageBean 查询条件
     * @return Page<AccessCard>
     *
     *
     */
    @PostMapping(value = "/accessCard/pagingQuery")
    Page<AccessCard> pagingQuery(@RequestBody PageBean<AccessCard, Device> pageBean);

    /**
	 * 功能描述: 分页查询卡列表，只获取已启用的
     * @param pageBean 查询条件
     * @return Page<AccessCard>
     *
     *
     */
    @PostMapping(value = "/accessCard/enable/pagingQuery")
    Page<AccessCard> enablePagingQuery(@RequestBody PageBean<AccessCard, Device> pageBean);
    /**
     * 功能描述:添加和更新（含删除）住户门禁卡
     * @param accessCardDto 门禁卡业务对象
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/addOrUpdateUserCard")
    ResultBean<Boolean> addOrUpdateUserCard(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:添加和更新（含删除）住户门禁卡（但不下发卡到设备上）
     * @param accessCardDto 门禁卡业务对象
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/simpleAddOrUpdateUserCard")
    ResultBean<AccessCardDto> simpleAddOrUpdateUserCard(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:添加和更新（含删除）住户门禁卡（但不下发卡到设备上）
     * @param devicesAccessPushVO 门禁卡业务对象
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/sendAccessUserCard")
    ResultBean<Boolean> sendAccessUserCard(@RequestBody DevicesAccessPushVO devicesAccessPushVO);

    /**
     * 功能描述:根据类型和ID获取住户卡
     * @param accessCardDto
     * @return AccessCard
     *
     *
     */
    @PostMapping(value = "/accessCard/getAccessCardByUserIdAndType")
    List<AccessCard> getAccessCardByUserIdAndType(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:根据位置查询卡管理
     * @param accessCardDto
     * @return ResultBean<AccessCard>
     *
     *
     */
    @PostMapping(value = "/accessCard/findListByPosition")
    ResultBean<AccessCard> findListByPosition(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:批量导入
     * @param list 导入对象集合
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/accessCard/importAccessCardList")
    ResultBean<Boolean> importAccessCardList(@RequestBody List<AccessCard> list);

    @GetMapping(value = "/accessCard/getByOldId/{oldId}")
    AccessCard getByOldId(@PathVariable(value = "oldId") String oldId);

    @GetMapping(value = "/accessCard/getCardByCardNo/{cardNo}")
    AccessCard getCardByCardNo(@PathVariable(value = "cardNo") String cardNo);

    @PostMapping(value = "/accessCard/findAccessCardListByCardNo")
    List<AccessCard> getAccessCardListByCardNo(@RequestBody AccessCardDto accessCardDto);

    @PostMapping(value = "/accessCard/getAccessCardListByCardIds")
    List<AccessCard> getAccessCardListByCardIds(@RequestBody AccessCardDto accessCardDto);

    /**
     * 功能描述:根据卡号和有效期
     * @param accessCardDto 门禁卡业务对象
     * @return List<AccessCard>
     *
     *
     */
    @PostMapping(value = "/accessCard/getListByCardNoAndDate")
    List<AccessCard> getListByCardNoAndDate(@RequestBody AccessCardDto accessCardDto);

    /**
     * 根据卡号和小区修改记名卡用户
     * @param accessCardDto
     * @return
     */
    @PostMapping("/accessCard/updateAccessCardByCardNo")
    ResultBean<Boolean> updateAccessCardByCardNo(@RequestBody AccessCardDto accessCardDto);

    /**
     * 根据id修改门禁卡为黑名单
     * @param id
     * @return
     */
    @GetMapping("/accessCard/updateBlackCard/{id}")
    ResultBean<Boolean> updateBlackCard(@PathVariable("id") Long id);

    /**
     * 根据id取消门禁卡为黑名单
     * @param id
     * @return
     */
    @GetMapping("/accessCard/cancelBlackCard/{id}")
    ResultBean<Boolean> cancelBlackCard(@PathVariable("id") Long id);

    /**
     * 更新数据
     * @param accessCard
     * @return
     */
    @PostMapping("/accessCard/updateAccessCardById")
    ResultBean<Boolean> updateAccessCardById(@RequestBody AccessCard accessCard);
    @PostMapping("/accessCard/findAccessCardByUserIdAndUserName")
    List<AccessCard> findAccessCardByUserIdAndUserName(@RequestBody AccessCardDto accessCardDto);
}
