<?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="cn.iocoder.yudao.module.knowledge.mapper.TExpertZoneCollectionMapper">

    <resultMap type="cn.iocoder.yudao.module.knowledge.entity.TExpertZoneCollection" id="tExpertZoneCollectionMap">
            <result property="id" column="id"/>
            <result property="specialistId" column="specialist_id"/>
            <result property="expertZoneId" column="expert_zone_id"/>
            <result property="userId" column="user_id"/>
            <result property="createTime" column="create_time"/>
            <result property="updateTime" column="update_time"/>
            <result property="deptId" column="dept_id"/>
            <result property="identityId" column="identity_id"/>
            <result property="deleted" column="deleted"/>
    </resultMap>

    <!-- 用于select查询公用抽取的列 -->
    <sql id="columns">
        id,specialist_id,expert_zone_id,user_id,create_time,update_time,dept_id,identity_id,deleted
    </sql>
    <select id="findList" resultMap="tExpertZoneCollectionMap">
        select
        <include refid="columns"/>
        from t_expert_zone_collection
        <where>
                    <if test="id != null">
                        id = #{id}
                    </if>
                    <if test="specialistId != null">
                        specialist_id = #{specialistId}
                    </if>
                    <if test="expertZoneId != null">
                        expert_zone_id = #{expertZoneId}
                    </if>
                    <if test="userId != null">
                        user_id = #{userId}
                    </if>
                    <if test="createTime != null">
                        create_time = #{createTime}
                    </if>
                    <if test="updateTime != null">
                        update_time = #{updateTime}
                    </if>
                    <if test="deptId != null and deptId != ''">
                            dept_id = #{deptId}
                    </if>
                    <if test="identityId != null and identityId != ''">
                            identity_id = #{identityId}
                    </if>
                    <if test="deleted != null">
                        deleted = #{deleted}
                    </if>
        </where>
    </select>
    <select id="selectByUserIdAndZoneId"
            resultType="cn.iocoder.yudao.module.knowledge.entity.TExpertZoneCollection">
        SELECT * FROM t_expert_zone_collection
                 WHERE user_id = #{userId} AND expert_zone_id = #{zoneId} AND deleted = 0
    </select>

</mapper>