This is an automated email from the ASF dual-hosted git repository.
zhangzicheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new a4a0b8857 [Task] support API document Api doc detail mapper #4029
(#4126)
a4a0b8857 is described below
commit a4a0b885789100bd16d8f5b1590c946a6ddc2ae1
Author: ywj1352 <[email protected]>
AuthorDate: Wed Nov 2 17:59:31 2022 +0800
[Task] support API document Api doc detail mapper #4029 (#4126)
* Implementation DetailMapper
* DetailMapper change
* remove field_desc
Co-authored-by: dragon-zhang <[email protected]>
---
.../apache/shenyu/admin/mapper/DetailMapper.java | 73 ++++++
.../apache/shenyu/admin/model/entity/DetailDO.java | 268 +++++++++++++++++++++
.../src/main/resources/mappers/detail-sqlmap.xml | 157 ++++++++++++
.../shenyu/admin/mapper/DetailMapperTest.java | 106 ++++++++
4 files changed, 604 insertions(+)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DetailMapper.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DetailMapper.java
new file mode 100644
index 000000000..501850010
--- /dev/null
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DetailMapper.java
@@ -0,0 +1,73 @@
+/*
+ * 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.shenyu.admin.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.shenyu.admin.model.entity.DetailDO;
+
+@Mapper
+public interface DetailMapper {
+
+ /**
+ * insert detailDO to table.
+ *
+ * @param detailDO the detailDO
+ * @return insert count
+ */
+ int insert(DetailDO detailDO);
+
+ /**
+ * insert detailDO to table selective.
+ *
+ * @param detailDO the detailDO
+ * @return insert count
+ */
+ int insertSelective(DetailDO detailDO);
+
+ /**
+ * select by primary key.
+ *
+ * @param id primary key
+ * @return object by primary key
+ */
+ DetailDO selectByPrimaryKey(String id);
+
+ /**
+ * update detailDO selective.
+ *
+ * @param detailDO the updated detailDO
+ * @return update count
+ */
+ int updateByPrimaryKeySelective(DetailDO detailDO);
+
+ /**
+ * update detailDO.
+ *
+ * @param detailDO the updated detailDO
+ * @return update count
+ */
+ int updateByPrimaryKey(DetailDO detailDO);
+
+ /**
+ * delete by primary key.
+ *
+ * @param id primaryKey
+ * @return deleteCount
+ */
+ int deleteByPrimaryKey(String id);
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DetailDO.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DetailDO.java
new file mode 100644
index 000000000..ecd7338bf
--- /dev/null
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DetailDO.java
@@ -0,0 +1,268 @@
+/*
+ * 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.shenyu.admin.model.entity;
+
+import java.sql.Timestamp;
+import java.util.Objects;
+
+/**
+ * DetailDO.
+ */
+public class DetailDO extends BaseDO {
+
+ /**
+ * the field id.
+ */
+ private String fieldId;
+
+ /**
+ * is example.
+ */
+ private Boolean example;
+
+ /**
+ * field value.
+ */
+ private String fieldValue;
+
+ /**
+ * value desc.
+ */
+ private String valueDesc;
+
+ /**
+ * getFieldId.
+ *
+ * @return fieldId
+ */
+ public String getFieldId() {
+ return fieldId;
+ }
+
+ /**
+ * set fieldId.
+ *
+ * @param fieldId fieldId
+ */
+ public void setFieldId(final String fieldId) {
+ this.fieldId = fieldId;
+ }
+
+ /**
+ * get Example.
+ *
+ * @return example
+ */
+ public Boolean getExample() {
+ return example;
+ }
+
+ /**
+ * set example.
+ *
+ * @param example example.
+ */
+ public void setExample(final Boolean example) {
+ this.example = example;
+ }
+
+ /**
+ * get fieldValue.
+ *
+ * @return fieldValue
+ */
+ public String getFieldValue() {
+ return fieldValue;
+ }
+
+ /**
+ * set fieldValue.
+ *
+ * @param fieldValue fieldValue
+ */
+ public void setFieldValue(final String fieldValue) {
+ this.fieldValue = fieldValue;
+ }
+
+ /**
+ * get valueDesc.
+ *
+ * @return valueDesc
+ */
+ public String getValueDesc() {
+ return valueDesc;
+ }
+
+ /**
+ * set valueDesc.
+ *
+ * @param valueDesc valueDesc
+ */
+ public void setValueDesc(final String valueDesc) {
+ this.valueDesc = valueDesc;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ DetailDO detailDO = (DetailDO) o;
+ return Objects.equals(fieldId, detailDO.fieldId)
+ && Objects.equals(example, detailDO.example)
+ && Objects.equals(fieldValue, detailDO.fieldValue)
+ && Objects.equals(valueDesc, detailDO.valueDesc);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), fieldId, example, fieldValue,
valueDesc);
+ }
+
+
+ /**
+ * builder.
+ *
+ * @return fieldDOBuilder
+ */
+ public static DetailDOBuilder builder() {
+ return new DetailDOBuilder();
+ }
+
+ public static final class DetailDOBuilder {
+
+ private String id;
+
+ private String fieldId;
+
+ private Boolean example;
+
+ private String fieldValue;
+
+ private String valueDesc;
+
+ private Timestamp dateCreated;
+
+ private Timestamp dateUpdated;
+
+ private DetailDOBuilder() {
+
+ }
+
+ /**
+ * id.
+ *
+ * @param id id
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder id(final String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * field id.
+ *
+ * @param fieldId fieldId
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder fieldId(final String fieldId) {
+ this.fieldId = fieldId;
+ return this;
+ }
+
+ /**
+ * example.
+ *
+ * @param example fieldId
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder example(final Boolean example) {
+ this.example = example;
+ return this;
+ }
+
+ /**
+ * fieldValue.
+ *
+ * @param fieldValue fieldValue
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder fieldValue(final String fieldValue) {
+ this.fieldValue = fieldValue;
+ return this;
+ }
+
+ /**
+ * valueDesc.
+ *
+ * @param valueDesc valueDesc
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder valueDesc(final String valueDesc) {
+ this.valueDesc = valueDesc;
+ return this;
+ }
+
+ /**
+ * dateCreated.
+ *
+ * @param dateCreated dateCreated
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder dateCreated(final Timestamp dateCreated) {
+ this.dateCreated = dateCreated;
+ return this;
+ }
+
+ /**
+ * dateUpdated.
+ *
+ * @param dateUpdated dateUpdated
+ * @return DetailDOBuilder
+ */
+ public DetailDOBuilder dateUpdated(final Timestamp dateUpdated) {
+ this.dateUpdated = dateUpdated;
+ return this;
+ }
+
+ /**
+ * build.
+ *
+ * @return detailDO
+ */
+ public DetailDO build() {
+ DetailDO detailDO = new DetailDO();
+ detailDO.setId(this.id);
+ detailDO.setFieldId(this.fieldId);
+ detailDO.setExample(this.example);
+ detailDO.setFieldValue(this.fieldValue);
+ detailDO.setValueDesc(this.valueDesc);
+ detailDO.setDateCreated(this.dateCreated);
+ detailDO.setDateUpdated(this.dateUpdated);
+ return detailDO;
+ }
+
+ }
+}
diff --git a/shenyu-admin/src/main/resources/mappers/detail-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/detail-sqlmap.xml
new file mode 100644
index 000000000..91dbd9f5b
--- /dev/null
+++ b/shenyu-admin/src/main/resources/mappers/detail-sqlmap.xml
@@ -0,0 +1,157 @@
+<?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.shenyu.admin.mapper.DetailMapper">
+
+ <resultMap id="BaseResultMap"
type="org.apache.shenyu.admin.model.entity.DetailDO">
+ <id column="id" jdbcType="VARCHAR" property="id"/>
+ <result column="field_id" jdbcType="VARCHAR" property="fieldId"/>
+ <result column="is_example" jdbcType="TINYINT" property="example"/>
+ <result column="field_value" jdbcType="VARCHAR" property="fieldValue"/>
+ <result column="value_desc" jdbcType="VARCHAR" property="valueDesc"/>
+ <result column="date_created" jdbcType="TIMESTAMP"
property="dateCreated"/>
+ <result column="date_updated" jdbcType="TIMESTAMP"
property="dateUpdated"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id,
+ field_id,
+ is_example,
+ field_value,
+ value_desc,
+ date_created,
+ date_updated
+ </sql>
+
+ <insert id="insert"
parameterType="org.apache.shenyu.admin.model.entity.DetailDO">
+ insert into detail (
+ id,
+ field_id,
+ is_example,
+ field_value,
+ value_desc,
+ date_created,
+ date_updated
+ )values (
+ #{id, jdbcType=VARCHAR},
+ #{fieldId, jdbcType=VARCHAR},
+ #{example, jdbcType=TINYINT},
+ #{fieldValue, jdbcType=VARCHAR},
+ #{valueDesc, jdbcType=VARCHAR},
+ #{dateCreated, jdbcType=TIMESTAMP},
+ #{dateUpdated, jdbcType=TIMESTAMP}
+ )
+ </insert>
+
+ <insert id="insertSelective"
parameterType="org.apache.shenyu.admin.model.entity.DetailDO">
+ INSERT INTO detail
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ id,
+ <if test="fieldId != null">
+ field_id,
+ </if>
+ <if test="example != null">
+ is_example,
+ </if>
+ <if test="fieldValue != null">
+ field_value,
+ </if>
+ <if test="valueDesc != null">
+ value_desc,
+ </if>
+ <if test="dateCreated != null">
+ date_created,
+ </if>
+ <if test="dateUpdated != null">
+ date_updated,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ #{id, jdbcType=VARCHAR},
+ <if test="fieldId != null">
+ #{fieldId, jdbcType=VARCHAR},
+ </if>
+ <if test="example != null">
+ #{example, jdbcType=TINYINT},
+ </if>
+ <if test="fieldValue != null">
+ #{fieldValue, jdbcType=VARCHAR},
+ </if>
+ <if test="valueDesc != null">
+ #{valueDesc, jdbcType=VARCHAR},
+ </if>
+ <if test="dateCreated != null">
+ #{dateCreated, jdbcType=TIMESTAMP},
+ </if>
+ <if test="dateUpdated != null">
+ #{dateUpdated, jdbcType=TIMESTAMP},
+ </if>
+ </trim>
+ </insert>
+
+ <update id="updateByPrimaryKeySelective"
parameterType="org.apache.shenyu.admin.model.entity.DetailDO">
+ UPDATE detail
+ <set>
+ <if test="fieldId != null">
+ field_id = #{fieldId, jdbcType=VARCHAR},
+ </if>
+ <if test="example != null">
+ is_example = #{example, jdbcType=TINYINT},
+ </if>
+ <if test="fieldValue != null">
+ field_value = #{fieldValue, jdbcType=VARCHAR},
+ </if>
+ <if test="valueDesc != null">
+ value_desc = #{valueDesc, jdbcType=VARCHAR},
+ </if>
+ <if test="dateCreated != null">
+ date_created = #{dateCreated, jdbcType=TIMESTAMP},
+ </if>
+ <if test="dateUpdated != null">
+ date_updated = #{dateUpdated, jdbcType=TIMESTAMP},
+ </if>
+ </set>
+ WHERE id = #{id, jdbcType=VARCHAR}
+ </update>
+
+ <update id="updateByPrimaryKey"
parameterType="org.apache.shenyu.admin.model.entity.DetailDO">
+ update detail
+ set
+ field_id = #{fieldId,jdbcType=VARCHAR},
+ is_example = #{example,jdbcType=TINYINT},
+ field_value = #{fieldValue,jdbcType=VARCHAR},
+ value_desc = #{valueDesc,jdbcType=VARCHAR},
+ date_created = #{dateCreated,jdbcType=TIMESTAMP},
+ date_updated = #{dateUpdated,jdbcType=TIMESTAMP}
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+ DELETE FROM detail
+ WHERE id = #{id, jdbcType=VARCHAR}
+ </delete>
+
+ <select id="selectByPrimaryKey" resultMap="BaseResultMap">
+ SELECT
+ <include refid="Base_Column_List"/>
+ FROM detail
+ WHERE id = #{id, jdbcType=VARCHAR}
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DetailMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DetailMapperTest.java
new file mode 100644
index 000000000..9cfeea1b1
--- /dev/null
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DetailMapperTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.shenyu.admin.mapper;
+
+import org.apache.shenyu.admin.AbstractSpringIntegrationTest;
+import org.apache.shenyu.admin.model.entity.DetailDO;
+import org.apache.shenyu.common.utils.UUIDUtils;
+import org.junit.jupiter.api.Test;
+
+import javax.annotation.Resource;
+import java.sql.Timestamp;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class DetailMapperTest extends AbstractSpringIntegrationTest {
+
+ @Resource
+ private DetailMapper detailMapper;
+
+ private DetailDO buildDetailDO() {
+ Timestamp now = new Timestamp(System.currentTimeMillis());
+ String id = UUIDUtils.getInstance().generateShortUuid();
+ String fieldId = UUIDUtils.getInstance().generateShortUuid();
+ return DetailDO.builder()
+ .id(id)
+ .fieldId(fieldId)
+ .example(true)
+ .fieldValue("fieldValue")
+ .valueDesc("valueDesc")
+ .dateCreated(now)
+ .dateUpdated(now)
+ .build();
+ }
+
+ @Test
+ public void testInsert() {
+ DetailDO detailDO = buildDetailDO();
+ int count = detailMapper.insert(detailDO);
+ assertThat(count, greaterThan(0));
+
+ int delete = detailMapper.deleteByPrimaryKey(detailDO.getId());
+ assertEquals(delete, 1);
+ }
+
+ @Test
+ public void testInsertSelective() {
+ DetailDO detailDO = buildDetailDO();
+ int count = detailMapper.insertSelective(detailDO);
+ assertThat(count, greaterThan(0));
+
+ int delete = detailMapper.deleteByPrimaryKey(detailDO.getId());
+ assertEquals(delete, 1);
+ }
+
+ @Test
+ public void testSelectByPrimaryKey() {
+ DetailDO detailDO = buildDetailDO();
+ int count = detailMapper.insert(detailDO);
+ assertThat(count, greaterThan(0));
+
+ DetailDO fieldDO = detailMapper.selectByPrimaryKey(detailDO.getId());
+ assertNotNull(fieldDO);
+ }
+
+ @Test
+ public void testUpdateByPrimaryKey() {
+ DetailDO detailDO = buildDetailDO();
+ int count = detailMapper.insert(detailDO);
+ assertThat(count, greaterThan(0));
+
+ detailDO.setValueDesc("update");
+ int updateCount = detailMapper.updateByPrimaryKey(detailDO);
+ assertThat(updateCount, greaterThan(0));
+
+ DetailDO fieldDO = detailMapper.selectByPrimaryKey(detailDO.getId());
+ assertEquals(fieldDO.getValueDesc(), "update");
+ }
+
+ @Test
+ public void testDeleteByPrimaryKey() {
+ DetailDO detailDO = buildDetailDO();
+ int count = detailMapper.insertSelective(detailDO);
+ assertThat(count, greaterThan(0));
+ int delete = detailMapper.deleteByPrimaryKey(detailDO.getId());
+ assertEquals(delete, 1);
+ }
+
+}