<?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.ProjectMapper"> <sql id="where"> <where> <if test="params.code != null and params.code != ''"> and t.code like concat('%', #{params.code}, '%') </if> <if test="params.clientId != null"> and t.client_id = #{params.clientId} </if> <if test="params.name != null and params.name != ''"> and t.name like concat('%', #{params.name}, '%') </if> </where> </sql> <select id="getPage" resultType="cn.wise.sc.cement.business.model.vo.ProjectVo"> select t.*,cl.name clientName FROM project t left join client cl on cl.id = t.client_id <include refid="where"/> order by t.id desc </select> <select id="getList" resultType="cn.wise.sc.cement.business.model.vo.ProjectVo"> select t.*, cl.id as clientId, cl.name clientName FROM project t left join client cl on cl.id = t.client_id where t.status = 1 order by t.id desc </select> <select id="getProjectList" resultType="cn.wise.sc.cement.business.model.vo.ProjectVo"> select t.*, cl.id as clientId, cl.name clientName FROM project t left join client cl on cl.id = t.client_id where t.status = 1 <if test="clientId != null"> and t.client_id = #{clientId} </if> order by t.id desc </select> <select id="getByName" resultType="cn.wise.sc.cement.business.model.vo.ProjectVo"> select t.*, cl.id as clientId, cl.name clientName FROM project t left join client cl on cl.id = t.client_id where t.status = 1 and t.name=#{name} </select> <select id="exportList" resultType="java.util.HashMap"> SELECT (@i:=@i+1) as 序号, t.name as 项目名称, t.code as 项目编号, cl.name as 所属单位 FROM project t left join client cl on cl.id = t.client_id ,(select @i:=0)t <include refid="where"/> ORDER BY t.id DESC </select> </mapper>