package com.bizzan.bitrade.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.bizzan.bitrade.entity.FollowWallet;
import com.bizzan.bitrade.service.FollowWalletService;
import com.bizzan.bitrade.service.WalletTransRecordService;
import com.bizzan.bitrade.vo.IWalletTransStat;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/follow")
@Slf4j
public class InnerFollowController {

    @Autowired
    private FollowWalletService followWalletService;
    @Autowired
    private WalletTransRecordService walletTransRecordService;

    @PostMapping("wallets")
    public List<FollowWallet> wallets(String ids) {
        log.info("follow/wallets ids={}", ids);
        List<Long> idList = JSON.parseArray(ids, Long.class);
        return followWalletService.findByIds(idList);
    }

    @PostMapping("tranfers")
    public List<IWalletTransStat> tranfers(String ids) {
        log.info("follow/tranfers ids={}", ids);
        List<Long> idList = JSON.parseArray(ids, Long.class);
        List<IWalletTransStat> statList = walletTransRecordService.statWalletTrans(idList);
        log.info("follow/tranfers result={}", statList);
        return statList;
    }
}
