<?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.house365.ws.dao.mapper.ProjectRecommendMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.UserProjectRecommendEntity">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="projectId" column="project_id"/>
        <result property="projectName" column="project_name"/>
        <result property="recommendReason" column="recommend_reason"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="isDeleted" column="is_deleted"/>
        <result property="channel" column="channel"/>
        <result property="city" column="city"/>
    </resultMap>

    <select id="queryByConditions" parameterType="map" resultMap="infoMap">
        SELECT *
        FROM user_project_recommend
        where is_deleted = 0
        <if test="userId != null and userId > 0 ">
            AND user_id = #{userId}
        </if>
        <if test="userName != null and userName != '' ">
            AND user_name = #{userName}
        </if>
        <if test="city != null and city != '' ">
            AND city = #{city}
        </if>
        <if test="projectName != null and projectName != '' ">
            AND project_name = #{projectName}
        </if>
        <if test="projectId != null and projectId != '' ">
            AND project_id = #{projectId}
        </if>
        <if test="channel != null and channel != '' ">
            AND channel = #{channel}
        </if>
        ORDER by update_time DESC
    </select>

    <delete id="deleteByUserId"  parameterType="Integer">
       DELETE FROM user_project_recommend
        WHERE
	       user_id = #{userId}
    </delete>

</mapper>