<?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.ruoyi.member.mapper.MemberApplyMapper">

    <resultMap type="MemberApply" id="MemberApplyResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="nickname"    column="nickname"    />
        <result property="identityType"    column="identity_type"    />
        <result property="content"    column="content"    />
        <result property="remark"    column="remark"    />
        <result property="images"    column="images"    />
        <result property="approvalStatus"    column="approval_status"    />
        <result property="approvalUserId"    column="approval_user_id"    />
        <result property="approvalTime"    column="approval_time"    />
        <result property="approvalRemark"    column="approval_remark"    />
        <result property="approvalUserName"    column="approval_user_name"    />
        <result property="creator"    column="creator"    />
        <result property="createTime"    column="create_time"    />
        <result property="updater"    column="updater"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMemberApplyVo">
        select id, user_id, nickname, identity_type, content, remark, images, approval_status, approval_user_id, approval_time, approval_remark,approval_user_name, creator, create_time, updater, update_time, del_flag from dl_member_apply
    </sql>
    <select id="queryListPage" parameterType="MemberApply" resultMap="MemberApplyResult">
        <include refid="selectMemberApplyVo"/>
        <where>
            del_flag=0
            <if test="entity.nickname != null  and entity.nickname != ''"> and nickname like concat('%', #{entity.nickname}, '%')</if>
            <if test="entity.identityType != null  and entity.identityType != ''"> and identity_type = #{entity.identityType}</if>

            <if test="entity.approvalTime != null "> and approval_time = #{entity.approvalTime}</if>
            <if test="entity.startTime != null and entity.endTime != null"> and create_time between #{entity.startTime} and #{entity.endTime}</if>
            <if test="entity.approvalStatus == 10"> and approval_status != 0</if>
            <if test="entity.approvalStatus != null  and entity.approvalStatus != '' and entity.approvalStatus != 10"> and approval_status = #{entity.approvalStatus}</if>
        </where>
        <choose>
            <when test="entity.approvalStatus == 10">order by approval_time desc</when>
            <otherwise>order by create_time asc </otherwise>
        </choose>
    </select>


</mapper>