package shop.alien.second.platform;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.second.vo.SecondTradeRecordVo;
import shop.alien.second.service.PlatformSecondTradeService;

import java.util.List;

@Slf4j
@Api(tags = {"平台-二手交易记录"})
@ApiSort(1)
@CrossOrigin
@RequiredArgsConstructor
@RestController
@RequestMapping("/platformSecondTrade")
public class PlatformSecondTradeController {

    private final PlatformSecondTradeService secondTradeRecordService;

    @ApiOperation("交易列表")
    @ApiOperationSupport(order = 1)
    @PostMapping("/getTradeRecordPage")
    public R<IPage<SecondTradeRecordVo>> getTradeRecordPage(@RequestBody SecondTradeRecordVo vo) throws Exception {
        log.info("PlatformSecondTradeController.getTradeRecordPage?vo={}", vo.toString());
        return R.data(secondTradeRecordService.getTradeRecordPage(vo));
    }

    @ApiOperation("交易详情")
    @ApiOperationSupport(order = 2)
    @GetMapping("/getTradeRecordById")
    public R<SecondTradeRecordVo> getTradeRecordById(Integer id) throws Exception {
        log.info("PlatformSecondTradeController.getTradeRecordById?id={}",id);
        return R.data(secondTradeRecordService.getTradeRecordById(id));
    }

}
