This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new 4d6dff0f1 feat(basedata-manager): add DatasourceEnv manager restful
api (#3183)
4d6dff0f1 is described below
commit 4d6dff0f1afb3eb5f26f06f4d3d226895a4591af
Author: jack tao <[email protected]>
AuthorDate: Fri Sep 2 14:18:02 2022 +0800
feat(basedata-manager): add DatasourceEnv manager restful api (#3183)
---
.../server/dao/DatasourceEnvMapper.java | 32 +++
.../server/dao/mapper/DatasourceEnvMapper.xml | 51 +++++
.../server/domain/DatasourceEnvEntity.java | 227 +++++++++++++++++++++
.../server/restful/DatasourceEnvRestfulApi.java | 91 +++++++++
.../server/service/DatasourceEnvService.java | 31 +++
.../service/impl/DatasourceEnvServiceImpl.java | 46 +++++
6 files changed, 478 insertions(+)
diff --git
a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/DatasourceEnvMapper.java
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/DatasourceEnvMapper.java
new file mode 100644
index 000000000..2db98a7d1
--- /dev/null
+++
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/DatasourceEnvMapper.java
@@ -0,0 +1,32 @@
+/*
+ * 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.linkis.basedatamanager.server.dao;
+
+import org.apache.linkis.basedatamanager.server.domain.DatasourceEnvEntity;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @description Database operation Mapper for table
[linkis_PS_DM_DATASource_env]
+ * @createDate 2022-08-13 15:15:25 @Entity
+ * org.apache.linkis.basedatamanager.server.domain.LinkisPsDmDatasourceEnv
+ */
+public interface DatasourceEnvMapper extends BaseMapper<DatasourceEnvEntity> {
+ List<DatasourceEnvEntity> getListByPage(String searchName);
+}
diff --git
a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/DatasourceEnvMapper.xml
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/DatasourceEnvMapper.xml
new file mode 100644
index 000000000..b7fcc14bb
--- /dev/null
+++
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/DatasourceEnvMapper.xml
@@ -0,0 +1,51 @@
+<?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.linkis.basedatamanager.server.dao.DatasourceEnvMapper">
+
+ <resultMap id="BaseResultMap"
type="org.apache.linkis.basedatamanager.server.domain.DatasourceEnvEntity">
+ <id property="id" column="id" jdbcType="INTEGER"/>
+ <result property="envName" column="env_name" jdbcType="VARCHAR"/>
+ <result property="envDesc" column="env_desc" jdbcType="VARCHAR"/>
+ <result property="datasourceTypeId" column="datasource_type_id"
jdbcType="INTEGER"/>
+ <result property="parameter" column="parameter"
jdbcType="VARCHAR"/>
+ <result property="createTime" column="create_time"
jdbcType="TIMESTAMP"/>
+ <result property="createUser" column="create_user"
jdbcType="VARCHAR"/>
+ <result property="modifyTime" column="modify_time"
jdbcType="TIMESTAMP"/>
+ <result property="modifyUser" column="modify_user"
jdbcType="VARCHAR"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id,env_name,env_desc,
+ datasource_type_id,parameter,create_time,
+ create_user,modify_time,modify_user
+ </sql>
+
+ <select id="getListByPage" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List"></include>
+ from linkis_ps_dm_datasource_env
+ <if test="searchName != null and searchName!=''">
+ where env_name like concat('%',#{searchName},'%')
+ or env_desc like concat('%',#{searchName},'%')
+ or parameter like concat('%',#{searchName},'%')
+ </if>
+ </select>
+</mapper>
diff --git
a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/DatasourceEnvEntity.java
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/DatasourceEnvEntity.java
new file mode 100644
index 000000000..06977ec54
--- /dev/null
+++
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/DatasourceEnvEntity.java
@@ -0,0 +1,227 @@
+/*
+ * 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.linkis.basedatamanager.server.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+/** @TableName linkis_ps_dm_datasource_env */
+@TableName(value = "linkis_ps_dm_datasource_env")
+public class DatasourceEnvEntity implements Serializable {
+ /** */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /** */
+ private String envName;
+
+ /** */
+ private String envDesc;
+
+ /** */
+ private Integer datasourceTypeId;
+
+ /** */
+ private String parameter;
+
+ /** */
+ private Date createTime;
+
+ /** */
+ private String createUser;
+
+ /** */
+ private Date modifyTime;
+
+ /** */
+ private String modifyUser;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+
+ /** */
+ public Integer getId() {
+ return id;
+ }
+
+ /** */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /** */
+ public String getEnvName() {
+ return envName;
+ }
+
+ /** */
+ public void setEnvName(String envName) {
+ this.envName = envName;
+ }
+
+ /** */
+ public String getEnvDesc() {
+ return envDesc;
+ }
+
+ /** */
+ public void setEnvDesc(String envDesc) {
+ this.envDesc = envDesc;
+ }
+
+ /** */
+ public Integer getDatasourceTypeId() {
+ return datasourceTypeId;
+ }
+
+ /** */
+ public void setDatasourceTypeId(Integer datasourceTypeId) {
+ this.datasourceTypeId = datasourceTypeId;
+ }
+
+ /** */
+ public String getParameter() {
+ return parameter;
+ }
+
+ /** */
+ public void setParameter(String parameter) {
+ this.parameter = parameter;
+ }
+
+ /** */
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ /** */
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ /** */
+ public String getCreateUser() {
+ return createUser;
+ }
+
+ /** */
+ public void setCreateUser(String createUser) {
+ this.createUser = createUser;
+ }
+
+ /** */
+ public Date getModifyTime() {
+ return modifyTime;
+ }
+
+ /** */
+ public void setModifyTime(Date modifyTime) {
+ this.modifyTime = modifyTime;
+ }
+
+ /** */
+ public String getModifyUser() {
+ return modifyUser;
+ }
+
+ /** */
+ public void setModifyUser(String modifyUser) {
+ this.modifyUser = modifyUser;
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ if (getClass() != that.getClass()) {
+ return false;
+ }
+ DatasourceEnvEntity other = (DatasourceEnvEntity) that;
+ return (this.getId() == null ? other.getId() == null :
this.getId().equals(other.getId()))
+ && (this.getEnvName() == null
+ ? other.getEnvName() == null
+ : this.getEnvName().equals(other.getEnvName()))
+ && (this.getEnvDesc() == null
+ ? other.getEnvDesc() == null
+ : this.getEnvDesc().equals(other.getEnvDesc()))
+ && (this.getDatasourceTypeId() == null
+ ? other.getDatasourceTypeId() == null
+ : this.getDatasourceTypeId().equals(other.getDatasourceTypeId()))
+ && (this.getParameter() == null
+ ? other.getParameter() == null
+ : this.getParameter().equals(other.getParameter()))
+ && (this.getCreateTime() == null
+ ? other.getCreateTime() == null
+ : this.getCreateTime().equals(other.getCreateTime()))
+ && (this.getCreateUser() == null
+ ? other.getCreateUser() == null
+ : this.getCreateUser().equals(other.getCreateUser()))
+ && (this.getModifyTime() == null
+ ? other.getModifyTime() == null
+ : this.getModifyTime().equals(other.getModifyTime()))
+ && (this.getModifyUser() == null
+ ? other.getModifyUser() == null
+ : this.getModifyUser().equals(other.getModifyUser()));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+ result = prime * result + ((getEnvName() == null) ? 0 :
getEnvName().hashCode());
+ result = prime * result + ((getEnvDesc() == null) ? 0 :
getEnvDesc().hashCode());
+ result =
+ prime * result + ((getDatasourceTypeId() == null) ? 0 :
getDatasourceTypeId().hashCode());
+ result = prime * result + ((getParameter() == null) ? 0 :
getParameter().hashCode());
+ result = prime * result + ((getCreateTime() == null) ? 0 :
getCreateTime().hashCode());
+ result = prime * result + ((getCreateUser() == null) ? 0 :
getCreateUser().hashCode());
+ result = prime * result + ((getModifyTime() == null) ? 0 :
getModifyTime().hashCode());
+ result = prime * result + ((getModifyUser() == null) ? 0 :
getModifyUser().hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [");
+ sb.append("Hash = ").append(hashCode());
+ sb.append(", id=").append(id);
+ sb.append(", envName=").append(envName);
+ sb.append(", envDesc=").append(envDesc);
+ sb.append(", datasourceTypeId=").append(datasourceTypeId);
+ sb.append(", parameter=").append(parameter);
+ sb.append(", createTime=").append(createTime);
+ sb.append(", createUser=").append(createUser);
+ sb.append(", modifyTime=").append(modifyTime);
+ sb.append(", modifyUser=").append(modifyUser);
+ sb.append(", serialVersionUID=").append(serialVersionUID);
+ sb.append("]");
+ return sb.toString();
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/DatasourceEnvRestfulApi.java
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/DatasourceEnvRestfulApi.java
new file mode 100644
index 000000000..992548ca8
--- /dev/null
+++
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/DatasourceEnvRestfulApi.java
@@ -0,0 +1,91 @@
+/*
+ * 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.linkis.basedatamanager.server.restful;
+
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.linkis.basedatamanager.server.domain.DatasourceEnvEntity;
+import org.apache.linkis.basedatamanager.server.service.DatasourceEnvService;
+import org.apache.linkis.server.Message;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags = "DatasourceEnvRestfulApi")
+@RestController
+@RequestMapping(path = "/basedata_manager/datasource_env")
+public class DatasourceEnvRestfulApi {
+
+ @Autowired
+ DatasourceEnvService datasourceEnvService;
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "query", dataType = "string", name =
"searchName", value = ""),
+ @ApiImplicitParam(paramType = "query", dataType = "int", name =
"currentPage", value = ""),
+ @ApiImplicitParam(paramType = "query", dataType = "int", name =
"pageSize", value = "")
+ })
+ @ApiOperation(value = "list", notes = "get list data", httpMethod = "GET")
+ @RequestMapping(path = "", method = RequestMethod.GET)
+ public Message list(String searchName,Integer currentPage,Integer
pageSize) {
+ PageInfo pageList =
datasourceEnvService.getListByPage(searchName,currentPage,pageSize);
+ return Message.ok("").data("list", pageList);
+ }
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "path", dataType = "long", name =
"id", value = "")
+ })
+ @ApiOperation(value = "get", notes = "get data by id", httpMethod = "GET")
+ @RequestMapping(path = "/{id}", method = RequestMethod.GET)
+ public Message get(@PathVariable("id") Long id) {
+ DatasourceEnvEntity datasourceEnv = datasourceEnvService.getById(id);
+ return Message.ok("").data("item", datasourceEnv);
+ }
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "body", dataType =
"DatasourceEnvEntity", name = "datasourceEnv", value = "")
+ })
+ @ApiOperation(value = "add", notes = "add data", httpMethod = "POST")
+ @RequestMapping(path = "", method = RequestMethod.POST)
+ public Message add(@RequestBody DatasourceEnvEntity datasourceEnv) {
+ boolean result = datasourceEnvService.save(datasourceEnv);
+ return Message.ok("").data("result", result);
+ }
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "path", dataType = "long", name =
"id", value = "")
+ })
+ @ApiOperation(value = "remove", notes = "remove data by id", httpMethod =
"DELETE")
+ @RequestMapping(path = "/{id}", method = RequestMethod.DELETE)
+ public Message remove(@PathVariable("id") Long id) {
+ boolean result = datasourceEnvService.removeById(id);
+ return Message.ok("").data("result", result);
+ }
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "body", dataType =
"DatasourceEnvEntity", name = "errorCode", value = "")
+ })
+ @ApiOperation(value = "update", notes = "update data", httpMethod = "PUT")
+ @RequestMapping(path = "", method = RequestMethod.PUT)
+ public Message update(@RequestBody DatasourceEnvEntity errorCode) {
+ boolean result = datasourceEnvService.updateById(errorCode);
+ return Message.ok("").data("result", result);
+ }
+
+
+}
diff --git
a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/DatasourceEnvService.java
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/DatasourceEnvService.java
new file mode 100644
index 000000000..2c8a87d19
--- /dev/null
+++
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/DatasourceEnvService.java
@@ -0,0 +1,31 @@
+/*
+ * 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.linkis.basedatamanager.server.service;
+
+import org.apache.linkis.basedatamanager.server.domain.DatasourceEnvEntity;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * @description Database operation Service for the
[linkis_PS_DM_DATASource_env] table
+ * @createDate 2022-08-13 15:15:25
+ */
+public interface DatasourceEnvService extends IService<DatasourceEnvEntity> {
+ PageInfo getListByPage(String searchName, Integer currentPage, Integer
pageSize);
+}
diff --git
a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/DatasourceEnvServiceImpl.java
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/DatasourceEnvServiceImpl.java
new file mode 100644
index 000000000..3d5868ae1
--- /dev/null
+++
b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/DatasourceEnvServiceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * 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.linkis.basedatamanager.server.service.impl;
+
+import org.apache.linkis.basedatamanager.server.dao.DatasourceEnvMapper;
+import org.apache.linkis.basedatamanager.server.domain.DatasourceEnvEntity;
+import org.apache.linkis.basedatamanager.server.service.DatasourceEnvService;
+
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * @description Database operation Service implementation for the table
[linKIS_PS_DM_DATASource_env]
+ * @createDate 2022-08-13 15:15:25
+ */
+@Service
+public class DatasourceEnvServiceImpl extends ServiceImpl<DatasourceEnvMapper,
DatasourceEnvEntity>
+ implements DatasourceEnvService {
+ @Override
+ public PageInfo getListByPage(String searchName, Integer currentPage,
Integer pageSize) {
+ PageHelper.startPage(currentPage, pageSize);
+ List<DatasourceEnvEntity> listByPage =
this.getBaseMapper().getListByPage(searchName);
+ PageInfo pageInfo = new PageInfo(listByPage);
+ return pageInfo;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]