Skip to content

Commit

Permalink
[type:refactor #3088] Format meta-data-sqlmap.xml (#3192)
Browse files Browse the repository at this point in the history
* format SQL to improve code readability in shenyu-admin.
format meta-data-sqlmap.xml

* format SQL to improve code readability in shenyu-admin.
format meta-data-sqlmap.xml
  • Loading branch information
selectbook committed Apr 3, 2022
1 parent 0185849 commit 7ea9bdf
Showing 1 changed file with 121 additions and 91 deletions.
212 changes: 121 additions & 91 deletions shenyu-admin/src/main/resources/mappers/meta-data-sqlmap.xml
Expand Up @@ -34,150 +34,180 @@
</resultMap>

<sql id="Base_Column_List">
id, date_created, date_updated, app_name, path,path_desc,rpc_type, service_name,method_name,parameter_types,rpc_ext,enabled
id,
date_created,
date_updated,
app_name,
path,
path_desc,
rpc_type,
service_name,
method_name,
parameter_types,
rpc_ext,
enabled
</sql>

<select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data
where id = #{id,jdbcType=VARCHAR}
SElECT
<include refid="Base_Column_List"/>
FROM meta_data
WHERE id = #{id,jdbcType=VARCHAR}
</select>

<select id="selectByIdSet" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data
where id in
<foreach collection="idSet" item="id" index="index"
open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
SElECT
<include refid="Base_Column_List"/>
FROM meta_data
WHERE id IN
<foreach collection="idSet" item="id" index="index" open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
</select>

<select id="findByPath" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data
where path = #{path,jdbcType=VARCHAR}
SElECT
<include refid="Base_Column_List"/>
FROM meta_data
WHERE path = #{path,jdbcType=VARCHAR}
</select>

<select id="findByServiceNameAndMethod" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data
where service_name = #{serviceName,jdbcType=VARCHAR}
and method_name = #{methodName,jdbcType=VARCHAR}
SElECT
<include refid="Base_Column_List"/>
FROM meta_data
WHERE service_name = #{serviceName,jdbcType=VARCHAR}
AND method_name = #{methodName,jdbcType=VARCHAR}
</select>


<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data

SElECT
<include refid="Base_Column_List"/>
FROM meta_data
</select>


<select id="selectByQuery" parameterType="org.apache.shenyu.admin.model.query.MetaDataQuery" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data
<if test="appName != null and appName != ''">
<bind name="appNameLike" value="('%' + appName + '%')"/>
where app_name LIKE #{appNameLike,jdbcType=VARCHAR}
</if>
SElECT
<include refid="Base_Column_List"/>
FROM meta_data
<if test="appName != null and appName != ''">
<bind name="appNameLike" value="('%' + appName + '%')"/>
WHERE app_name LIKE #{appNameLike,jdbcType=VARCHAR}
</if>
</select>

<select id="countByQuery" parameterType="org.apache.shenyu.admin.model.query.MetaDataQuery" resultType="java.lang.Integer">
select count(1)
from meta_data
<if test="appName != null">
where app_name = #{appName,jdbcType=VARCHAR}
</if>
SElECT COUNT(1)
FROM meta_data
<if test="appName != null">
WHERE app_name = #{appName,jdbcType=VARCHAR}
</if>
</select>

<select id="selectAll" resultType="org.apache.shenyu.admin.model.entity.MetaDataDO" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from meta_data
SElECT
<include refid="Base_Column_List"/>
FROM meta_data
</select>

<select id="pathExisted" resultType="java.lang.Boolean">
select true from meta_data where path = #{path} limit 1
SElECT true
FROM meta_data
WHERE path = #{path}
LIMIT 1
</select>

<select id="pathExistedExclude" resultType="java.lang.Boolean">
select true
from meta_data
where path = #{path}
and id not in
<foreach collection="exclude" item="id" index="index"
open="(" separator="," close=")">
#{id}
</foreach>
limit 1
SElECT true
FROM meta_data
WHERE path = #{path}
AND id NOT IN
<foreach collection="exclude" item="id" index="index" open="(" separator="," close=")">
#{id}
</foreach>
LIMIT 1
</select>

<select id="existed" resultType="java.lang.Boolean">
select true from meta_data where id = #{id} limit 1
SElECT true
FROM meta_data
WHERE id = #{id}
LIMIT 1
</select>

<insert id="insert" parameterType="org.apache.shenyu.admin.model.entity.MetaDataDO">
insert into meta_data (id, date_created, date_updated, app_name, path,path_desc,rpc_type, service_name,method_name,parameter_types,rpc_ext,enabled )
values (#{id,jdbcType=VARCHAR}, #{dateCreated,jdbcType=TIMESTAMP}, #{dateUpdated,jdbcType=TIMESTAMP},
#{appName,jdbcType=VARCHAR},
#{path,jdbcType=VARCHAR},
#{pathDesc,jdbcType=VARCHAR},
#{rpcType,jdbcType=VARCHAR},
#{serviceName,jdbcType=VARCHAR},
#{methodName,jdbcType=VARCHAR},
#{parameterTypes,jdbcType=VARCHAR},
#{rpcExt,jdbcType=VARCHAR},
#{enabled,jdbcType=TINYINT})
INSERT INTO meta_data
(id,
date_created,
date_updated,
app_name,
path,
path_desc,
rpc_type,
service_name,
method_name,
parameter_types,
rpc_ext,
enabled)
VALUES
(#{id,jdbcType=VARCHAR},
#{dateCreated,jdbcType=TIMESTAMP},
#{dateUpdated,jdbcType=TIMESTAMP},
#{appName,jdbcType=VARCHAR},
#{path,jdbcType=VARCHAR},
#{pathDesc,jdbcType=VARCHAR},
#{rpcType,jdbcType=VARCHAR},
#{serviceName,jdbcType=VARCHAR},
#{methodName,jdbcType=VARCHAR},
#{parameterTypes,jdbcType=VARCHAR},
#{rpcExt,jdbcType=VARCHAR},
#{enabled,jdbcType=TINYINT})
</insert>


<update id="update" parameterType="org.apache.shenyu.admin.model.entity.MetaDataDO">
update meta_data
set app_name = #{appName,jdbcType=VARCHAR},
path = #{path,jdbcType=VARCHAR},
path_desc = #{pathDesc,jdbcType=VARCHAR},
rpc_type = #{rpcType,jdbcType=VARCHAR},
service_name = #{serviceName,jdbcType=VARCHAR},
method_name = #{methodName,jdbcType=VARCHAR},
parameter_types = #{parameterTypes,jdbcType=VARCHAR},
rpc_ext= #{rpcExt,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
UPDATE meta_data
SET
app_name = #{appName,jdbcType=VARCHAR},
path = #{path,jdbcType=VARCHAR},
path_desc = #{pathDesc,jdbcType=VARCHAR},
rpc_type = #{rpcType,jdbcType=VARCHAR},
service_name = #{serviceName,jdbcType=VARCHAR},
method_name = #{methodName,jdbcType=VARCHAR},
parameter_types = #{parameterTypes,jdbcType=VARCHAR},
rpc_ext= #{rpcExt,jdbcType=VARCHAR}
WHERE id = #{id,jdbcType=VARCHAR}
</update>

<update id="updateEnable" parameterType="org.apache.shenyu.admin.model.entity.PluginDO">
update meta_data
set enabled = #{enabled,jdbcType=TINYINT}
where id = #{id,jdbcType=VARCHAR}
UPDATE meta_data
SET
enabled = #{enabled,jdbcType=TINYINT}
WHERE id = #{id,jdbcType=VARCHAR}
</update>

<update id="updateEnableBatch">
update meta_data
set enabled = #{enabled,jdbcType=TINYINT}
where id in
<foreach collection="idSet" index="index" item="id"
open="(" separator="," close=")">
#{id, jdbcType=VARCHAR}
</foreach>
UPDATE meta_data
SET enabled = #{enabled,jdbcType=TINYINT}
WHERE id IN
<foreach collection="idSet" index="index" item="id" open="(" separator="," close=")">
#{id, jdbcType=VARCHAR}
</foreach>
</update>

<delete id="delete" parameterType="java.lang.String">
delete from meta_data
where id = #{id,jdbcType=VARCHAR}
DELETE FROM meta_data
WHERE id = #{id,jdbcType=VARCHAR}
</delete>

<delete id="deleteByIdSet" parameterType="java.lang.String">
delete from meta_data
where id in
<foreach collection="idSet" item="id" index="index"
open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
DELETE FROM meta_data
WHERE id IN
<foreach collection="idSet" item="id" index="index" open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
</delete>
</mapper>

0 comments on commit 7ea9bdf

Please sign in to comment.