zhangf
2024-05-08 0414ddb0b2b3a7199ae6181a770f97ac140dbd73
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
94
95
96
97
98
99
100
101
<?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.gkhy.safePlatform.emergency.repository.EmergencyPlanLogInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyPlanLogInfoDO" id="emergencyPlanLogInfoDOResult">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="plan_id" property="planId"/>
        <result column="user_uid" property="userUid"/>
        <result column="user_name" property="userName"/>
        <result column="start_create" property="startCreate"/>
        <result column="remark" property="remark"/>
    </resultMap>
 
    <select id="selectEmergencyPlanLogList" resultMap="emergencyPlanLogInfoDOResult">
 
        SELECT
        a.id,
        a.`plan_id`,
        a.`user_uid`,
        a.user_name,
        a.`start_create`,
        a.`remark`,
        b.`name` AS planName
        FROM
        emergency_plan_log a
        LEFT JOIN emergency_plan b ON a.plan_id = b.id
        WHERE
        a.del_flag = 0
        <if test="query.planId != null  ">and a.`plan_id` = #{query.planId}</if>
    </select>
 
    <insert id="addEmergencyPlanLog" parameterType="com.gkhy.safePlatform.emergency.entity.EmergencyPlanLogInfo"
            keyProperty="id" useGeneratedKeys="true">
        insert into emergency_plan_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="delFlag != null ">del_flag,</if>
            <if test="gmtCreate != null ">gmt_create,</if>
            <if test="gmtModitify != null ">gmt_moditify,</if>
            <if test="createUid != null ">create_uid,</if>
            <if test="updateUid != null ">update_uid,</if>
            <if test="planId != null ">plan_id,</if>
            <if test="userUid != null ">user_uid,</if>
            <if test="userName != null and userName != ''">user_name,</if>
            <if test="startCreate != null ">start_create,</if>
            <if test="remark != null and remark != ''">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="delFlag != null ">#{delFlag},</if>
            <if test="gmtCreate != null ">#{gmtCreate},</if>
            <if test="gmtModitify != null ">#{gmtModitify},</if>
            <if test="createUid != null ">#{createUid},</if>
            <if test="updateUid != null ">#{updateUid},</if>
            <if test="planId != null ">#{planId},</if>
            <if test="userUid != null ">#{userUid},</if>
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="startCreate != null ">#{startCreate},</if>
            <if test="remark != null and remark != ''">#{remark},</if>
        </trim>
    </insert>
 
 
    <select id="selectEmergencyPlanLogById" resultMap="emergencyPlanLogInfoDOResult">
        SELECT
            a.id,
            a.`plan_id`,
            a.`user_uid`,
            a.user_name,
            a.`start_create`,
            a.`remark`,
            b.`name` AS planName
        FROM
            emergency_plan_log a
            LEFT JOIN emergency_plan b ON a.plan_id = b.id
        WHERE
            a.del_flag = 0
            AND a.id =  #{id}
 
    </select>
 
    <update id="updateEmergencyPlanLog" parameterType="com.gkhy.safePlatform.emergency.entity.EmergencyPlanLogInfo">
        update emergency_plan_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="gmtModitify != null ">gmt_moditify = #{gmtModitify},</if>
            <if test="updateUid != null ">update_uid = #{updateUid},</if>
            <if test="planId != null ">plan_id = #{planId},</if>
            <if test="userUid != null ">user_uid = #{userUid},</if>
            <if test="userName != null and userName != ''">user_name = #{userName},</if>
            <if test="startCreate != null ">start_create = #{startCreate},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
 
    <update id="deleteEmergencyPlanLog">
        update emergency_plan_log set del_flag = 1 where id = #{id}
    </update>
</mapper>