|
@@ -41,7 +41,7 @@ public class GTMController {
|
|
|
/** 获取站点绑定的GTM snippets */
|
|
|
@RequestMapping(value = "/get", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public Result<Pair<String, String>> getGTMSnippets(String siteCode) {
|
|
|
+ public Result<AdwebSite> getGTMSnippets(String siteCode) {
|
|
|
GoogleGTM googleGTM =
|
|
|
googleGTMService.getOne(
|
|
|
new LambdaQueryWrapper<GoogleGTM>().eq(GoogleGTM::getSiteCode, siteCode));
|
|
@@ -50,13 +50,19 @@ public class GTMController {
|
|
|
return Result.error(CommonConstant.SC_INTERNAL_NOT_FOUND_404, "GoogleGTM不存在");
|
|
|
}
|
|
|
|
|
|
- return Result.ok(gtmAdminService.getSnippets(googleGTM.getGtmTagId()));
|
|
|
+ Pair<String, String> snippets = gtmAdminService.getSnippets(googleGTM.getGtmTagId());
|
|
|
+
|
|
|
+ AdwebSite adwebSite = new AdwebSite();
|
|
|
+ adwebSite.setGtmHead(snippets.getLeft());
|
|
|
+ adwebSite.setGtmBody(snippets.getRight());
|
|
|
+
|
|
|
+ return Result.ok(adwebSite);
|
|
|
}
|
|
|
|
|
|
/** 为站点添加GTM snippets */
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public Result<Pair<String, String>> addGTMSnippets(String siteCode, String gaAccountId) {
|
|
|
+ public Result<AdwebSite> addGTMSnippets(String siteCode, String gaAccountId) {
|
|
|
AdwebSite adwebSite = adwebSiteService.getSiteByCode(siteCode);
|
|
|
|
|
|
// 如果GoogleGTM表中已存在,不再创建,返回现有记录
|
|
@@ -67,7 +73,11 @@ public class GTMController {
|
|
|
adwebSite.getName(),
|
|
|
gaAccountId);
|
|
|
|
|
|
- return Result.ok(gtmAdminService.getSnippets(googleGTM.getGtmTagId()));
|
|
|
+ Pair<String, String> snippets = gtmAdminService.getSnippets(googleGTM.getGtmTagId());
|
|
|
+ adwebSite.setGtmHead(snippets.getLeft());
|
|
|
+ adwebSite.setGtmBody(snippets.getRight());
|
|
|
+
|
|
|
+ return Result.ok(adwebSite);
|
|
|
}
|
|
|
|
|
|
/** 获取所有可用的GA帐号 */
|