package com.hr.controller;

import com.hr.param.InterfaceCalledQueryParam;
import com.hr.repository.service.IpOrderService;
import com.hr.vo.CallbackHistoryVO;
import com.hr.vo.InterfaceCalledDetail;
import com.hr.vo.IpInterfaceCallVO;
import com.yy.basedevelop.common.data.BasePageResult;
import com.yy.basedevelop.common.data.BaseReturnDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.List;

@RestController
@RequestMapping("/ipInterface/call")
@Tag(name = "接口调用管理")
public class IpInterfaceCallbackController {


    @Autowired
    private IpOrderService ipOrderService;

    /**
     * 分页查询
     * @param ipInterfaceCalledQueryParam 筛选条件
     * @return 查询结果
     */
    @Operation(summary = "分页查询接口调用记录")
    @GetMapping("/list")
    public Mono<BasePageResult<IpInterfaceCallVO>> queryList(InterfaceCalledQueryParam ipInterfaceCalledQueryParam){
        return Mono.just(ipOrderService.queryList(ipInterfaceCalledQueryParam));
    }

    /**
     * 查询接口的调用详情
     * @param id 筛选条件
     * @return 查询结果
     */
    @Operation(summary = "查询接口调用详情")
    @GetMapping("/detail/{id}")
    public Mono<BaseReturnDto<InterfaceCalledDetail>> interfaceDetail(@PathVariable Long id){
        InterfaceCalledDetail vo = ipOrderService.interfaceDetail(id);
        return Mono.just(BaseReturnDto.success(vo));
    }


    /**
     * 接口调用参数明细
     *
     * @return 查询结果
     */
    @Operation(summary = "查询接口回调记录")
    @GetMapping("/callback/history/{id}")
    public Mono<BaseReturnDto<List<CallbackHistoryVO>>> queryList(@PathVariable long id){
        List<CallbackHistoryVO> list = ipOrderService.callbackHistory(id);
        return Mono.just(BaseReturnDto.success(list));
    }
}
