fuweng11 commented on code in PR #8097:
URL: https://github.com/apache/inlong/pull/8097#discussion_r1206138379


##########
inlong-manager/manager-dao/src/main/resources/mappers/InlongTenantEntityMapper.xml:
##########
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="org.apache.inlong.manager.dao.mapper.InlongTenantEntityMapper">
+  <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    <id column="id" jdbcType="INTEGER" property="id"/>
+    <result column="name" jdbcType="VARCHAR" property="name"/>
+    <result column="description" jdbcType="VARCHAR" property="description"/>
+    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+    <result column="creator" jdbcType="VARCHAR" property="creator"/>
+    <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+    <result column="version" jdbcType="INTEGER" property="version"/>
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, name, description, is_deleted, creator, modifier, create_time, 
modify_time, version
+  </sql>
+
+  <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant (id, name, description, creator, modifier)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
#{description,jdbcType=VARCHAR},
+            #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,
+      </if>
+      <if test="isDeleted != null">
+        is_deleted,
+      </if>
+      <if test="creator != null and creator != ''">
+        creator,
+      </if>
+      <if test="modifier != null and modifier != ''">
+        modifier,
+      </if>
+      <if test="version != null">
+        version,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null and name != ''">
+        name,

Review Comment:
    #{name,jdbcType=VARCHAR},



##########
inlong-manager/manager-dao/src/main/resources/mappers/InlongTenantEntityMapper.xml:
##########
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="org.apache.inlong.manager.dao.mapper.InlongTenantEntityMapper">
+  <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    <id column="id" jdbcType="INTEGER" property="id"/>
+    <result column="name" jdbcType="VARCHAR" property="name"/>
+    <result column="description" jdbcType="VARCHAR" property="description"/>
+    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+    <result column="creator" jdbcType="VARCHAR" property="creator"/>
+    <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+    <result column="version" jdbcType="INTEGER" property="version"/>
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, name, description, is_deleted, creator, modifier, create_time, 
modify_time, version
+  </sql>
+
+  <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant (id, name, description, creator, modifier)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
#{description,jdbcType=VARCHAR},
+            #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,
+      </if>
+      <if test="isDeleted != null">
+        is_deleted,
+      </if>
+      <if test="creator != null and creator != ''">
+        creator,
+      </if>
+      <if test="modifier != null and modifier != ''">
+        modifier,
+      </if>
+      <if test="version != null">
+        version,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,
+      </if>
+      <if test="isDeleted != null">
+        #{isDeleted,jdbcType=INTEGER},
+      </if>
+      <if test="creator != null and creator != ''">
+        creator,

