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:31:50 UTC

[incubator-linkis] branch dev-1.3.1 updated: feat(basedata-manager): add ErrorCodeManager manager restful api (#3172)

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 24e45436c feat(basedata-manager):  add ErrorCodeManager manager restful api (#3172)
24e45436c is described below

commit 24e45436c5207c5da1585eddac1c7c985091e904
Author: jack tao <79...@qq.com>
AuthorDate: Fri Sep 2 14:31:44 2022 +0800

    feat(basedata-manager):  add ErrorCodeManager manager restful api (#3172)
---
 .../server/dao/PsErrorCodeMapper.java              |  32 +++++
 .../server/dao/mapper/PsErrorCodeMapper.xml        |  47 +++++++
 .../server/domain/ErrorCodeEntity.java             | 153 +++++++++++++++++++++
 .../server/restful/ErrorCodeRestfulApi.java        |  91 ++++++++++++
 .../server/service/ErrorCodeService.java           |  31 +++++
 .../server/service/impl/ErrorCodeServiceImpl.java  |  47 +++++++
 6 files changed, 401 insertions(+)

diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/PsErrorCodeMapper.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/PsErrorCodeMapper.java
new file mode 100644
index 000000000..3d2e77847
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/PsErrorCodeMapper.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.ErrorCodeEntity;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @description Database operation Mapper for the [linkis_ps_error_code] table
+ * @createDate 2022-08-13 15:10:51 @Entity
+ *     org.apache.linkis.basedatamanager.server.domain.LinkisPsErrorCode
+ */
+public interface PsErrorCodeMapper extends BaseMapper<ErrorCodeEntity> {
+  public List<ErrorCodeEntity> getListByPage(String searchName);
+}
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/PsErrorCodeMapper.xml b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/PsErrorCodeMapper.xml
new file mode 100644
index 000000000..047a9408a
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/dao/mapper/PsErrorCodeMapper.xml
@@ -0,0 +1,47 @@
+<?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.PsErrorCodeMapper">
+
+    <resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.ErrorCodeEntity">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="errorCode" column="error_code" jdbcType="VARCHAR"/>
+            <result property="errorDesc" column="error_desc" jdbcType="VARCHAR"/>
+            <result property="errorRegex" column="error_regex" jdbcType="VARCHAR"/>
+            <result property="errorType" column="error_type" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,error_code,error_desc,
+        error_regex,error_type
+    </sql>
+
+    <select id="getListByPage" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"></include>
+        from linkis_ps_error_code
+        <if test="searchName != null and searchName!=''">
+            where error_code like concat('%',#{searchName},'%')
+            or error_desc like concat('%',#{searchName},'%')
+            or error_regex like concat('%',#{searchName},'%')
+            or error_type 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/ErrorCodeEntity.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/ErrorCodeEntity.java
new file mode 100644
index 000000000..5b593c98a
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/domain/ErrorCodeEntity.java
@@ -0,0 +1,153 @@
+/*
+ * 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_error_code */
+@TableName(value = "linkis_ps_error_code")
+public class ErrorCodeEntity implements Serializable {
+  /** */
+  @TableId(type = IdType.AUTO)
+  private Long id;
+
+  /** */
+  private String errorCode;
+
+  /** */
+  private String errorDesc;
+
+  /** */
+  private String errorRegex;
+
+  /** */
+  private Integer errorType;
+
+  @TableField(exist = false)
+  private static final long serialVersionUID = 1L;
+
+  /** */
+  public Long getId() {
+    return id;
+  }
+
+  /** */
+  public void setId(Long id) {
+    this.id = id;
+  }
+
+  /** */
+  public String getErrorCode() {
+    return errorCode;
+  }
+
+  /** */
+  public void setErrorCode(String errorCode) {
+    this.errorCode = errorCode;
+  }
+
+  /** */
+  public String getErrorDesc() {
+    return errorDesc;
+  }
+
+  /** */
+  public void setErrorDesc(String errorDesc) {
+    this.errorDesc = errorDesc;
+  }
+
+  /** */
+  public String getErrorRegex() {
+    return errorRegex;
+  }
+
+  /** */
+  public void setErrorRegex(String errorRegex) {
+    this.errorRegex = errorRegex;
+  }
+
+  /** */
+  public Integer getErrorType() {
+    return errorType;
+  }
+
+  /** */
+  public void setErrorType(Integer errorType) {
+    this.errorType = errorType;
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (this == that) {
+      return true;
+    }
+    if (that == null) {
+      return false;
+    }
+    if (getClass() != that.getClass()) {
+      return false;
+    }
+    ErrorCodeEntity other = (ErrorCodeEntity) that;
+    return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+        && (this.getErrorCode() == null
+            ? other.getErrorCode() == null
+            : this.getErrorCode().equals(other.getErrorCode()))
+        && (this.getErrorDesc() == null
+            ? other.getErrorDesc() == null
+            : this.getErrorDesc().equals(other.getErrorDesc()))
+        && (this.getErrorRegex() == null
+            ? other.getErrorRegex() == null
+            : this.getErrorRegex().equals(other.getErrorRegex()))
+        && (this.getErrorType() == null
+            ? other.getErrorType() == null
+            : this.getErrorType().equals(other.getErrorType()));
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+    result = prime * result + ((getErrorCode() == null) ? 0 : getErrorCode().hashCode());
+    result = prime * result + ((getErrorDesc() == null) ? 0 : getErrorDesc().hashCode());
+    result = prime * result + ((getErrorRegex() == null) ? 0 : getErrorRegex().hashCode());
+    result = prime * result + ((getErrorType() == null) ? 0 : getErrorType().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(", errorCode=").append(errorCode);
+    sb.append(", errorDesc=").append(errorDesc);
+    sb.append(", errorRegex=").append(errorRegex);
+    sb.append(", errorType=").append(errorType);
+    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/ErrorCodeRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/ErrorCodeRestfulApi.java
new file mode 100644
index 000000000..abb50cd49
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/restful/ErrorCodeRestfulApi.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.ErrorCodeEntity;
+import org.apache.linkis.basedatamanager.server.service.ErrorCodeService;
+import org.apache.linkis.server.Message;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags="ErrorCodeRestfulApi")
+@RestController
+@RequestMapping(path = "/basedata_manager/error_code")
+public class ErrorCodeRestfulApi {
+
+    @Autowired
+    ErrorCodeService errorCodeService;
+
+    @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 with page", httpMethod = "GET")
+    @RequestMapping(path = "", method = RequestMethod.GET)
+    public Message list(String searchName,Integer currentPage,Integer pageSize) {
+        PageInfo pageList = errorCodeService.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) {
+        ErrorCodeEntity errorCode = errorCodeService.getById(id);
+        return Message.ok("").data("item", errorCode);
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(paramType = "body", dataType = "ErrorCodeEntity", name = "errorCode", value = "")
+    })
+    @ApiOperation(value = "add", notes = "add data", httpMethod = "POST")
+    @RequestMapping(path = "", method = RequestMethod.POST)
+    public Message add(@RequestBody ErrorCodeEntity errorCode) {
+        boolean result = errorCodeService.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 = errorCodeService.removeById(id);
+        return Message.ok("").data("result", result);
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(paramType = "body", dataType = "ErrorCodeEntity", name = "errorCode", value = "")
+    })
+    @ApiOperation(value = "update", notes = "update data", httpMethod = "PUT")
+    @RequestMapping(path = "", method = RequestMethod.PUT)
+    public Message update(@RequestBody ErrorCodeEntity errorCode) {
+        boolean result = errorCodeService.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/ErrorCodeService.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/ErrorCodeService.java
new file mode 100644
index 000000000..503a77d68
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/ErrorCodeService.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.ErrorCodeEntity;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * @description Database operation Service for the [linkis_ps_error_code] table
+ * @createDate 2022-08-13 15:10:51
+ */
+public interface ErrorCodeService extends IService<ErrorCodeEntity> {
+  public 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/ErrorCodeServiceImpl.java b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/ErrorCodeServiceImpl.java
new file mode 100644
index 000000000..016f9e8e6
--- /dev/null
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/ErrorCodeServiceImpl.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.PsErrorCodeMapper;
+import org.apache.linkis.basedatamanager.server.domain.ErrorCodeEntity;
+import org.apache.linkis.basedatamanager.server.service.ErrorCodeService;
+
+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 [linkis_ps_error_code] table
+ * @createDate 2022-08-13 15:10:51
+ */
+@Service
+public class ErrorCodeServiceImpl extends ServiceImpl<PsErrorCodeMapper, ErrorCodeEntity>
+    implements ErrorCodeService {
+
+  @Override
+  public PageInfo getListByPage(String searchName, Integer currentPage, Integer pageSize) {
+    PageHelper.startPage(currentPage, pageSize);
+    List<ErrorCodeEntity> 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