|
@@ -0,0 +1,57 @@
|
|
|
|
+package org.jeecg.modules.adweb.marketing.facebook.controller;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+
|
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.modules.adweb.marketing.facebook.entity.AdwebImFacebook;
|
|
|
|
+import org.jeecg.modules.adweb.marketing.facebook.service.IFacebookService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.util.Optional;
|
|
|
|
+
|
|
|
|
+@Tag(name = "Facebook - 帐号,广告,报表数据等")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/marketing/facebook")
|
|
|
|
+@Slf4j
|
|
|
|
+public class FaceBookController {
|
|
|
|
+
|
|
|
|
+ @Autowired private IFacebookService facebookService;
|
|
|
|
+
|
|
|
|
+ /** 获取站点绑定的Facebook account */
|
|
|
|
+ @GetMapping("/account/get")
|
|
|
|
+ public Result<AdwebImFacebook> getFacebookAccount(@RequestParam String siteCode) {
|
|
|
|
+ log.info("getFacebookAccount: siteCode={}", siteCode);
|
|
|
|
+ AdwebImFacebook imFacebook =
|
|
|
|
+ facebookService.getOne(
|
|
|
|
+ new LambdaQueryWrapper<AdwebImFacebook>().eq(AdwebImFacebook::getSiteCode, siteCode),
|
|
|
|
+ false);
|
|
|
|
+ log.info("getFacebookAccount: imFacebook={}", imFacebook);
|
|
|
|
+ return Result.ok(imFacebook);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /** 为站点绑定Facebook account */
|
|
|
|
+ @PostMapping("/account/add")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Result<String> addFacebookAccount(
|
|
|
|
+ @RequestParam String siteCode,
|
|
|
|
+ @RequestParam String customerId,
|
|
|
|
+ @RequestParam(required = false) String refreshToken) {
|
|
|
|
+ AdwebImFacebook facebook =
|
|
|
|
+ facebookService.getOne(
|
|
|
|
+ new LambdaQueryWrapper<AdwebImFacebook>().eq(AdwebImFacebook::getSiteCode, siteCode),
|
|
|
|
+ false);
|
|
|
|
+ facebook = Optional.ofNullable(facebook).orElse(new AdwebImFacebook());
|
|
|
|
+
|
|
|
|
+ facebook.setSiteCode(siteCode);
|
|
|
|
+ facebook.setCustomerId(customerId);
|
|
|
|
+ facebook.setRefreshToken(refreshToken);
|
|
|
|
+ facebookService.saveOrUpdate(facebook);
|
|
|
|
+
|
|
|
|
+ return Result.ok("添加成功");
|
|
|
|
+ }
|
|
|
|
+}
|