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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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>