package org.jeecg.modules.okki.google.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHeaders;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.okki.google.param.OkkiGoogleAdsAccountParam;
import org.jeecg.modules.okki.google.service.IOkkiGoogleAdsAccountService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/website")
public class OkkiGoogleAdsAccountApiController {

    @Resource
    private IOkkiGoogleAdsAccountService okkiGoogleAdsAccountService;
    /**
     *   小满推送数据
     *
     * @param okkiGoogleAdsAccountParam
     * @return
     */
    @AutoLog(value = "Google Ads账号-小满推送数据")
    @PostMapping(value = "/googleAdsAccount")
    public Result<String> add(@RequestBody OkkiGoogleAdsAccountParam okkiGoogleAdsAccountParam, @RequestHeader(HttpHeaders.AUTHORIZATION) String authorization) {
        log.info("请求参数 param" + okkiGoogleAdsAccountParam.toString() + "authorization" + authorization);
        String Authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImRlYW4iLCJleHAiOjE3MTQ0NjU5Njl9.QdCBYR8mioXcKGi1n5RdMQ5RbJHCSGbE8dkdwYuOXh4";
        if (!authorization.equals(Authorization)) {
            return Result.error("sign 验证不通过");
        }
        okkiGoogleAdsAccountService.okkiSave(okkiGoogleAdsAccountParam);
        return Result.OK("添加成功！");
    }
}
