You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/09/02 04:08:47 UTC
[incubator-linkis] branch dev-1.3.1 updated: feat(basedata-manager): add DatasourceType manager restful api (#3170)
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 c9d5eca27 feat(basedata-manager): add DatasourceType manager restful api (#3170)
c9d5eca27 is described below
commit c9d5eca275f3794fddfcf3fb3fe4d8a203d6ae0b
Author: jack tao <79...@qq.com>
AuthorDate: Fri Sep 2 12:08:41 2022 +0800
feat(basedata-manager): add DatasourceType manager restful api (#3170)
* feat(basedata-manager): add DatasourceType manager restful api
* feat(basedata-manager): add swagger annotation
---
.../server/dao/DatasourceTypeMapper.java | 32 ++++
.../server/dao/mapper/DatasourceTypeMapper.xml | 50 ++++++
.../server/domain/DatasourceTypeEntity.java | 189 +++++++++++++++++++++
.../server/restful/DatasourceTypeRestfulApi.java | 91 ++++++++++
.../server/service/DatasourceTypeService.java | 32 ++++
.../service/impl/DatasourceTypeServiceImpl.java | 47 +++++
6 files changed, 441 insertions(+)
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/DatasourceTypeMapper.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/DatasourceTypeMapper.java
new file mode 100644
index 000000000..73d94f4a8
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/DatasourceTypeMapper.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.DatasourceTypeEntity;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @description Database operation Mapper for the linkis_PS_dM_DATASource_type table
+ * @createDate 2022-08-13 15:16:37 @Entity
+ * org.apache.linkis.basedatamanager.server.domain.LinkisPsDmDatasourceType
+ */
+public interface DatasourceTypeMapper extends BaseMapper<DatasourceTypeEntity> {
+ public List<DatasourceTypeEntity> getListByPage(String searchName);
+}
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/DatasourceTypeMapper.xml b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/DatasourceTypeMapper.xml
new file mode 100644
index 000000000..5f8c558aa
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/DatasourceTypeMapper.xml
@@ -0,0 +1,50 @@
+<?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.DatasourceTypeMapper">
+
+ <resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.DatasourceTypeEntity">
+ <id property="id" column="id" jdbcType="INTEGER"/>
+ <result property="name" column="name" jdbcType="VARCHAR"/>
+ <result property="description" column="description" jdbcType="VARCHAR"/>
+ <result property="option" column="option" jdbcType="VARCHAR"/>
+ <result property="classifier" column="classifier" jdbcType="VARCHAR"/>
+ <result property="icon" column="icon" jdbcType="VARCHAR"/>
+ <result property="layers" column="layers" jdbcType="INTEGER"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ `id`,`name`,`description`,
+ `option`,`classifier`,`icon`,
+ `layers`
+ </sql>
+
+ <select id="getListByPage" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List"></include>
+ <![CDATA[ from linkis_ps_dm_datasource_type ]]>
+ <if test="searchName != null and searchName!=''">
+ <![CDATA[ where `name` like concat('%',#{searchName},'%')
+ or `description` like concat('%',#{searchName},'%')
+ or `option` like concat('%',#{searchName},'%')
+ or `classifier` 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/DatasourceTypeEntity.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/DatasourceTypeEntity.java
new file mode 100644
index 000000000..a5d7a94b8
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/DatasourceTypeEntity.java
@@ -0,0 +1,189 @@
+/*
+ * 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 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_type */
+@TableName(value = "linkis_ps_dm_datasource_type")
+public class DatasourceTypeEntity implements Serializable {
+ /** */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /** */
+ private String name;
+
+ /** */
+ private String description;
+
+ /** */
+ private String option;
+
+ /** */
+ private String classifier;
+
+ /** */
+ private String icon;
+
+ /** */
+ private Integer layers;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+
+ /** */
+ public Integer getId() {
+ return id;
+ }
+
+ /** */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /** */
+ public String getName() {
+ return name;
+ }
+
+ /** */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** */
+ public String getDescription() {
+ return description;
+ }
+
+ /** */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /** */
+ public String getOption() {
+ return option;
+ }
+
+ /** */
+ public void setOption(String option) {
+ this.option = option;
+ }
+
+ /** */
+ public String getClassifier() {
+ return classifier;
+ }
+
+ /** */
+ public void setClassifier(String classifier) {
+ this.classifier = classifier;
+ }
+
+ /** */
+ public String getIcon() {
+ return icon;
+ }
+
+ /** */
+ public void setIcon(String icon) {
+ this.icon = icon;
+ }
+
+ /** */
+ public Integer getLayers() {
+ return layers;
+ }
+
+ /** */
+ public void setLayers(Integer layers) {
+ this.layers = layers;
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ if (getClass() != that.getClass()) {
+ return false;
+ }
+ DatasourceTypeEntity other = (DatasourceTypeEntity) that;
+ return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+ && (this.getName() == null
+ ? other.getName() == null
+ : this.getName().equals(other.getName()))
+ && (this.getDescription() == null
+ ? other.getDescription() == null
+ : this.getDescription().equals(other.getDescription()))
+ && (this.getOption() == null
+ ? other.getOption() == null
+ : this.getOption().equals(other.getOption()))
+ && (this.getClassifier() == null
+ ? other.getClassifier() == null
+ : this.getClassifier().equals(other.getClassifier()))
+ && (this.getIcon() == null
+ ? other.getIcon() == null
+ : this.getIcon().equals(other.getIcon()))
+ && (this.getLayers() == null
+ ? other.getLayers() == null
+ : this.getLayers().equals(other.getLayers()));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
+ result = prime * result + ((getOption() == null) ? 0 : getOption().hashCode());
+ result = prime * result + ((getClassifier() == null) ? 0 : getClassifier().hashCode());
+ result = prime * result + ((getIcon() == null) ? 0 : getIcon().hashCode());
+ result = prime * result + ((getLayers() == null) ? 0 : getLayers().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(", name=").append(name);
+ sb.append(", description=").append(description);
+ sb.append(", option=").append(option);
+ sb.append(", classifier=").append(classifier);
+ sb.append(", icon=").append(icon);
+ sb.append(", layers=").append(layers);
+ 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/DatasourceTypeRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/DatasourceTypeRestfulApi.java
new file mode 100644
index 000000000..b529a55db
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/DatasourceTypeRestfulApi.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.DatasourceTypeEntity;
+import org.apache.linkis.basedatamanager.server.service.DatasourceTypeService;
+import org.apache.linkis.server.Message;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags="DatasourceTypeRestfulApi")
+@RestController
+@RequestMapping(path = "/basedata_manager/datasource_type")
+public class DatasourceTypeRestfulApi {
+
+ @Autowired
+ DatasourceTypeService datasourceTypeService;
+
+ @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 = datasourceTypeService.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) {
+ DatasourceTypeEntity datasourceType = datasourceTypeService.getById(id);
+ return Message.ok("").data("item", datasourceType);
+ }
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "body", dataType = "DatasourceTypeEntity", name = "datasourceType", value = "")
+ })
+ @ApiOperation(value = "add", notes = "add data", httpMethod = "POST")
+ @RequestMapping(path = "", method = RequestMethod.POST)
+ public Message add(@RequestBody DatasourceTypeEntity datasourceType) {
+ boolean result = datasourceTypeService.save(datasourceType);
+ 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 = datasourceTypeService.removeById(id);
+ return Message.ok("").data("result", result);
+ }
+
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "body", dataType = "DatasourceTypeEntity", name = "errorCode", value = "")
+ })
+ @ApiOperation(value = "update", notes = "update data", httpMethod = "PUT")
+ @RequestMapping(path = "", method = RequestMethod.PUT)
+ public Message update(@RequestBody DatasourceTypeEntity errorCode) {
+ boolean result = datasourceTypeService.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/DatasourceTypeService.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/DatasourceTypeService.java
new file mode 100644
index 000000000..cbb7ee02a
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/DatasourceTypeService.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.service;
+
+import org.apache.linkis.basedatamanager.server.domain.DatasourceTypeEntity;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * @author jack
+ * @description Database operation Service for the linKIS_PS_DM_DATASource_type table
+ * @createDate 2022-08-13 15:16:37
+ */
+public interface DatasourceTypeService extends IService<DatasourceTypeEntity> {
+ 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/DatasourceTypeServiceImpl.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/DatasourceTypeServiceImpl.java
new file mode 100644
index 000000000..afd1bd956
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/DatasourceTypeServiceImpl.java
@@ -0,0 +1,47 @@
+/*
+ * 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.DatasourceTypeMapper;
+import org.apache.linkis.basedatamanager.server.domain.DatasourceTypeEntity;
+import org.apache.linkis.basedatamanager.server.service.DatasourceTypeService;
+
+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 linKIS_PS_DM_DATASource_type table
+ * @createDate 2022-08-13 15:16:37
+ */
+@Service
+public class DatasourceTypeServiceImpl
+ extends ServiceImpl<DatasourceTypeMapper, DatasourceTypeEntity>
+ implements DatasourceTypeService {
+ @Override
+ public PageInfo getListByPage(String searchName, Integer currentPage, Integer pageSize) {
+ PageHelper.startPage(currentPage, pageSize);
+ List<DatasourceTypeEntity> listByPage = this.getBaseMapper().getListByPage(searchName);
+ PageInfo pageInfo = new PageInfo(listByPage);
+ return pageInfo;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org