Review Comment:
   #{creator,jdbcType=VARCHAR},



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.inlong.manager.service.tenant;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.common.consts.InlongConstants;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.dao.entity.InlongTenantEntity;
+import org.apache.inlong.manager.dao.mapper.InlongTenantEntityMapper;
+import org.apache.inlong.manager.pojo.tenant.InlongTenantInfo;
+import org.apache.inlong.manager.pojo.tenant.InlongTenantPageRequest;
+import org.apache.inlong.manager.pojo.tenant.InlongTenantRequest;
+import org.apache.inlong.manager.service.user.LoginUserUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class InlongTenantServiceImpl implements InlongTenantService {
+
+    @Autowired
+    private InlongTenantEntityMapper inlongTenantEntityMapper;
+
+    @Override
+    public InlongTenantInfo get(String name) {
+        InlongTenantEntity entity = 
inlongTenantEntityMapper.selectByName(name);
+        return CommonBeanUtils.copyProperties(entity, InlongTenantInfo::new);
+    }
+
+    @Override
+    public Integer save(InlongTenantRequest request) {
+        String name = request.getName();
+        InlongTenantEntity existEntity = 
inlongTenantEntityMapper.selectByName(name);
+        if (existEntity != null) {
+            String errMsg = String.format("tenant already exist for name=%s)", 
name);
+            log.error(errMsg);
+            throw new BusinessException(errMsg);
+        }
+        InlongTenantEntity entity = CommonBeanUtils.copyProperties(request, 
InlongTenantEntity::new);
+        String operator = LoginUserUtils.getLoginUser().getName();
+        entity.setCreator(operator);
+        entity.setModifier(operator);
+        inlongTenantEntityMapper.insert(entity);
+        return entity.getId();
+    }
+
+    @Override
+    public PageInfo<InlongTenantInfo> listByCondition(InlongTenantPageRequest 
request) {
+        PageHelper.startPage(request.getPageNum(), request.getPageSize());
+        Page<InlongTenantEntity> entityPage = 
inlongTenantEntityMapper.selectByCondition(request);
+        return entityPage
+                .toPageInfo(entity -> CommonBeanUtils.copyProperties(entity, 
InlongTenantInfo::new));
+    }
+
+    @Override
+    public Boolean update(InlongTenantRequest request) {
+        InlongTenantEntity exist = 
inlongTenantEntityMapper.selectByName(request.getName());

Review Comment:
   Whether the tenant name can be changed?



##########
inlong-manager/manager-dao/src/main/resources/mappers/InlongTenantEntityMapper.xml:
##########
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="org.apache.inlong.manager.dao.mapper.InlongTenantEntityMapper">
+  <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    <id column="id" jdbcType="INTEGER" property="id"/>
+    <result column="name" jdbcType="VARCHAR" property="name"/>
+    <result column="description" jdbcType="VARCHAR" property="description"/>
+    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+    <result column="creator" jdbcType="VARCHAR" property="creator"/>
+    <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+    <result column="version" jdbcType="INTEGER" property="version"/>
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, name, description, is_deleted, creator, modifier, create_time, 
modify_time, version
+  </sql>
+
+  <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant (id, name, description, creator, modifier)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
#{description,jdbcType=VARCHAR},
+            #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,
+      </if>
+      <if test="isDeleted != null">
+        is_deleted,
+      </if>
+      <if test="creator != null and creator != ''">
+        creator,
+      </if>
+      <if test="modifier != null and modifier != ''">
+        modifier,
+      </if>
+      <if test="version != null">
+        version,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,
+      </if>
+      <if test="isDeleted != null">
+        #{isDeleted,jdbcType=INTEGER},
+      </if>
+      <if test="creator != null and creator != ''">
+        creator,
+      </if>
+      <if test="modifier != null and modifier != ''">
+        modifier,

Review Comment:
   #{modifier,jdbcType=VARCHAR},



##########
inlong-manager/manager-dao/src/main/resources/mappers/InlongTenantEntityMapper.xml:
##########
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="org.apache.inlong.manager.dao.mapper.InlongTenantEntityMapper">
+  <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    <id column="id" jdbcType="INTEGER" property="id"/>
+    <result column="name" jdbcType="VARCHAR" property="name"/>
+    <result column="description" jdbcType="VARCHAR" property="description"/>
+    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+    <result column="creator" jdbcType="VARCHAR" property="creator"/>
+    <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+    <result column="version" jdbcType="INTEGER" property="version"/>
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, name, description, is_deleted, creator, modifier, create_time, 
modify_time, version
+  </sql>
+
+  <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant (id, name, description, creator, modifier)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
#{description,jdbcType=VARCHAR},
+            #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
+          
parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
+    insert into inlong_tenant
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,
+      </if>
+      <if test="isDeleted != null">
+        is_deleted,
+      </if>
+      <if test="creator != null and creator != ''">
+        creator,
+      </if>
+      <if test="modifier != null and modifier != ''">
+        modifier,
+      </if>
+      <if test="version != null">
+        version,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null and name != ''">
+        name,
+      </if>
+      <if test="description != null and description != ''">
+        description,

Review Comment:
   #{description,jdbcType=VARCHAR},



-- 
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: commits-unsubscr...@inlong.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to