macksonmu commented on code in PR #1831:
URL: 
https://github.com/apache/incubator-streampark/pull/1831#discussion_r996295127


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/VariableServiceImpl.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.system.service.impl;
+
+import org.apache.streampark.console.base.domain.RestRequest;
+import org.apache.streampark.console.core.entity.Application;
+import org.apache.streampark.console.core.service.ApplicationService;
+import org.apache.streampark.console.system.entity.Variable;
+import org.apache.streampark.console.system.mapper.VariableMapper;
+import org.apache.streampark.console.system.service.VariableService;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, 
rollbackFor = Exception.class)
+public class VariableServiceImpl extends ServiceImpl<VariableMapper, Variable> 
implements VariableService {
+
+    @Autowired
+    private ApplicationService applicationService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void createVariable(Variable variable) throws Exception {
+        this.save(variable);
+    }
+
+    @Override
+    public IPage<Variable> findVariables(Variable variable, RestRequest 
request) {
+        Page<Variable> page = new Page<>();
+        page.setCurrent(request.getPageNum());
+        page.setSize(request.getPageSize());
+        return this.baseMapper.findVariable(page, variable);
+    }
+
+    @Override
+    public void updateVariable(Variable variable) throws Exception {
+        updateById(variable);
+    }
+
+    @Override
+    public Variable findByVariableCode(Long teamId, String variableCode) {
+        return baseMapper.selectOne(new LambdaQueryWrapper<Variable>()
+            .eq(Variable::getVariableCode, variableCode)
+            .eq(Variable::getTeamId, teamId));
+    }
+
+    @Override
+    public List<Variable> findByTeamId(Long teamId) {
+        return baseMapper.selectByTeamId(teamId);
+    }
+
+    @Override
+    @SneakyThrows
+    public List<Application> findDependByCode(Variable variable) {
+        return null;

Review Comment:
   Yes, it will be used in the next PR. When deleting a variable, it is 
necessary to detect whether the variable is referenced. If it is referenced, it 
will prompt that it cannot be deleted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to