This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev-2.1.3
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev-2.1.3 by this push:
     new 75f986196 [Improve] commonService improvement
75f986196 is described below

commit 75f986196bf725f0c2e90c2252cd2f2280a707b7
Author: benjobs <[email protected]>
AuthorDate: Sat Jan 20 21:34:38 2024 +0800

    [Improve] commonService improvement
---
 .../console/core/aspect/StreamParkAspect.java      |  6 +-
 .../console/core/service/CommonService.java        | 30 --------
 .../console/core/service/ServiceHelper.java        | 58 ++++++++++++++-
 .../core/service/impl/AppBuildPipeServiceImpl.java |  8 +-
 .../core/service/impl/ApplicationServiceImpl.java  | 13 ++--
 .../core/service/impl/CommonServiceImpl.java       | 87 ----------------------
 .../core/service/impl/FlinkClusterServiceImpl.java |  7 +-
 .../core/service/impl/VariableServiceImpl.java     |  6 +-
 .../system/controller/AccessTokenController.java   |  8 +-
 .../console/system/controller/MenuController.java  |  6 +-
 .../console/system/controller/UserController.java  |  6 +-
 .../system/service/impl/TeamServiceImpl.java       |  6 +-
 12 files changed, 86 insertions(+), 155 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/StreamParkAspect.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/StreamParkAspect.java
index eefea20f5..90f7eade0 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/StreamParkAspect.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/StreamParkAspect.java
@@ -25,7 +25,7 @@ import org.apache.streampark.console.core.entity.Application;
 import org.apache.streampark.console.core.enums.PermissionType;
 import org.apache.streampark.console.core.enums.UserType;
 import org.apache.streampark.console.core.service.ApplicationService;
-import org.apache.streampark.console.core.service.CommonService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.core.task.FlinkRESTAPIWatcher;
 import org.apache.streampark.console.system.entity.AccessToken;
 import org.apache.streampark.console.system.entity.Member;
