aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
blob: f0bc629664eb6d051731c07f99209a9a98771488 (plain)
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
<?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="org.onap.usecaseui.intentanalysis.mapper.ConditionMapper">

    <insert id="insertConditionList">
        insert into condition(condition_id, condition_name, operator_type, condition_value, parent_id)
        values
        <foreach collection="conditionList" index="index" item="item" separator=",">
            (#{item.conditionId}, #{item.conditionName}, #{item.operator}, #{item.conditionValue}, #{parentId})
        </foreach>
    </insert>

    <insert id="insertConditionParentList">
        insert into condition_mapping(condition_id, parent_type, parent_id)
        values
        <foreach collection="conditionList" index="index" item="item" separator=",">
            (#{item.conditionId}, #{parentType}, #{parentId})
        </foreach>
    </insert>

    <insert id="insertCondition">
        insert into condition(condition_id, condition_name, operator_type, condition_value, parent_id)
        values
            (#{condition.conditionId}, #{condition.conditionName}, #{condition.operator}, #{condition.conditionValue}, #{parentId})
    </insert>
    <!--    这里的查询有问题-->
    <select id="selectConditionList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
        select condition_id conditionId, condition_name conditionName, operator_type "operator", condition_value conditionValue
        from condition
        where parent_id = #{parentId}
    </select>

    <select id="selectCondition" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
        select condition_id conditionId, condition_name conditionName, operator_type "operator", condition_value conditionValue
        from condition
        where condition_id = #{conditionId}
    </select>

    <update id="updateCondition">
        update condition
        <trim prefix="set" suffixOverrides=",">
            <if test="condition.conditionName != null">condition_name = #{condition.conditionName},</if>
            <if test="condition.operator != null">operator_type = #{condition.operator},</if>
            <if test="condition.conditionValue != null">condition_value = #{condition.conditionValue},</if>
        </trim>
        where condition_id = #{condition.conditionId}
    </update>

    <delete id="deleteCondition">
        DELETE FROM condition WHERE condition_id = #{conditionId}
    </delete>

    <delete id="deleteConditionList">
        DELETE FROM condition WHERE parent_id = #{parentId}
    </delete>

</mapper>