package com.yifu.cloud.plus.v1.yifu.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author licancan
 * @description 订单controller
 * @date 2022-08-29 09:05:23
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/order")
@Tag(name = "订单相关")
public class OrderController {
	@Resource
	private TOrderService tOrderService;

	/**
	 * 订单列表分页查询
	 *
	 * @author licancan
	 * @param page
	 * @param param
	 * @return {@link R<IPage<OrderListVO>>}
	 */
	@Operation(summary = "订单列表分页查询", description = "订单列表分页查询")
	@GetMapping("/getOrderPageList")
	public R<IPage<OrderListVO>> getOrderPageList(Page<OrderListParam> page, OrderListParam param) {
		return R.ok(tOrderService.getOrderPageList(page,param));
	}

	/**
	 * 订单列表不分页查询
	 *
	 * @author licancan
	 * @param param
	 * @return {@link R<List<OrderListVO>>}
	 */
	@Operation(summary = "订单列表不分页查询", description = "订单列表不分页查询")
	@GetMapping("/getOrderList")
	public R<List<OrderListVO>> getOrderList(OrderListParam param) {
		return R.ok(tOrderService.getOrderList(param));
	}

	/**
	 * 变更订单状态
	 *
	 * @author licancan
	 * @param id
	 * @param status
	 * @return {@link R< String>}
	 */
	@GetMapping("/handleOrder")
	@Operation(summary = "变更订单状态", description = "变更订单状态")
	public R<String> handleOrder(@RequestParam String id,@RequestParam Integer status) {
		return tOrderService.handleOrder(id,status);
	}

}
