WorkReportMapper.xml
4.23 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?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.trash.report.mapper.WorkReportMapper">
<resultMap type="WorkReport" id="WorkReportResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="writer" column="writer" />
<result property="writeTime" column="write_time" />
<result property="reportContent" column="report_content" />
<result property="type" column="type" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="attachmentLink" column="attachment_link" />
</resultMap>
<sql id="selectWorkReportVo">
select id, title, writer, write_time, report_content,type,start_time,end_time,create_by,create_time,attachment_link from work_report
</sql>
<select id="selectWorkReportList" parameterType="WorkReport" resultMap="WorkReportResult">
<include refid="selectWorkReportVo"/>
<where>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
</where>
</select>
<select id="selectWorkReportById" parameterType="Long" resultMap="WorkReportResult">
<include refid="selectWorkReportVo"/>
where id = #{id}
</select>
<insert id="insertWorkReport" parameterType="WorkReport" useGeneratedKeys="true" keyProperty="id">
insert into work_report
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">title,</if>
<if test="writer != null and writer != ''">writer,</if>
<if test="writeTime != null">write_time,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="reportContent != null ">report_content,</if>
<if test="createBy != ''">create_by,</if>
<if test="attachmentLink!= null">attachment_link,</if>
create_time,
type,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="writer != null and writer != ''">#{writer},</if>
<if test="writeTime != null">#{writeTime},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="reportContent != null ">#{reportContent},</if>
<if test="createBy != ''">#{createBy},</if>
<if test="attachmentLink!= null ">#{attachmentLink},</if>
NOW(),
#{type}
</trim>
</insert>
<update id="updateWorkReport" parameterType="WorkReport">
update work_report
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="writer != null and writer != ''">writer = #{writer},</if>
<if test="writeTime != null">write_time = #{writeTime},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="reportContent != null ">report_content = #{reportContent},</if>
<if test="attachmentLink!= null ">attachment_link = #{attachmentLink},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWorkReportById" parameterType="Long">
delete from work_report where id = #{id}
</delete>
<delete id="deleteWorkReportByIds" parameterType="String">
delete from work_report where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>