package cn.iocoder.yudao.module.app.apy;

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("/userClient/order")
@Validated
public class ClientOrderApi {
    @Resource
    private RepairOrderInfoService repairOrderInfoService;


    @GetMapping("/pageCreator")
    @Operation(summary = "订单分页查询")
    @TenantIgnore
    public CommonResult<?> pageCreator(RepairOrderInfoRespVO respVO,
                                        @RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
                                        @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
        // 当前登录用户的id
        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
        respVO.setCreator(String.valueOf(loginUserId));
        Page<RepairOrderInfo> page = new Page<>(pageNo, pageSize);
        return success(repairOrderInfoService.pageCreator(respVO, page));
    }
}
