<?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.jeeplus.test.luckyDraw.mapper.LuckyDrawMembersMapper">
    <select id="findList" resultType="com.jeeplus.test.luckyDraw.service.dto.LuckyDrawMembersDto">
        SELECT
			a.id,
			a.create_by,
			a.create_date,
			a.name,
			a.office_name,
			a.phone,
			a.event_id,
			b.name as eventName
		FROM
			lucky_draw_members a
			left join lucky_draw_events b on a.event_id = b.id and b.del_flag = '0'
			${ew.customSqlSegment}
		ORDER BY a.update_date DESC
    </select>
    <select id="getByName" resultType="java.lang.Integer">
		select count(1) from lucky_draw_members
		<where>
			name = #{name}
			and event_id = #{eventId}
			<if test="id != null and id != ''">
				and id != #{id}
			</if>
		</where>
	</select>
	<select id="getByNameAndId" resultType="java.lang.Integer">
		select count(*) from lucky_draw_members where name = #{name} and event_id = #{eventId}
	</select>
	<select id="findById" resultType="com.jeeplus.test.luckyDraw.service.dto.LuckyDrawMembersDto">
		select a.*,b.name as eventName from lucky_draw_members a
		left join lucky_draw_events b on a.event_id = b.id and b.del_flag = '0'
		where a.id = #{id}
	</select>
</mapper>
