package cn.iocoder.yudao.module.order.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.order.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.order.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.order.vo.RepairOrderInfoRespVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 维修模块 订单")
@RestController
@RequestMapping("/repair/order-info")
@Validated
public class ApiOrderInfoController {

    @Resource
    private RepairOrderInfoService repairOrderInfoService;

    /**
     * 小程序端查询客户个人所有订单
     * @author vinjor-M
     * @date 14:58 2024/10/15
     * @param respVO
     * @param pageNo
     * @param pageSize
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
    **/
    @GetMapping("/page")
    @Operation(summary = "订单分页查询")
    @TenantIgnore
    public CommonResult<?> getOrderPage(RepairOrderInfoRespVO respVO,
                                        @RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
                                        @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
        // 当前登录用户的id
        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
        respVO.setUserId(loginUserId);
        Page<RepairOrderInfo> page = new Page<>(pageNo, pageSize);
        return success(repairOrderInfoService.getOrderPageByStatus(respVO, page));
    }
}