package com.xindazhou.vehicle.api;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.vehicle.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 车辆报警 API
 *
 * 供其他服务调用，用于触发车辆报警推送
 * 车辆服务接收到报警后，会发送到 Redis MQ，然后消息服务监听并推送给客户端
 *
 * @author xindazhou
 */
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 车辆报警")
public interface VehicleAlarmApi {

    String PREFIX = ApiConstants.PREFIX + "/alarm";

    @PostMapping(PREFIX + "/push")
    @Operation(summary = "推送车辆报警")
    @Parameter(name = "userId", description = "用户ID", required = true, example = "1")
    @Parameter(name = "vehicleId", description = "车辆ID", required = true, example = "1")
    @Parameter(name = "alarmType", description = "报警类型", required = true, example = "test_alarm")
    CommonResult<Boolean> pushAlarm(@RequestParam("userId") Long userId,
                                    @RequestParam("vehicleId") Long vehicleId,
                                    @RequestParam("alarmType") String alarmType,
                                    @RequestBody(required = false) Map<String, Object> alarmData);

}

