ComExpertDAO.xml 2.82 KB
<?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.yiboshi.science.dao.ComExpertDAO">
    <sql id="allColumns">
        t.id as id, t.expert_id as expertId, t.spec_id as specId, t.created as created, t.updated as updated
    </sql>
    <select id="getListByPage" resultType="com.yiboshi.science.param.dto.ComExpertDTO">
        SELECT distinct
        a.*,e.person_name,e.sex,e.cert_id,e.mobile,e.email,e.unit_id,e.work_unit,e.person_state,e.degree,
        d.unit_name,d.unit_type,g.name nation_name,h.name education_name,
        i.name title_name,f.username,f.id user_id,l.id user_role_id,l.state,
        (case l.state when 1 then '启用' else '停用' end) state_name
        FROM com_expert a
        LEFT JOIN com_person e ON a.person_id = e.id
        LEFT JOIN com_unit d ON e.unit_id = d.id
        LEFT JOIN system_user f ON f.person_id = e.id
        LEFT JOIN system_user_role l ON l.user_id = f.id
        left join system_parameter g on e.nation=g.id and g.type_id=11
        left join system_parameter h on e.education=h.id and h.type_id=8
        left join system_parameter i on e.title=i.id and i.type_id=7
       -- left join system_parameter m on i.parent_id = m.id
        left join com_expert_spec p on a.id=p.expert_id
        left join system_parameter j on p.spec_id=j.id
      -- left join system_parameter k on j.parent_id = k.id
        <where>
            ${ew.sqlSegment}
        </where>
        ORDER BY d.tree_code ASC
    </select>
    <select id="getExpertById" parameterType="java.lang.String" resultType="com.yiboshi.science.param.dto.ComExpertDTO">
        SELECT x.*,a.person_name,a.cert_id,a.sex,a.birthday,a.mobile,a.email,a.education,a.title,a.unit_id,a.work_unit
               ,b.tree_code,b.unit_name,d.name education_name,e.name title_name
        FROM com_expert x
        LEFT JOIN com_person a ON x.person_id = a.id
        LEFT JOIN com_unit b ON a.unit_id = b.id
        left join system_parameter d on a.education=d.id and d.type_id=8
        left join system_parameter e on a.title=e.id and e.type_id=7
        where x.id = #{id}
    </select>
    <select id="getExpertByCertId" parameterType="java.lang.String" resultType="com.yiboshi.science.param.dto.ComExpertDTO">
        SELECT x.*,a.person_name,a.cert_id,a.sex,a.birthday,a.mobile,a.email,a.title,a.work_unit,a.degree,a.spec,a.address
        FROM com_expert x
        LEFT JOIN com_person a ON x.person_id = a.id
        where a.cert_id = #{certId}
    </select>
    <select id="getExpertListByIdList"  resultType="com.yiboshi.science.param.dto.ComExpertDTO">
        select a.id,c.person_name
        from com_expert a
        left join com_person c on a.person_id=c.id
        <where>
            ${ew.sqlSegment}
        </where>
    </select>
</mapper>