Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-8087][Manager] Add definition of Inlong tenant table #8090

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.dao.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
public class InlongTenantEntity implements Serializable {

private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private String description;
private Integer isDeleted;
private String creator;
private String modifier;
private Date createTime;
private Date modifyTime;
private Integer version;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.dao.mapper;

import org.apache.inlong.manager.dao.entity.InlongTenantEntity;
import org.springframework.stereotype.Repository;

@Repository
public interface InlongTenantEntityMapper {

int insert(InlongTenantEntity record);

int insertSelective(InlongTenantEntity record);

int updateById(InlongTenantEntity record);

int updateByIdSelective(InlongTenantEntity record);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<!-- Database connection URL, username, password -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/apache_inlong_manager?nullCatalogMeansCurrent=true"
userId="root" password="123456">
userId="root" password="inlong">
</jdbcConnection>

<javaTypeResolver>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?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" parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
insert into inlong_tenant (id, name, description,
is_deleted, creator, modifier,
create_time, modify_time)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{isDeleted,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" 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="createTime != null">
create_time,
</if>
<if test="modifyTime != null">
modify_time,
</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, jdbcType=VARCHAR},
</if>
<if test="description != null and description != ''">
#{description,jdbcType=VARCHAR},
</if>
<if test="isDeleted != null">
#{isDeleted,jdbcType=INTEGER},
</if>
<if test="creator != null and creator != ''">
#{creator, jdbcType=VARCHAR},
</if>
<if test="modifier != null and modifier != ''">
#{modifier, jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
update inlong_tenant
set name = #{name, jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
is_deleted = #{isDeleted, jdbcType=INTEGER},
modifier = #{modifier, jdbcType=VARCHAR},
version = #{version, jdbcType=INTEGER} + 1
where id = #{id, jdbcType=INTEGER}
and version = #{version, jdbcType=INTEGER}
</update>
<update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.InlongTenantEntity">
update inlong_tenant
<set>
<if test="name != null and name != ''">
name = #{name, jdbcType=VARCHAR},
</if>
<if test="description != null and description != ''">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted, jdbcType=INTEGER},
</if>
<if test="modifier != null and modifier != ''">
modifier = #{modifier, jdbcType=VARCHAR},
</if>
version = #{version, jdbcType=INTEGER} + 1
</set>
where id = #{id, jdbcType=INTEGER}
and version = #{version, jdbcType=INTEGER}
</update>
</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.pojo.tenant;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Date;

@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("Inlong tenant info")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, visible = true, property = "type")
public class TenantInfo {

@ApiModelProperty(value = "Primary key")
private Integer id;

@ApiModelProperty(value = "Tenant name")
private String name;

@ApiModelProperty(value = "Description of the tenant")
private String description;

@ApiModelProperty(value = "Name of in creator")
private String creator;

@ApiModelProperty(value = "Name of in modifier")
private String modifier;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date modifyTime;

@ApiModelProperty(value = "Version number")
private Integer version;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.pojo.tenant;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.inlong.manager.pojo.common.PageRequest;

import javax.validation.constraints.Pattern;

@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel("Tenant paging query request")
public class TenantPageRequest extends PageRequest {

@ApiModelProperty(value = "Primary key")
private Integer id;

@ApiModelProperty(value = "Tenant name")
@Pattern(regexp = "^[A-Za-z0-9_-]{1,256}$", message = "only supports letters, numbers, '-', or '_'")
private String name;

@ApiModelProperty(value = "Current user", hidden = true)
private String currentUser;

@ApiModelProperty(value = "Whether the current user is in the administrator role", hidden = true)
private Boolean isAdminRole;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.pojo.tenant;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.inlong.manager.common.validation.UpdateByIdValidation;
import org.apache.inlong.manager.common.validation.UpdateByKeyValidation;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("Tenant request")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, visible = true, property = "type")
public class TenantRequest {

@ApiModelProperty(value = "Primary key")
private Integer id;

@ApiModelProperty(value = "Tenant name")
@Pattern(regexp = "^[A-Za-z0-9_-]{1,256}$", message = "only supports letters, numbers, '-', or '_'")
private String name;

@ApiModelProperty(value = "Description of the tenant")
@Length(max = 256, message = "length must be less than or equal to 256")
private String description;

@ApiModelProperty(value = "Version number")
@NotNull(groups = {UpdateByIdValidation.class, UpdateByKeyValidation.class}, message = "version cannot be null")
private Integer version;
}
Loading