Ver Fonte

GTM controller

wfansh há 6 meses atrás
pai
commit
aa345a0589

+ 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;
 
+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 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
@@ -13,10 +20,22 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 @RestController
 @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();
     }
 }