refactor mapper xml
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.common.mapper.AttachmentMapper">
|
||||
<select id="selectByBizIdList" resultType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
SELECT
|
||||
*
|
||||
FROM `attachment`
|
||||
WHERE
|
||||
`biz_type` = #{bizType}
|
||||
<if test="bizIdList != null and !bizIdList.isEmpty()">
|
||||
AND `biz_id` IN
|
||||
<foreach collection="bizIdList" item="bizId" separator="," open="(" close=")">
|
||||
#{bizId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="bizIdList == null or bizIdList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
AND (`destroy_at` IS NULL OR UNIX_TIMESTAMP() < `destroy_at`)
|
||||
<if test="attachTypes != null and !attachTypes.isEmpty()">
|
||||
AND `attach_type` IN
|
||||
<foreach collection="attachTypes" item="attachType" separator="," open="(" close=")">
|
||||
#{attachType}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY `created_at`
|
||||
</select>
|
||||
<select id="selectThumb" resultType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
`attachment`
|
||||
WHERE
|
||||
biz_type = #{bizType}
|
||||
AND biz_id = #{sourceId}
|
||||
AND attach_type = 'THUMB'
|
||||
<choose>
|
||||
<when test="requestWidth != null">
|
||||
AND JSON_EXTRACT(metadata, '$.requestWidth') = #{requestWidth}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND JSON_EXTRACT(metadata, '$.requestWidth') IS NULL
|
||||
</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="requestHeight != null">
|
||||
AND JSON_EXTRACT(metadata, '$.requestHeight') = #{requestHeight}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND JSON_EXTRACT(metadata, '$.requestHeight') IS NULL
|
||||
</otherwise>
|
||||
</choose>
|
||||
AND is_destroyed = FALSE
|
||||
AND UNIX_TIMESTAMP() * 1000 < destroy_at
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.common.mapper.MultilingualMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.common.entity.Multilingual">
|
||||
SELECT
|
||||
*
|
||||
FROM `multilingual`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.common.mapper.TagMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.common.entity.Tag">
|
||||
SELECT
|
||||
*
|
||||
FROM `tag`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user