package com.fs.company.controller.baidu;

import com.fs.baiduApi.BaiduApiService;
import com.fs.baiduApi.Param.ConversionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/baidu/conversion")
public class Conversion {
    @Autowired
    private BaiduApiService conversionDataService;

//    @Value("${baidu.token}")
    @Value("12345649")
    private String token;
    /**
     * 发送单个转换数据
     *
     * @param conversionType 转换类型
     * @return 是否发送成功
     */
    @PostMapping("/single")
    public boolean sendSingleConvertData(@RequestBody ConversionType conversionType) {
        ArrayList<ConversionType> conversionTypes = new ArrayList<>();
        conversionTypes.add(conversionType);
        return conversionDataService.sendConvertData(token, conversionTypes);
    }

    /**
     * 发送多个转换数据
     *
     * @param conversionTypeList 转换类型列表
     * @return 是否发送成功
     */
    @PostMapping("/multiple")
    public boolean sendMultipleConvertData( @RequestBody List<ConversionType> conversionTypeList) {

        return conversionDataService.sendConvertData(token, conversionTypeList);
    }
}
