SalesManMapper.xml
1.63 KB
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
<?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.project.demo.mapper.SalesManMapper">
<resultMap id="salesManMap" type="com.project.demo.domain.SalesMan">
<result column="users_id" property="usersId" />
<result column="projects_id" property="projectsId" />
<result column="state" property="state" />
</resultMap>
<select id="search" resultMap="salesManMap" resultType="Map">
SELECT
*
FROM sales_man
where 1=1
<if test="params.usersId != null">
AND users_id = #{params.usersId}
</if>
<if test="params.projectsId != null">
AND projects_id = #{params.projectsId}
</if>
</select>
<delete id = "delete">
DELETE FROM sales_man where users_id=#{usersId} and projects_id = #{projectsId}
</delete>
<insert id="insert" parameterType="com.project.demo.domain.SalesMan">
insert into sales_man
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="usersId != null">
users_id,
</if>
<if test="projectsId != null">
projects_id,
</if>
<if test="state != null">
state,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="usersId != null">
#{usersId},
</if>
<if test="projectsId != null">
#{projectsId},
</if>
<if test="state != null">
#{state},
</if>
</trim>
</insert>
</mapper>