package com.fzm.mall.server.front.order.controller;


import com.alibaba.fastjson.JSONObject;
import com.fzm.mall.server.front.base.PageVO;
import com.fzm.mall.server.front.base.ResponseVO;
import com.fzm.mall.server.front.constant.MallResponseEnum;
import com.fzm.mall.server.front.goods.model.vo.PageVo;
import com.fzm.mall.server.front.goods.model.vo.UserAuctionVO;
import com.fzm.mall.server.front.order.model.Deposit;
import com.fzm.mall.server.front.order.service.IBiddingRecordService;
import com.fzm.mall.server.front.order.service.IDepositService;
import com.fzm.mall.server.front.user.model.Header;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import springfox.documentation.annotations.ApiIgnore;

/**
 * @author tdz
 * @date 2021/09/02 11:26
 */
@Api(tags = "保证金接口", description = "用户拍卖时候下保证金等")
@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping(value = "/mall/deposit", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DepositController {
    private final IDepositService depositService;

    @ApiOperation(value = "根据uid查询用户保证金记录")
    @PostMapping("/getDepositByUid")
    public ResponseVO<Deposit> getDepositByUid(@RequestBody JSONObject obj, @ApiIgnore @RequestAttribute Header header) {
        String uid = header.getUid();
        String auctionId = obj.getString("auctionId");
        Deposit deposit = depositService.getDepositByUid(uid, auctionId);
        return new ResponseVO(MallResponseEnum.SUCCESS, deposit);
    }
}
