AfmsDataMedicineMapper.xml
4.3 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
<?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.zhonglai.luhui.afms.mapper.AfmsDataMedicineMapper">
<resultMap type="AfmsDataMedicine" id="AfmsDataMedicineResult">
<result property="id" column="id" />
<result property="feeding_start_time" column="feeding_start_time" />
<result property="pond_id" column="pond_id" />
<result property="medicine_name" column="medicine_name" />
<result property="medicine_amount" column="medicine_amount" />
<result property="unit" column="unit" />
<result property="reason" column="reason" />
</resultMap>
<sql id="selectAfmsDataMedicineVo">
select `id`, `feeding_start_time`, `pond_id`, `medicine_name`, `medicine_amount`, `unit`, `reason` from afms_data_medicine
</sql>
<select id="selectAfmsDataMedicineList" parameterType="AfmsDataMedicine" resultMap="AfmsDataMedicineResult">
<include refid="selectAfmsDataMedicineVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="params.beginFeeding_start_time != null and params.beginFeeding_start_time != '' and params.endFeeding_start_time != null and params.endFeeding_start_time != ''"> and feeding_start_time between #{params.beginFeeding_start_time} and #{params.endFeeding_start_time}</if>
<if test="pond_id != null "> and pond_id = #{pond_id}</if>
<if test="medicine_name != null and medicine_name != ''"> and medicine_name like concat('%', #{medicine_name}, '%')</if>
<if test="unit != null and unit != ''"> and unit like concat('%', #{unit}, '%')</if>
<if test="reason != null and reason != ''"> and reason like concat('%', #{reason}, '%')</if>
</where>
</select>
<select id="selectAfmsDataMedicineById" parameterType="Integer" resultMap="AfmsDataMedicineResult">
<include refid="selectAfmsDataMedicineVo"/>
where id = #{id}
</select>
<insert id="insertAfmsDataMedicine" parameterType="AfmsDataMedicine" useGeneratedKeys="true" keyProperty="id">
insert into afms_data_medicine
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="feeding_start_time != null">feeding_start_time,</if>
<if test="pond_id != null">pond_id,</if>
<if test="medicine_name != null and medicine_name != ''">medicine_name,</if>
<if test="medicine_amount != null">medicine_amount,</if>
<if test="unit != null and unit != ''">unit,</if>
<if test="reason != null and reason != ''">reason,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="feeding_start_time != null">#{feeding_start_time},</if>
<if test="pond_id != null">#{pond_id},</if>
<if test="medicine_name != null and medicine_name != ''">#{medicine_name},</if>
<if test="medicine_amount != null">#{medicine_amount},</if>
<if test="unit != null and unit != ''">#{unit},</if>
<if test="reason != null and reason != ''">#{reason},</if>
</trim>
</insert>
<update id="updateAfmsDataMedicine" parameterType="AfmsDataMedicine">
update afms_data_medicine
<trim prefix="SET" suffixOverrides=",">
<if test="feeding_start_time != null">feeding_start_time = #{feeding_start_time},</if>
<if test="pond_id != null">pond_id = #{pond_id},</if>
<if test="medicine_name != null and medicine_name != ''">medicine_name = #{medicine_name},</if>
<if test="medicine_amount != null">medicine_amount = #{medicine_amount},</if>
<if test="unit != null and unit != ''">unit = #{unit},</if>
<if test="reason != null and reason != ''">reason = #{reason},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAfmsDataMedicineById" parameterType="Integer">
delete from afms_data_medicine where id = #{id}
</delete>
<delete id="deleteAfmsDataMedicineByIds" parameterType="String">
delete from afms_data_medicine where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>