<?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.TExpertMapper">

    <resultMap type="cn.iocoder.yudao.module.knowledge.entity.TExpert" id="tExpertMap">
            <result property="id" column="id"/>
            <result property="username" column="username"/>
            <result property="usercode" column="usercode"/>
            <result property="phone" column="phone"/>
            <result property="sex" column="sex"/>
            <result property="headPortrait" column="head_portrait"/>
            <result property="educationBackground" column="education_background"/>
            <result property="introduce" column="introduce"/>
            <result property="domainExpert" column="domain_expert"/>
            <result property="post" column="post"/>
            <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,username,usercode,phone,sex,head_portrait,education_background,introduce,domain_expert,post,create_time,update_time,dept_id,identity_id,deleted
    </sql>
    <update id="deleteByid">
        update t_expert set deleted = 1 where id = #{id}
    </update>
    <select id="findList" resultMap="tExpertMap">
        select
        <include refid="columns"/>
        from t_expert
        <where>
            deleted = 0
                    <if test="params.username != null and params.username != ''">
                        and  username = #{params.username}
                    </if>
                    <if test="params.usercode != null and params.usercode != ''">
                        and  usercode = #{params.usercode}
                    </if>
                    <if test="params.phone != null and params.phone != ''">
                        and   phone = #{params.phone}
                    </if>
                    <if test="params.sex != null and params.sex != ''">
                        and  sex = #{params.sex}
                    </if>
                    <if test="params.headPortrait != null and params.headPortrait != ''">
                        and  head_portrait = #{params.headPortrait}
                    </if>
                    <if test="params.educationBackground != null and params.educationBackground != ''">
                        and   education_background = #{params.educationBackground}
                    </if>
                    <if test="params.introduce != null and params.introduce != ''">
                        and   introduce = #{params.introduce}
                    </if>
                    <if test="params.domainExpert != null and params.domainExpert != ''">
                        and  domain_expert = #{params.domainExpert}
                    </if>
                    <if test="params.post != null and params.post != ''">
                        and  post = #{params.post}
                    </if>
                    <if test="params.createTime != null">
                        and create_time = #{params.createTime}
                    </if>
                    <if test="params.updateTime != null">
                        and update_time = #{params.updateTime}
                    </if>
                    <if test="params.deptId != null and params.deptId != ''">
                        and   dept_id = #{params.deptId}
                    </if>
                    <if test="params.identityId != null and params.identityId != ''">
                        and   identity_id = #{params.identityId}
                    </if>
        </where>
    </select>
    <select id="selectByUsercode" resultType="cn.iocoder.yudao.module.knowledge.entity.TExpert">
        select * from t_expert
        where usercode = #{usercode} and deleted = 0
    </select>

</mapper>