liurunyu
3 天以前 1cf88d43994ec7ec403319032a9d118b39fe3571
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
<?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.dy.pipIrrGlobal.daoIr.IrGroupUnitMapper">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrGroupUnit">
        <!--@mbg.generated-->
        <!--@Table ir_group_unit-->
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="group_id" jdbcType="BIGINT" property="groupId" />
        <result column="unit_id" jdbcType="BIGINT" property="unitId" />
        <result column="operator" jdbcType="BIGINT" property="operator" />
        <result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" />
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, group_id, unit_id, `operator`,
        operate_time
    </sql>
 
    <!--添加-->
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrGroupUnit">
        <!--@mbg.generated-->
        insert into ir_group_unit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="groupId != null">
                group_id,
            </if>
            <if test="unitId != null">
                unit_id,
            </if>
            <if test="operator != null">
                `operator`,
            </if>
            <if test="operateDt != null">
                operate_time,
            </if>
 
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="groupId != null">
                #{groupId,jdbcType=BIGINT},
            </if>
            <if test="unitId != null">
                #{unitId,jdbcType=BIGINT},
            </if>
            <if test="operator != null">
                #{operator,jdbcType=BIGINT},
            </if>
            <if test="operateDt != null">
                #{operateDt,jdbcType=TIMESTAMP},
            </if>
 
        </trim>
    </insert>
 
 
 
    <delete id="deleteByUnitIdGroupId" parameterType="com.dy.pipIrrGlobal.pojoIr.IrGroupUnit">
        delete from ir_group_unit
        where group_id = #{groupId,jdbcType=BIGINT} and unit_id = #{unitId,jdbcType=BIGINT}
    </delete>
 
    <delete id="deleteByUnitId">
        delete from ir_group_unit
        where unit_id = #{unitId,jdbcType=BIGINT}
    </delete>
 
    <delete id="deleteByGroupId">
        delete from ir_group_unit
        where group_id = #{groupId,jdbcType=BIGINT}
    </delete>
 
<!--    //查一个轮灌组绑定的灌溉单元id-->
    <select id="getGroupBindUnits" parameterType="Long" resultType="java.lang.Long">
        SELECT unit_id AS unitId FROM `ir_group_unit`WHERE group_id = #{groupId,jdbcType=BIGINT}
    </select>
 
    <select id="getNotBindUnits" resultType="java.lang.Long">
        SELECT id FROM ir_irrigate_unit  WHERE id NOT IN (SELECT unit_id  FROM ir_group_unit)
    </select>
</mapper>