瀏覽代碼

GTM controller

wfansh 6 月之前
父節點
當前提交
aa345a0589
共有 1 個文件被更改,包括 27 次插入8 次删除
  1. 27 8
      src/main/java/com/wechi/adweb/bridge/google/gtm/controller/GTMController.java

+ 27 - 8
src/main/java/com/wechi/adweb/bridge/google/gtm/controller/GTMController.java

@@ -1,11 +1,18 @@
 package com.wechi.adweb.bridge.google.gtm.controller;
 package com.wechi.adweb.bridge.google.gtm.controller;
 
 
+import com.wechi.adweb.bridge.common.APIStatus;
+import com.wechi.adweb.bridge.common.BaseController;
+import com.wechi.adweb.bridge.common.OpenAPIResponse;
+import com.wechi.adweb.bridge.exception.DataException;
+import com.wechi.adweb.bridge.google.gtm.dto.GTMAccountDTO;
+import com.wechi.adweb.bridge.google.gtm.service.GTMService;
+
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 
 
-import org.apache.commons.lang3.RandomStringUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 
 /**
 /**
  * @author wfansh
  * @author wfansh
@@ -13,10 +20,22 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 @Slf4j
 @RestController
 @RestController
 @RequestMapping("/api/google/gtm")
 @RequestMapping("/api/google/gtm")
-public class GTMController {
+public class GTMController extends BaseController {
+
+    @Autowired private GTMService gtmService;
+
+    @PostMapping("/accounts/list")
+    @ResponseBody
+    public OpenAPIResponse<List<GTMAccountDTO>> listGTMAccounts() throws DataException {
+        long start = System.currentTimeMillis();
+        log.info("****** listGTMAccounts() ******");
+
+        List<GTMAccountDTO> gtmAccounts = gtmService.listGTMAccounts();
 
 
-    @GetMapping("/test")
-    public String test() {
-        return RandomStringUtils.randomAlphabetic(10);
+        log.info("****** listGTMAccounts() ****** duration = {} seconds", getElapsedSeconds(start));
+        return OpenAPIResponse.<List<GTMAccountDTO>>builder()
+                .status(APIStatus.SUCCESS)
+                .data(gtmAccounts)
+                .build();
     }
     }
 }
 }