Skip to content

Commit

Permalink
format SQL to improve code readability in shenyu-admin. format auth-p…
Browse files Browse the repository at this point in the history
…aram-sqlmap.xml apache#3088
  • Loading branch information
hutaishi committed Mar 22, 2022
1 parent 4c4ec0b commit e36f18b
Showing 1 changed file with 66 additions and 63 deletions.
129 changes: 66 additions & 63 deletions shenyu-admin/src/main/resources/mappers/auth-param-sqlmap.xml
Expand Up @@ -28,100 +28,103 @@
</resultMap>

<sql id="Base_Column_List">
id, auth_id, app_name,app_param,date_created, date_updated
id,
auth_id,
app_name,
app_param,
date_created,
date_updated
</sql>

<select id="findByAuthId" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from auth_param
where auth_id = #{authId,jdbcType=VARCHAR}
SELECT
<include refid="Base_Column_List"/>
FROM auth_param
WHERE auth_id = #{authId, jdbcType=VARCHAR}
</select>

<select id="findByAuthIdList" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from auth_param
where auth_id in
<foreach collection="authIdSet" index="index" item="authId"
open="(" separator="," close=")" >
#{authId,jdbcType=VARCHAR}
</foreach>
SELECT
<include refid="Base_Column_List"/>
FROM auth_param
WHERE auth_id IN
<foreach collection="authIdSet" index="index" item="authId"
open="(" separator="," close=")">
#{authId, jdbcType=VARCHAR}
</foreach>
</select>

<select id="findByAuthIdAndAppName" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from auth_param
where auth_id = #{authId,jdbcType=VARCHAR}
and app_name = #{appName,jdbcType=VARCHAR}
limit 1
<select id="findByAuthIdAndAppName" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM auth_param
WHERE auth_id = #{authId, jdbcType=VARCHAR}
AND app_name = #{appName, jdbcType=VARCHAR}
LIMIT 1
</select>


<insert id="save" parameterType="org.apache.shenyu.admin.model.entity.AuthParamDO">
insert into auth_param
(id,
auth_id,
app_name,
app_param,
date_created,
date_updated)
values
(
#{id,jdbcType=VARCHAR},
#{authId,jdbcType=VARCHAR},
#{appName,jdbcType=VARCHAR},
#{appParam,jdbcType=VARCHAR},
#{dateCreated,jdbcType=TIMESTAMP},
#{dateUpdated,jdbcType=TIMESTAMP})
INSERT INTO auth_param
(id,
auth_id,
app_name,
app_param,
date_created,
date_updated)
VALUES
(#{id, jdbcType=VARCHAR},
#{authId, jdbcType=VARCHAR},
#{appName, jdbcType=VARCHAR},
#{appParam, jdbcType=VARCHAR},
#{dateCreated, jdbcType=TIMESTAMP},
#{dateUpdated, jdbcType=TIMESTAMP})
</insert>

<insert id="batchSave">
INSERT INTO auth_param
(id,
auth_id,
app_name,
app_param,
date_created,
date_updated)
(id,
auth_id,
app_name,
app_param,
date_created,
date_updated)
VALUES
<foreach collection="authParamDOList" item="authParamDO" separator=",">
(
#{authParamDO.id,jdbcType=VARCHAR},
#{authParamDO.authId,jdbcType=VARCHAR},
#{authParamDO.appName,jdbcType=VARCHAR},
#{authParamDO.appParam,jdbcType=VARCHAR},
#{authParamDO.dateCreated,jdbcType=TIMESTAMP},
#{authParamDO.dateUpdated,jdbcType=TIMESTAMP})
</foreach>
<foreach collection="authParamDOList" item="authParamDO" separator=",">
(
#{authParamDO.id, jdbcType=VARCHAR},
#{authParamDO.authId, jdbcType=VARCHAR},
#{authParamDO.appName, jdbcType=VARCHAR},
#{authParamDO.appParam, jdbcType=VARCHAR},
#{authParamDO.dateCreated, jdbcType=TIMESTAMP},
#{authParamDO.dateUpdated, jdbcType=TIMESTAMP})
</foreach>
</insert>


<update id="update" parameterType="org.apache.shenyu.admin.model.entity.AuthParamDO">
update auth_param
set
app_param = #{appParam,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
UPDATE auth_param
SET app_param = #{appParam, jdbcType=VARCHAR}
WHERE id = #{id, jdbcType=VARCHAR}
</update>


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

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

<delete id="deleteByAuthIds" parameterType="java.util.List">
delete from auth_param
where auth_id in
<foreach item="authId" collection="list" open="(" separator="," close=")">
#{authId,jdbcType=VARCHAR}
</foreach>
DELETE FROM auth_param
WHERE auth_id IN
<foreach item="authId" collection="list" open="(" separator="," close=")">
#{authId,jdbcType=VARCHAR}
</foreach>
</delete>


Expand Down

0 comments on commit e36f18b

Please sign in to comment.