@@ -57,7 +57,7 @@ import java.util.Objects;
 public class StreamParkAspect {
 
   @Autowired private FlinkRESTAPIWatcher flinkRESTAPIWatcher;
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
   @Autowired private MemberService memberService;
   @Autowired private ApplicationService applicationService;
 
@@ -104,7 +104,7 @@ public class StreamParkAspect {
     PermissionAction permissionAction =
         methodSignature.getMethod().getAnnotation(PermissionAction.class);
 
-    User currentUser = commonService.getCurrentUser();
+    User currentUser = serviceHelper.getLoginUser();
     ApiAlertException.throwIfNull(currentUser, "Permission denied, please 
login first.");
 
     boolean isAdmin = currentUser.getUserType() == UserType.ADMIN;
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/CommonService.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/CommonService.java
deleted file mode 100644
index 2a821f2b5..000000000
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/CommonService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.core.entity.FlinkEnv;
-import org.apache.streampark.console.system.entity.User;
-
-public interface CommonService {
-
-  User getCurrentUser();
-
-  Long getUserId();
-
-  String getSqlClientJar(FlinkEnv flinkEnv);
-}
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ServiceHelper.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ServiceHelper.java
index 048a2549a..7f0e4af3e 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ServiceHelper.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ServiceHelper.java
@@ -17,26 +17,80 @@
 
 package org.apache.streampark.console.core.service;
 
+import org.apache.streampark.console.base.exception.ApiAlertException;
 import org.apache.streampark.console.base.exception.ApiDetailException;
+import org.apache.streampark.console.base.util.WebUtils;
+import org.apache.streampark.console.core.entity.FlinkEnv;
+import org.apache.streampark.console.system.authentication.JWTUtil;
+import org.apache.streampark.console.system.entity.User;
+import org.apache.streampark.console.system.service.UserService;
 import org.apache.streampark.flink.kubernetes.ingress.IngressController;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
 
 import io.fabric8.kubernetes.client.KubernetesClientException;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-@Component
+@Service
 public class ServiceHelper {
 
   @Autowired private SettingService settingService;
 
+  @Autowired private UserService userService;
+
+  private String sqlClientJar = null;
+
+  public User getLoginUser() {
+    String token = (String) SecurityUtils.getSubject().getPrincipal();
+    Long userId = JWTUtil.getUserId(token);
+    return userService.getById(userId);
+  }
+
+  public Long getUserId() {
+    User user = getLoginUser();
+    if (user != null) {
+      return user.getUserId();
+    }
+    return null;
+  }
+
+  public String getSqlClientJar(FlinkEnv flinkEnv) {
+    if (sqlClientJar == null) {
+      File localClient = WebUtils.getAppClientDir();
+      ApiAlertException.throwIfFalse(
+          localClient.exists(), "[StreamPark] " + localClient + " no exists. 
please check.");
+
+      String regex =
+          String.format("streampark-flink-sqlclient_%s-.*\\.jar", 
flinkEnv.getScalaVersion());
+
+      List<String> jars =
+          Arrays.stream(Objects.requireNonNull(localClient.list()))
+              .filter(x -> x.matches(regex))
+              .collect(Collectors.toList());
+
+      ApiAlertException.throwIfTrue(
+          jars.isEmpty(),
+          "[StreamPark] can't found streampark-flink-sqlclient jar in " + 
localClient);
+
+      ApiAlertException.throwIfTrue(
+          jars.size() > 1,
+          "[StreamPark] found multiple streampark-flink-sqlclient jar in " + 
localClient);
+      sqlClientJar = jars.get(0);
+    }
+    return sqlClientJar;
+  }
+
   public String rollViewLog(String path, int offset, int limit) {
     try {
       File file = new File(path);
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
index 1e6042b89..00f46799e 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
@@ -45,11 +45,11 @@ import 
org.apache.streampark.console.core.service.ApplicationBackUpService;
 import org.apache.streampark.console.core.service.ApplicationConfigService;
 import org.apache.streampark.console.core.service.ApplicationLogService;
 import org.apache.streampark.console.core.service.ApplicationService;
-import org.apache.streampark.console.core.service.CommonService;
 import org.apache.streampark.console.core.service.FlinkClusterService;
 import org.apache.streampark.console.core.service.FlinkEnvService;
 import org.apache.streampark.console.core.service.FlinkSqlService;
 import org.apache.streampark.console.core.service.MessageService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.core.service.SettingService;
 import org.apache.streampark.console.core.task.FlinkRESTAPIWatcher;
 import org.apache.streampark.flink.packer.docker.DockerConf;
@@ -119,7 +119,7 @@ public class AppBuildPipeServiceImpl
 
   @Autowired private ApplicationBackUpService backUpService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Autowired private SettingService settingService;
 
@@ -243,7 +243,7 @@ public class AppBuildPipeServiceImpl
             } else {
               Message message =
                   new Message(
-                      commonService.getUserId(),
+                      serviceHelper.getUserId(),
                       app.getId(),
                       app.getJobName().concat(" release failed"),
                       Utils.stringifyException(snapshot.error().exception()),
@@ -523,7 +523,7 @@ public class AppBuildPipeServiceImpl
                     + app.getApplicationType());
         }
       case FLINK_SQL:
-        String sqlDistJar = commonService.getSqlClientJar(flinkEnv);
+        String sqlDistJar = serviceHelper.getSqlClientJar(flinkEnv);
         return Workspace.local().APP_CLIENT().concat("/").concat(sqlDistJar);
       default:
         throw new UnsupportedOperationException(
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java
index 1d26029c1..f15a48d22 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java
@@ -68,7 +68,6 @@ import 
org.apache.streampark.console.core.service.ApplicationBackUpService;
 import org.apache.streampark.console.core.service.ApplicationConfigService;
 import org.apache.streampark.console.core.service.ApplicationLogService;
 import org.apache.streampark.console.core.service.ApplicationService;
-import org.apache.streampark.console.core.service.CommonService;
 import org.apache.streampark.console.core.service.EffectiveService;
 import org.apache.streampark.console.core.service.FlinkClusterService;
 import org.apache.streampark.console.core.service.FlinkEnvService;
@@ -206,7 +205,7 @@ public class ApplicationServiceImpl extends 
ServiceImpl<ApplicationMapper, Appli
 
   @Autowired private SettingService settingService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Autowired private EnvInitializer envInitializer;
 
@@ -222,8 +221,6 @@ public class ApplicationServiceImpl extends 
ServiceImpl<ApplicationMapper, Appli
 
   @Autowired private FlinkK8sWatcherWrapper k8sWatcherWrapper;
 
-  @Autowired private ServiceHelper serviceHelper;
-
   @PostConstruct
   public void resetOptionState() {
     this.baseMapper.resetOptionState();
@@ -741,7 +738,7 @@ public class ApplicationServiceImpl extends 
ServiceImpl<ApplicationMapper, Appli
         appParam.getTeamId(), "The teamId can't be null. Create application 
failed.");
 
     appParam.setBuild(true);
-    appParam.setUserId(commonService.getUserId());
+    appParam.setUserId(serviceHelper.getUserId());
     appParam.setState(FlinkAppState.ADDED.getValue());
     appParam.setRelease(ReleaseState.NEED_RELEASE.get());
     appParam.setOptionState(OptionState.NONE.getValue());
@@ -835,7 +832,7 @@ public class ApplicationServiceImpl extends 
ServiceImpl<ApplicationMapper, Appli
     newApp.setResourceFrom(oldApp.getResourceFrom());
     newApp.setProjectId(oldApp.getProjectId());
     newApp.setModule(oldApp.getModule());
-    newApp.setUserId(commonService.getUserId());
+    newApp.setUserId(serviceHelper.getUserId());
     newApp.setState(FlinkAppState.ADDED.getValue());
     newApp.setRelease(ReleaseState.NEED_RELEASE.get());
     newApp.setOptionState(OptionState.NONE.getValue());
@@ -1268,7 +1265,7 @@ public class ApplicationServiceImpl extends 
ServiceImpl<ApplicationMapper, Appli
     application.setOptionTime(new Date());
     this.baseMapper.updateById(application);
 
-    Long userId = commonService.getUserId();
+    Long userId = serviceHelper.getUserId();
     if (!application.getUserId().equals(userId)) {
       FlinkRESTAPIWatcher.addCanceledApp(application.getId(), userId);
     }
@@ -1526,7 +1523,7 @@ public class ApplicationServiceImpl extends 
ServiceImpl<ApplicationMapper, Appli
       FlinkSql flinkSql = flinkSqlService.getEffective(application.getId(), 
false);
       Utils.notNull(flinkSql);
       // 1) dist_userJar
-      String sqlDistJar = commonService.getSqlClientJar(flinkEnv);
+      String sqlDistJar = serviceHelper.getSqlClientJar(flinkEnv);
       // 2) appConfig
       appConf =
           applicationConfig == null
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CommonServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CommonServiceImpl.java
deleted file mode 100644
index 2a6f9abe6..000000000
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CommonServiceImpl.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.impl;
-
-import org.apache.streampark.console.base.exception.ApiAlertException;
-import org.apache.streampark.console.base.util.WebUtils;
-import org.apache.streampark.console.core.entity.FlinkEnv;
-import org.apache.streampark.console.core.service.CommonService;
-import org.apache.streampark.console.system.authentication.JWTUtil;
-import org.apache.streampark.console.system.entity.User;
-import org.apache.streampark.console.system.service.UserService;
-
-import org.apache.shiro.SecurityUtils;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-@Service
-public class CommonServiceImpl implements CommonService {
-
-  private String sqlClientJar = null;
-
-  @Autowired private UserService userService;
-
-  @Override
-  public User getCurrentUser() {
-    String token = (String) SecurityUtils.getSubject().getPrincipal();
-    Long userId = JWTUtil.getUserId(token);
-    return userService.getById(userId);
-  }
-
-  @Override
-  public Long getUserId() {
-    User user = getCurrentUser();
-    if (user != null) {
-      return user.getUserId();
-    }
-    return null;
-  }
-
-  @Override
-  public String getSqlClientJar(FlinkEnv flinkEnv) {
-    if (sqlClientJar == null) {
-      File localClient = WebUtils.getAppClientDir();
-      ApiAlertException.throwIfFalse(
-          localClient.exists(), "[StreamPark] " + localClient + " no exists. 
please check.");
-      List<String> jars =
-          Arrays.stream(Objects.requireNonNull(localClient.list()))
-              .filter(
-                  x ->
-                      x.matches(
-                          "streampark-flink-sqlclient_" + 
flinkEnv.getScalaVersion() + "-.*\\.jar"))
-              .collect(Collectors.toList());
-      if (jars.isEmpty()) {
-        throw new ApiAlertException(
-            "[StreamPark] can't found streampark-flink-sqlclient jar in " + 
localClient);
-      }
-      if (jars.size() > 1) {
-        throw new ApiAlertException(
-            "[StreamPark] found multiple streampark-flink-sqlclient jar in " + 
localClient);
-      }
-      sqlClientJar = jars.get(0);
-    }
-    return sqlClientJar;
-  }
-}
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkClusterServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkClusterServiceImpl.java
index 9a2bf1792..a0b56075a 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkClusterServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkClusterServiceImpl.java
@@ -29,7 +29,6 @@ import org.apache.streampark.console.core.entity.FlinkCluster;
 import org.apache.streampark.console.core.entity.FlinkEnv;
 import org.apache.streampark.console.core.mapper.FlinkClusterMapper;
 import org.apache.streampark.console.core.service.ApplicationService;
-import org.apache.streampark.console.core.service.CommonService;
 import org.apache.streampark.console.core.service.FlinkClusterService;
 import org.apache.streampark.console.core.service.FlinkEnvService;
 import org.apache.streampark.console.core.service.ServiceHelper;
@@ -84,14 +83,12 @@ public class FlinkClusterServiceImpl extends 
ServiceImpl<FlinkClusterMapper, Fli
 
   @Autowired private FlinkEnvService flinkEnvService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Autowired private ApplicationService applicationService;
 
   @Autowired private YarnQueueService yarnQueueService;
 
-  @Autowired private ServiceHelper serviceHelper;
-
   @Override
   public ResponseResult check(FlinkCluster cluster) {
     ResponseResult result = new ResponseResult();
@@ -138,7 +135,7 @@ public class FlinkClusterServiceImpl extends 
ServiceImpl<FlinkClusterMapper, Fli
 
   @Override
   public Boolean create(FlinkCluster flinkCluster) {
-    flinkCluster.setUserId(commonService.getUserId());
+    flinkCluster.setUserId(serviceHelper.getUserId());
     boolean successful = validateQueueIfNeeded(flinkCluster);
     ApiAlertException.throwIfFalse(
         successful, String.format(ERROR_CLUSTER_QUEUE_HINT, 
flinkCluster.getYarnQueue()));
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
index 32c2a74e1..61af7eaaa 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
@@ -27,8 +27,8 @@ import org.apache.streampark.console.core.entity.Variable;
 import org.apache.streampark.console.core.enums.ReleaseState;
 import org.apache.streampark.console.core.mapper.VariableMapper;
 import org.apache.streampark.console.core.service.ApplicationService;
-import org.apache.streampark.console.core.service.CommonService;
 import org.apache.streampark.console.core.service.FlinkSqlService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.core.service.VariableService;
 
 import org.apache.commons.collections.CollectionUtils;
@@ -69,7 +69,7 @@ public class VariableServiceImpl extends 
ServiceImpl<VariableMapper, Variable>
 
   @Autowired private FlinkSqlService flinkSqlService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Override
   @Transactional(rollbackFor = Exception.class)
@@ -77,7 +77,7 @@ public class VariableServiceImpl extends 
ServiceImpl<VariableMapper, Variable>
     if (this.findByVariableCode(variable.getTeamId(), 
variable.getVariableCode()) != null) {
       throw new ApiAlertException("Sorry, the variable code already exists.");
     }
-    variable.setCreatorId(commonService.getUserId());
+    variable.setCreatorId(serviceHelper.getUserId());
     this.save(variable);
   }
 
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/AccessTokenController.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/AccessTokenController.java
index 4bbc82ae2..fbd647658 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/AccessTokenController.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/AccessTokenController.java
@@ -22,7 +22,7 @@ import org.apache.streampark.console.base.domain.RestRequest;
 import org.apache.streampark.console.base.domain.RestResponse;
 import org.apache.streampark.console.base.exception.InternalException;
 import org.apache.streampark.console.core.enums.AccessTokenState;
-import org.apache.streampark.console.core.service.CommonService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.system.entity.AccessToken;
 import org.apache.streampark.console.system.service.AccessTokenService;
 
@@ -52,7 +52,7 @@ public class AccessTokenController {
 
   @Autowired private AccessTokenService accessTokenService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   /** generate token string */
   @Operation(summary = "Create token")
@@ -87,7 +87,7 @@ public class AccessTokenController {
   @Operation(summary = "Verify current user token")
   @PostMapping(value = "check")
   public RestResponse verifyToken() {
-    Long userId = commonService.getUserId();
+    Long userId = serviceHelper.getUserId();
     RestResponse restResponse = RestResponse.success();
     if (userId != null) {
       AccessToken accessToken = accessTokenService.getByUserId(userId);
@@ -170,7 +170,7 @@ public class AccessTokenController {
     curlBuilder
         .addHeader("Content-Type", "application/x-www-form-urlencoded; 
charset=UTF-8")
         .addHeader(
-            "Authorization", 
accessTokenService.getByUserId(commonService.getUserId()).getToken());
+            "Authorization", 
accessTokenService.getByUserId(serviceHelper.getUserId()).getToken());
 
     if ("/flink/app/start".equalsIgnoreCase(path)) {
       resultCURL =
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java
index 956a7c5ff..6252df3a1 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java
@@ -19,7 +19,7 @@ package org.apache.streampark.console.system.controller;
 
 import org.apache.streampark.console.base.domain.RestResponse;
 import org.apache.streampark.console.base.domain.router.VueRouter;
-import org.apache.streampark.console.core.service.CommonService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.system.entity.Menu;
 import org.apache.streampark.console.system.service.MenuService;
 
@@ -49,14 +49,14 @@ public class MenuController {
 
   @Autowired private MenuService menuService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Operation(summary = "List menu-routes")
   @PostMapping("router")
   public RestResponse getUserRouters(Long teamId) {
     // TODO The teamId is required, get routers should be called after choose 
teamId.
     ArrayList<VueRouter<Menu>> routers =
-        this.menuService.getUserRouters(commonService.getUserId(), teamId);
+        this.menuService.getUserRouters(serviceHelper.getUserId(), teamId);
     return RestResponse.success(routers);
   }
 
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java
index 1dec3fc5b..29113a1f7 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java
@@ -24,7 +24,7 @@ import 
org.apache.streampark.console.base.exception.ApiAlertException;
 import org.apache.streampark.console.core.annotation.PermissionAction;
 import org.apache.streampark.console.core.enums.LoginType;
 import org.apache.streampark.console.core.enums.PermissionType;
-import org.apache.streampark.console.core.service.CommonService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.system.entity.Team;
 import org.apache.streampark.console.system.entity.User;
 import org.apache.streampark.console.system.service.TeamService;
@@ -62,7 +62,7 @@ public class UserController {
 
   @Autowired private TeamService teamService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Operation(summary = "List users")
   @PostMapping("list")
@@ -148,7 +148,7 @@ public class UserController {
     if (team == null) {
       return RestResponse.fail("TeamId is invalid, set team failed.", 
ResponseCode.CODE_FAIL_ALERT);
     }
-    User user = commonService.getCurrentUser();
+    User user = serviceHelper.getLoginUser();
     ApiAlertException.throwIfNull(user, "Current login user is null, set team 
failed.");
     // 1) set the latest team
     userService.setLastTeam(teamId, user.getUserId());
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java
index 1361f303f..966bab4d8 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java
@@ -22,8 +22,8 @@ import 
org.apache.streampark.console.base.exception.ApiAlertException;
 import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
 import org.apache.streampark.console.core.enums.UserType;
 import org.apache.streampark.console.core.service.ApplicationService;
-import org.apache.streampark.console.core.service.CommonService;
 import org.apache.streampark.console.core.service.ProjectService;
+import org.apache.streampark.console.core.service.ServiceHelper;
 import org.apache.streampark.console.core.service.VariableService;
 import org.apache.streampark.console.system.entity.Team;
 import org.apache.streampark.console.system.entity.User;
@@ -61,7 +61,7 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, 
Team> implements Te
 
   @Autowired private VariableService variableService;
 
-  @Autowired private CommonService commonService;
+  @Autowired private ServiceHelper serviceHelper;
 
   @Override
   public IPage<Team> page(Team team, RestRequest request) {
@@ -92,7 +92,7 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, 
Team> implements Te
 
   @Override
   public void deleteTeam(Long teamId) {
-    log.info("{} Proceed delete team[Id={}]", 
commonService.getCurrentUser().getUsername(), teamId);
+    log.info("{} Proceed delete team[Id={}]", 
serviceHelper.getLoginUser().getUsername(), teamId);
     Team team = this.getById(teamId);
     // TODO The AssertUtils.checkApiAlert can simplify the exception.
     if (team == null) {

Reply via email to