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 06:28:50 UTC

[incubator-linkis] branch dev-1.3.1 updated: feat(basedata-manager): add UDF Tree manager restful api (#3180)

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 415ced601 feat(basedata-manager):  add UDF Tree manager restful api (#3180)
415ced601 is described below

commit 415ced601e23a41bd90bc2ff9b09cf27c7f41df6
Author: jack tao <79...@qq.com>
AuthorDate: Fri Sep 2 14:28:44 2022 +0800

    feat(basedata-manager):  add UDF Tree manager restful api (#3180)
---
 .../basedatamanager/server/dao/UdfTreeMapper.java  |  33 ++++
 .../server/dao/mapper/UdfTreeMapper.xml            |  50 +++++
 .../server/domain/UdfTreeEntity.java               | 208 +++++++++++++++++++++
 .../server/restful/UdfTreeRestfulApi.java          |  91 +++++++++
 .../server/service/UdfTreeService.java             |  31 +++
 .../server/service/impl/UdfTreeServiceImpl.java    |  46 +++++
 6 files changed, 459 insertions(+)

diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfTreeMapper.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfTreeMapper.java
new file mode 100644
index 000000000..40f381e6b
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfTreeMapper.java
@@ -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.linkis.basedatamanager.server.dao;
+
+import org.apache.linkis.basedatamanager.server.domain.UdfTreeEntity;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @description Database operation Mapper for the linkis_PS_UDF_tree table
+ * @createDate 2022-08-13 15:13:27 @Entity
+ *     org.apache.linkis.basedatamanager.server.domain.LinkisPsUdfTree
+ */
+public interface UdfTreeMapper extends BaseMapper<UdfTreeEntity> {
+  public List<UdfTreeEntity> getListByPage(String searchName);
+}
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/UdfTreeMapper.xml b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/UdfTreeMapper.xml
new file mode 100644
index 000000000..cd2f8a25e
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/UdfTreeMapper.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.UdfTreeMapper">
+
+    <resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.UdfTreeEntity">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="parent" column="parent" jdbcType="BIGINT"/>
+            <result property="name" column="name" jdbcType="VARCHAR"/>
+            <result property="userName" column="user_name" jdbcType="VARCHAR"/>
+            <result property="description" column="description" jdbcType="VARCHAR"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+            <result property="category" column="category" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,parent,name,
+        user_name,description,create_time,
+        update_time,category
+    </sql>
+
+    <select id="getListByPage" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"></include>
+        from linkis_ps_udf_tree
+        <if test="searchName != null and searchName!=''">
+            where user_name like concat('%',#{searchName},'%')
+            or description like concat('%',#{searchName},'%')
+            or category 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/UdfTreeEntity.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfTreeEntity.java
new file mode 100644
index 000000000..8a41d9fca
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfTreeEntity.java
@@ -0,0 +1,208 @@
+/*
+ * 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_udf_tree */
+@TableName(value = "linkis_ps_udf_tree")
+public class UdfTreeEntity implements Serializable {
+  /** */
+  @TableId(type = IdType.AUTO)
+  private Long id;
+
+  /** */
+  private Long parent;
+
+  /** Category name of the function. It would be displayed in the front-end */
+  private String name;
+
+  /** */
+  private String userName;
+
+  /** */
+  private String description;
+
+  /** */
+  private Date createTime;
+
+  /** */
+  private Date updateTime;
+
+  /** Used to distinguish between udf and function */
+  private String category;
+
+  @TableField(exist = false)
+  private static final long serialVersionUID = 1L;
+
+  /** */
+  public Long getId() {
+    return id;
+  }
+
+  /** */
+  public void setId(Long id) {
+    this.id = id;
+  }
+
+  /** */
+  public Long getParent() {
+    return parent;
+  }
+
+  /** */
+  public void setParent(Long parent) {
+    this.parent = parent;
+  }
+
+  /** Category name of the function. It would be displayed in the front-end */
+  public String getName() {
+    return name;
+  }
+
+  /** Category name of the function. It would be displayed in the front-end */
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  /** */
+  public String getUserName() {
+    return userName;
+  }
+
+  /** */
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+
+  /** */
+  public String getDescription() {
+    return description;
+  }
+
+  /** */
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  /** */
+  public Date getCreateTime() {
+    return createTime;
+  }
+
+  /** */
+  public void setCreateTime(Date createTime) {
+    this.createTime = createTime;
+  }
+
+  /** */
+  public Date getUpdateTime() {
+    return updateTime;
+  }
+
+  /** */
+  public void setUpdateTime(Date updateTime) {
+    this.updateTime = updateTime;
+  }
+
+  /** Used to distinguish between udf and function */
+  public String getCategory() {
+    return category;
+  }
+
+  /** Used to distinguish between udf and function */
+  public void setCategory(String category) {
+    this.category = category;
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (this == that) {
+      return true;
+    }
+    if (that == null) {
+      return false;
+    }
+    if (getClass() != that.getClass()) {
+      return false;
+    }
+    UdfTreeEntity other = (UdfTreeEntity) that;
+    return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+        && (this.getParent() == null
+            ? other.getParent() == null
+            : this.getParent().equals(other.getParent()))
+        && (this.getName() == null
+            ? other.getName() == null
+            : this.getName().equals(other.getName()))
+        && (this.getUserName() == null
+            ? other.getUserName() == null
+            : this.getUserName().equals(other.getUserName()))
+        && (this.getDescription() == null
+            ? other.getDescription() == null
+            : this.getDescription().equals(other.getDescription()))
+        && (this.getCreateTime() == null
+            ? other.getCreateTime() == null
+            : this.getCreateTime().equals(other.getCreateTime()))
+        && (this.getUpdateTime() == null
+            ? other.getUpdateTime() == null
+            : this.getUpdateTime().equals(other.getUpdateTime()))
+        && (this.getCategory() == null
+            ? other.getCategory() == null
+            : this.getCategory().equals(other.getCategory()));
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+    result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
+    result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+    result = prime * result + ((getUserName() == null) ? 0 : getUserName().hashCode());
+    result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
+    result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+    result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
+    result = prime * result + ((getCategory() == null) ? 0 : getCategory().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(", parent=").append(parent);
+    sb.append(", name=").append(name);
+    sb.append(", userName=").append(userName);
+    sb.append(", description=").append(description);
+    sb.append(", createTime=").append(createTime);
+    sb.append(", updateTime=").append(updateTime);
+    sb.append(", category=").append(category);
+    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/UdfTreeRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfTreeRestfulApi.java
new file mode 100644
index 000000000..47de078f4
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfTreeRestfulApi.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.UdfTreeEntity;
+import org.apache.linkis.basedatamanager.server.service.UdfTreeService;
+import org.apache.linkis.server.Message;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags="UdfTreeRestfulApi")
+@RestController
+@RequestMapping(path = "/basedata_manager/udf_tree")
+public class UdfTreeRestfulApi {
+
+    @Autowired
+    UdfTreeService udfTreeService;
+
+    @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 = udfTreeService.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) {
+        UdfTreeEntity errorCode = udfTreeService.getById(id);
+        return Message.ok("").data("item", errorCode);
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(paramType = "body", dataType = "UdfTreeEntity", name = "errorCode", value = "")
+    })
+    @ApiOperation(value = "add", notes = "add data", httpMethod = "POST")
+    @RequestMapping(path = "", method = RequestMethod.POST)
+    public Message add(@RequestBody UdfTreeEntity errorCode) {
+        boolean result = udfTreeService.save(errorCode);
+        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 = udfTreeService.removeById(id);
+        return Message.ok("").data("result", result);
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(paramType = "body", dataType = "UdfTreeEntity", name = "errorCode", value = "")
+    })
+    @ApiOperation(value = "update", notes = "update data", httpMethod = "PUT")
+    @RequestMapping(path = "", method = RequestMethod.PUT)
+    public Message update(@RequestBody UdfTreeEntity errorCode) {
+        boolean result = udfTreeService.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/UdfTreeService.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/UdfTreeService.java
new file mode 100644
index 000000000..001550a21
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/UdfTreeService.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.UdfTreeEntity;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * @description Database operation Service for the [linKIS_PS_UDF_tree] table
+ * @createDate 2022-08-13 15:13:27
+ */
+public interface UdfTreeService extends IService<UdfTreeEntity> {
+  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/UdfTreeServiceImpl.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/UdfTreeServiceImpl.java
new file mode 100644
index 000000000..cf3ae2036
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/UdfTreeServiceImpl.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.UdfTreeMapper;
+import org.apache.linkis.basedatamanager.server.domain.UdfTreeEntity;
+import org.apache.linkis.basedatamanager.server.service.UdfTreeService;
+
+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_UDF_tree
+ * @createDate 2022-08-13 15:13:27
+ */
+@Service
+public class UdfTreeServiceImpl extends ServiceImpl<UdfTreeMapper, UdfTreeEntity>
+    implements UdfTreeService {
+  @Override
+  public PageInfo getListByPage(String searchName, Integer currentPage, Integer pageSize) {
+    PageHelper.startPage(currentPage, pageSize);
+    List<UdfTreeEntity> 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