ClientMapper.xml 1.56 KB
Newer Older
qinhu's avatar
1  
qinhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?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.wise.sc.cement.business.mapper.ClientMapper">

    <sql id="where">
        <where>
            <if test="params.status != null">
                and t.status = #{params.status}
            </if>
            <if test="params.region != null and params.region != ''">
                and t.region like concat('%', #{params.region}, '%')
            </if>
            <if test="params.principal != null and params.principal != ''">
                and t.principal like concat('%', #{params.principal}, '%')
            </if>
        </where>
    </sql>

    <select id="getPage" resultType="cn.wise.sc.cement.business.model.vo.ClientVo">
        select t.*,
        (select count(*) from project p where p.client_id = t.id) projectNums
        from client t
        <include refid="where"/>
        order by t.id desc
    </select>


    <select id="exportList" resultType="java.util.HashMap">
        SELECT
        (@i:=@i+1) as 序号,
        t.name as 单位名称,
        t.principal as 联系人,
        t.principal_phone as 联系电话,
        t.region as 所在地区,
        (select count(*) from project p where p.client_id = t.id) as 项目数,
        (
        CASE t.status
        WHEN 0 THEN '已禁用'
        WHEN 1 THEN '已启用'
        ELSE NULL
        END
        ) as 状态
        FROM client t,(select @i:=0)t
        <include refid="where"/>
        ORDER BY t.id DESC
    </select>


</mapper>