Files
aida_back/src/main/resources/mapper/primary/GenerateMapper.xml

46 lines
1.5 KiB
XML
Raw Normal View History

<?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.ai.da.mapper.primary.GenerateMapper">
<select id="getByTypeAndTime" resultType="java.util.Map">
-- 查询level1_type的记录
SELECT
level1_type as type,
count(id) as count
FROM
t_generate
WHERE
level1_type IN ('Moodboard', 'Printboard', 'Sketchboard')
AND create_date >= #{startTime}
AND create_date &lt;= #{endTime}
<if test="accountIdList != null and accountIdList.size() > 0">
AND account_id IN
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
level1_type
UNION ALL
-- 查询level2_type的记录
SELECT
level2_type as type,
count(id) as count
FROM
t_generate
WHERE
level2_type IN ('Pattern', 'Logo', 'Slogan')
AND create_date > #{startTime}
AND create_date &lt;= #{endTime}
<if test="accountIdList != null and accountIdList.size() > 0">
AND account_id IN
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
level2_type;
</select>
</mapper>