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

76 lines
2.3 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.AffiliateMapper">
<select id="getMonthlyApprovedAffiliate" resultType="java.util.Map">
SELECT
count(*) AS count
FROM
t_affiliate
WHERE
YEAR ( create_time ) = #{year}
AND MONTH ( create_time ) = #{month}
AND status = 'Active'
</select>
2024-12-23 14:31:48 +08:00
<select id="getAffiliateList" resultType="com.ai.da.model.vo.AffiliateVO">
SELECT
f.*,
c.user_name
FROM
t_affiliate f
LEFT JOIN
t_account c
ON
f.account_id = c.id
<where>
1 = 1
<if test="status != null and status != ''">
AND f.status = #{status}
</if>
<if test="startTime != null and startTime != ''">
AND f.create_time &gt; #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND f.create_time &lt; #{endTime}
</if>
<if test="affiliateId != null">
AND f.id = #{affiliateId}
</if>
</where>
<if test="order != null and order.toUpperCase() == 'DESC'">
ORDER BY f.create_time DESC
</if>
<if test="order == null or order.toUpperCase() != 'DESC'">
ORDER BY f.create_time ASC
</if>
LIMIT ${size} OFFSET ${offset}
</select>
<select id="queryAffiliateTotalCount" resultType="int">
SELECT
count(f.id)
FROM
t_affiliate f
LEFT JOIN
t_account c
ON
f.account_id = c.id
<where>
1 = 1
<if test="status != null and status != ''">
AND f.status = #{status}
</if>
<if test="startTime != null and startTime != ''">
AND f.create_time &gt; #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND f.create_time &lt; #{endTime}
</if>
<if test="affiliateId != null">
AND f.id = #{affiliateId}
</if>
</where>
</select>
</mapper>