Forráskód Böngészése

Merge branch 'dev-zenas-20241018' of wangfan/adweb3-server into master

zhangqiang 1 hónapja
szülő
commit
0dc5a1c55a

+ 57 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/facebook/controller/FaceBookController.java

@@ -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("添加成功");
+    }
+}

+ 47 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/facebook/entity/AdwebImFacebook.java

@@ -0,0 +1,47 @@
+package org.jeecg.modules.adweb.marketing.facebook.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author Zenas
+ */
+@Data
+@TableName("adweb_im_facebook")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description = "adweb_im_facebook")
+public class AdwebImFacebook implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    @TableId(type = IdType.AUTO)
+    @Schema(description = "id")
+    private Integer id;
+
+    /** 站点code */
+    @Excel(name = "站点code", width = 15)
+    @Schema(description = "站点code")
+    private String siteCode;
+
+    private String customerId;
+
+    private String refreshToken;
+    /** ctime */
+    @Excel(name = "ctime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "ctime")
+    private Date ctime;
+}

+ 11 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/facebook/mapper/AdwebImFacebookMapper.java

@@ -0,0 +1,11 @@
+package org.jeecg.modules.adweb.marketing.facebook.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.adweb.marketing.facebook.entity.AdwebImFacebook;
+
+/**
+ * @author Zenas
+ */
+public interface AdwebImFacebookMapper extends BaseMapper<AdwebImFacebook> {
+
+}

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/facebook/mapper/xml/AdwebImFacebookMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.adweb.marketing.facebook.mapper.AdwebImFacebookMapper">
+
+</mapper>

+ 6 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/facebook/service/IFacebookService.java

@@ -0,0 +1,6 @@
+package org.jeecg.modules.adweb.marketing.facebook.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.adweb.marketing.facebook.entity.AdwebImFacebook;
+
+public interface IFacebookService extends IService<AdwebImFacebook> {}

+ 15 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/facebook/service/impl/FacebookServiceImpl.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.adweb.marketing.facebook.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.adweb.marketing.facebook.entity.AdwebImFacebook;
+import org.jeecg.modules.adweb.marketing.facebook.mapper.AdwebImFacebookMapper;
+import org.jeecg.modules.adweb.marketing.facebook.service.IFacebookService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Zenas
+ */
+@Service
+public class FacebookServiceImpl extends ServiceImpl<AdwebImFacebookMapper, AdwebImFacebook> implements IFacebookService {
+
+}