add data export
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
<?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.gao.mapper.GaoDataExportMapper">
|
||||
<sql id="exportWhere">
|
||||
`${scopeColumn}` = #{scopeValue}
|
||||
<if test="hasDeletedAt">
|
||||
AND `deleted_at` IS NULL
|
||||
</if>
|
||||
<if test="requiredBizType != null">
|
||||
AND `biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="countRows" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM `${tableName}`
|
||||
WHERE <include refid="exportWhere"/>
|
||||
</select>
|
||||
|
||||
<select id="selectRows" resultType="map">
|
||||
SELECT *
|
||||
FROM `${tableName}`
|
||||
WHERE <include refid="exportWhere"/>
|
||||
ORDER BY `${timeColumn}` ASC, `id` ASC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectChildren" resultType="map">
|
||||
SELECT *
|
||||
FROM `${tableName}`
|
||||
WHERE `${foreignKey}` IN
|
||||
<foreach collection="parentIdList" item="parentId" open="(" separator="," close=")">
|
||||
#{parentId}
|
||||
</foreach>
|
||||
<if test="hasDeletedAt">
|
||||
AND `deleted_at` IS NULL
|
||||
</if>
|
||||
ORDER BY `${foreignKey}` ASC, `created_at` ASC
|
||||
</select>
|
||||
|
||||
<select id="countChildren" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM `${childTableName}` `c`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `c`.`${childForeignKey}`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
<if test="childHasDeletedAt">
|
||||
AND `c`.`deleted_at` IS NULL
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenByScope" resultType="map">
|
||||
SELECT `c`.*
|
||||
FROM `${childTableName}` `c`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `c`.`${childForeignKey}`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
<if test="childHasDeletedAt">
|
||||
AND `c`.`deleted_at` IS NULL
|
||||
</if>
|
||||
ORDER BY `c`.`created_at` ASC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
<select id="statAttachment" resultType="map">
|
||||
SELECT
|
||||
COUNT(`a`.`id`) AS `attachmentCount`,
|
||||
COALESCE(SUM(`a`.`size`), 0) AS `attachmentSize`
|
||||
FROM `attachment` `a`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `a`.`biz_id`
|
||||
WHERE
|
||||
`a`.`deleted_at` IS NULL
|
||||
AND (`a`.`destroy_at` IS NULL OR `a`.`destroy_at` > UNIX_TIMESTAMP() * 1000)
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
AND `a`.`biz_type` IN
|
||||
<foreach collection="attachmentBizTypeList" item="bizType" open="(" separator="," close=")">
|
||||
#{bizType}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="statChildAttachment" resultType="map">
|
||||
SELECT
|
||||
COUNT(`a`.`id`) AS `attachmentCount`,
|
||||
COALESCE(SUM(`a`.`size`), 0) AS `attachmentSize`
|
||||
FROM `attachment` `a`
|
||||
INNER JOIN `${childTableName}` `c` ON `c`.`id` = `a`.`biz_id`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `c`.`${childForeignKey}`
|
||||
WHERE
|
||||
`a`.`deleted_at` IS NULL
|
||||
AND (`a`.`destroy_at` IS NULL OR `a`.`destroy_at` > UNIX_TIMESTAMP() * 1000)
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
<if test="childHasDeletedAt">
|
||||
AND `c`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
AND `a`.`biz_type` IN
|
||||
<foreach collection="attachmentBizTypeList" item="bizType" open="(" separator="," close=")">
|
||||
#{bizType}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user