package com.xindazhou.business.api.service;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.framework.common.pojo.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 维保订单 API 接口
 *
 * @author xindazhou
 */
@FeignClient(name = "xdz-platform", contextId = "maintenanceOrderApi")
public interface MaintenanceOrderApi {

    /**
     * 获得维保订单分页列表
     *
     * @param pageNo 页码
     * @param pageSize 每页条数
     * @param keyword 关键字
     * @param status 订单状态
     * @param startTime 创建时间开始
     * @param endTime 创建时间结束
     * @return 维保订单分页
     */
    @GetMapping("/service/maintenance/order/page")
    CommonResult<PageResult<Map<String, Object>>> getMaintenanceOrderPage(
            @RequestParam("pageNo") Integer pageNo,
            @RequestParam("pageSize") Integer pageSize,
            @RequestParam(value = "keyword", required = false) String keyword,
            @RequestParam(value = "status", required = false) Integer status,
            @RequestParam(value = "startTime", required = false) String startTime,
            @RequestParam(value = "endTime", required = false) String endTime
    );

    /**
     * 获得维保订单
     *
     * @param id 订单ID
     * @return 维保订单
     */
    @GetMapping("/service/maintenance/order/{id}")
    CommonResult<Map<String, Object>> getMaintenanceOrder(@PathVariable("id") Long id);

    /**
     * 创建维保订单
     *
     * @param createReqVO 创建信息
     * @return 订单ID
     */
    @PostMapping("/service/maintenance/order")
    CommonResult<Long> createMaintenanceOrder(@RequestBody Map<String, Object> createReqVO);

    /**
     * 更新维保订单
     *
     * @param id 订单ID
     * @param updateReqVO 更新信息
     * @return 是否成功
     */
    @PutMapping("/service/maintenance/order/{id}")
    CommonResult<Boolean> updateMaintenanceOrder(@PathVariable("id") Long id,
                                                  @RequestBody Map<String, Object> updateReqVO);

    /**
     * 删除维保订单
     *
     * @param id 订单ID
     * @return 是否成功
     */
    @DeleteMapping("/service/maintenance/order/{id}")
    CommonResult<Boolean> deleteMaintenanceOrder(@PathVariable("id") Long id);

    /**
     * 更新维保订单状态
     *
     * @param id 订单ID
     * @param statusUpdateReqVO 状态更新信息
     * @return 是否成功
     */
    @PutMapping("/service/maintenance/order/{id}/status")
    CommonResult<Boolean> updateMaintenanceOrderStatus(@PathVariable("id") Long id,
                                                        @RequestBody Map<String, Object> statusUpdateReqVO);

}

