package com.zfire.mall.manager.controller.displace.order;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zfire.mall.manager.bean.displace.order.DisplaceBean;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.displace.order.DisplaceOrderLogic;
import com.zfire.mall.manager.logic.displace.order.DisplaceOrderV2Logic;
import com.zfire.mall.manager.plus.entity.OrderDisplaceRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.redis.util.RedisLockRegistry;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;

@Slf4j
@RestController
@Api(value = "置换单V2", tags ={"置换单V2"} )
@RequestMapping(value = "/displace/order/v2", produces = "application/json; charset=utf-8")
public class DisplaceOrderV2Controller {

    @Autowired
    DisplaceOrderV2Logic displaceOrderV2Logic;
    @Autowired
    RedisLockRegistry redisLockRegistry;

    @ApiOperation("添加置换")
    @PostMapping("/add")
    public ResponseHelper add(@RequestBody DisplaceBean displaceBean) throws InterruptedException {
        displaceOrderV2Logic.add(displaceBean);
        return ResponseHelper.success();
    }


    @ApiOperation("置换详情")
    @GetMapping("/record/list")
    public ResponseHelper<List<List<OrderDisplaceRecord>>> recordList(
            @RequestParam String orderId
    ) throws InterruptedException {
        List<List<OrderDisplaceRecord>> lists = displaceOrderV2Logic.recordList(orderId);
        return ResponseHelper.success(lists);
    }

}
