package org.springblade.device.feign;

import io.swagger.annotations.ApiParam;
import org.springblade.core.tool.api.R;
import org.springblade.device.dto.DispatchTask;
import org.springblade.device.entity.DoorDevice;
import org.springblade.device.vo.DoorDeviceVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 *  Feign
 *
 * @author lianghanqiang
 * @since 2021-04-19
 */
@FeignClient(value = "cyzh-smart-device",path = "/feign/doordevice")
public interface IDoorDeviceClient  {

	/**
	 * 详情
	 */
	@GetMapping("/detail")
    DoorDeviceVO detail(@SpringQueryMap DoorDevice doorDevice);

	/**
	 * 根据id获取详情
	 */
	@GetMapping("/getById")
	DoorDevice getById(@RequestParam Long id);

	/**
	 * 查询
	 */
	@GetMapping("/list")
    List<DoorDeviceVO> list(@SpringQueryMap DoorDevice doorDevice);

	/**
	 * 查询
	 */
	@GetMapping("/listMap")
	List<DoorDeviceVO> listMap(@RequestParam Map<String,Object> doorDevice);



	/**
	 * 新增
	 */
	@PostMapping("/save")
	boolean save(@Valid @RequestBody DoorDevice doorDevice);

	/**
	 * 修改
	 */
	@PostMapping("/update")
    boolean update(@Valid @RequestBody DoorDevice doorDevice);

	/**
	 * 新增或修改
	 */
	@PostMapping("/submit")
    boolean submit(@Valid @RequestBody DoorDevice doorDevice);


	/**
	 * 删除
	 */
	@PostMapping("/remove")
    boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids);

	/**
	 * 下发人脸到住户所住区域的通用设备，不包括特定授权设备
	 * @param task 任务
	 * @return boolean
	 */
	@PostMapping(value = "/device/pushUserFace/{operType}")
	R pushUserFace(@RequestBody DispatchTask task, @PathVariable(value = "operType") Integer operType);


	@GetMapping("/getListByMacAddresses")
	List<DoorDevice> getListByMacAddresses(List<String> macAddresses);

	@GetMapping("/getListByResidentialAndUnit/{residentialId}/{unitId}")
	List<DoorDeviceVO> getListByResidentialAndUnit(@PathVariable("residentialId") Long residentialId,@PathVariable("unitId") Long unitId, @RequestParam(value = "localType", required = false) Integer localType);

	@GetMapping("/getListByAgencyAndResidential/{agencyId}/{residentialId}")
	List<DoorDeviceVO> getListByAgencyAndResidential(@PathVariable("agencyId") Long agencyId,@PathVariable("residentialId") Long residentialId);

	@GetMapping("/getBySerialNum")
	DoorDeviceVO getBySerialNum(@RequestParam String serialNum);

	@GetMapping("/heartbeat")
	R heartbeat(@RequestParam String serialNum);

	@GetMapping("/getListByAgencyId")
	List<DoorDevice> getListByAgencyId(@RequestParam Long agencyId);

	@PostMapping("/remoteOpenDoor")
	R remoteOpenDoor(@RequestParam String userId, @RequestParam String userName, @RequestParam String userType, @RequestParam String serialNum, @RequestParam String factory, @RequestParam boolean isOpen);

	@PostMapping("/listByIds")
	List<DoorDevice> listByIds(@RequestParam(value = "ids") String ids);
}
