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


    <select id="selectPageTS" parameterType="cn.iocoder.yudao.module.knowledge.controller.requestdto.ExpertRequestPage"
            resultType="cn.iocoder.yudao.module.knowledge.entity.TSpecialist">

        SELECT
        ts.*,tem.tag_name as tagName
        FROM
        t_specialist ts
        left join t_expert_maintenance tem on ts.domain_expert = tem.id
        WHERE ts.deleted = 0
        <if test="request.searchKey != '' and request.searchKey != null">
            and (ts.`username` LIKE CONCAT( '%',#{request.searchKey}, '%') or ts.`usercode` LIKE CONCAT( '%',#{request.searchKey}, '%'))
        </if>
        ORDER BY
        ts.create_time DESC
    </select>
    <select id="selectByUsercode" resultType="cn.iocoder.yudao.module.knowledge.entity.TSpecialist">
        select * from t_specialist
        where usercode = #{usercode} and deleted = 0
    </select>
    <select id="selectList" resultType="cn.iocoder.yudao.module.knowledge.entity.TSpecialist">
        SELECT
        ts.*,tem.tag_name as tagName
        FROM
        t_specialist ts
        left join t_expert_maintenance tem on ts.domain_expert = tem.id
        WHERE ts.deleted = 0
        <if test="request.searchKey != '' and request.searchKey != null">
            and ts.`username` LIKE CONCAT( '%',#{request.searchKey}, '%')
        </if>
        ORDER BY
        ts.create_time DESC
    </select>


    <select id="findOne" resultType="cn.iocoder.yudao.module.knowledge.entity.TSpecialist">
        SELECT
            ts.*,tem.tag_name as tagName
        FROM
            t_specialist ts
                left join t_expert_maintenance tem on ts.domain_expert = tem.id
        WHERE ts.deleted = 0

          and ts.`id` = #{id}

        ORDER BY
            ts.create_time DESC
    </select>

</mapper>

