田源
2023-05-09 549ecbf13b14a4deb74e42828abcd46ccb68a7c0
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
102
103
104
105
106
107
108
109
110
111
<?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.vci.ubcs.omd.mapper.BtmTypeAttributeMapper">
 
    <resultMap id="base_result_map" type="com.vci.ubcs.omd.entity.BtmTypeAttribute">
        <id column="oid" jdbcType="VARCHAR" property="oid"/>
        <result column="id" jdbcType="VARCHAR" property="id"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="pk_btm_type" jdbcType="VARCHAR" property="pkBtmType"/>
        <result column="attribute_length" jdbcType="DECIMAL" property="attributeLength"/>
        <result column="attr_data_type" jdbcType="VARCHAR" property="attrDataType"/>
        <result column="nullable_flag" jdbcType="VARCHAR" property="nullableFlag"/>
        <result column="default_value" jdbcType="VARCHAR" property="defaultValue"/>
        <result column="precision_length" jdbcType="DECIMAL" property="precisionLength"/>
        <result column="scale_length" property="scaleLength" jdbcType="DECIMAL"/>
        <result column="range" jdbcType="VARCHAR" property="range"/>
        <result column="refer_btm_type_id" jdbcType="VARCHAR" property="referBtmTypeId"/>
        <result column="refer_btm_type_name" jdbcType="VARCHAR" property="referBtmTypeName"/>
        <result column="enum_id" jdbcType="VARCHAR" property="enumId"/>
        <result column="enum_name" jdbcType="VARCHAR" property="enumName"/>
        <result column="btm_name" property="btmName" jdbcType="VARCHAR"/>
        <result column="owner" property="owner" jdbcType="VARCHAR"/>
        <result column="creator" jdbcType="VARCHAR" property="creator"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="last_modifier" jdbcType="VARCHAR" property="lastModifier"/>
        <result column="last_modify_time" jdbcType="TIMESTAMP" property="lastModifyTime"/>
        <result column="ts" jdbcType="TIMESTAMP" property="ts"/>
    </resultMap>
 
    <sql id="base_query_column">
        oid, id, name, description, pk_btm_type, attribute_length, attr_data_type, nullable_flag,
        default_value, precision_length, scale_length, range, refer_btm_type_id, refer_btm_type_name,
        enum_id, enum_name, btm_name, owner, creator, create_time, last_modifier, last_modify_time, ts
    </sql>
 
    <sql id="tableName">
        pl_omd_btm_type_attribute
    </sql>
    <sql id="btmTypeTableName">
        pl_omd_btm_type
    </sql>
    <update id="batchUpdate" parameterType="java.util.List">
        <foreach collection="records" item="item" index="index" open="begin" close=";end;" separator=";">
            update <include refid="tableName"/> set
                id = #{item.id,jdbcType=VARCHAR},
                name = #{item.name,jdbcType=VARCHAR},
                descrption = #{item.decription,jdbcType=VARCHAR},
                pk_btm_type = #{item.pkBtmType,jdbcType=VARCHAR},
                attribute_length = #{item.attributeLength,jdbcType=DECIMAL},
                attr_data_type = #{item.attrDataType,jdbcType=VARCHAR},
                nullable_flag = #{item.nullableFlag,jdbcType=VARCHAR},
                default_value = #{item.defaultValue,jdbcType=VARCHAR},
                precision_length = #{item.precisionLength,jdbcType=DECIMAL},
                scale_length = #{item.scaleLength,jdbcType=DECIMAL},
                range = #{item.range,jdbcType=VARCHAR},
                refer_btm_type_id = #{item.referBtmTypeId,jdbcType=VARCHAR},
                refer_btm_type_name = #{item.referBtmTypeName,jdbcType=VARCHAR},
                enum_id = #{item.enumId,jdbcType=VARCHAR},
                enum_name = #{item.enumName,jdbcType=VARCHAR},
                btm_name = #{item.btmName,jdbcType=VARCHAR},
                owner = #{item.owner,jdbcType=VARCHAR},
                creator = #{item.creator,jdbcType=VARCHAR},
                create_time = #{item.createTime,jdbcType=TIMESTAMP},
                last_modifier = #{item.lastModifier,jdbcType=VARCHAR},
                last_modify_time = #{item.lastModifyTime,jdbcType=TIMESTAMP},
                ts = #{item.ts,jdbcType=TIMESTAMP}
        </foreach>
    </update>
    <delete id="batchDelete">
        delete from
        <include refid="tableName"/>
        <where>
            <foreach collection="records" item="item" index="arrayindex" open="oid in (" close=")">
                #{item,jdbcType=VARCHAR}
                <if test="(arrayindex != records.size() -1)">
                    ,
                </if>
            </foreach>
        </where>
    </delete>
    <select id="selectByBtmTypeIdAndAttributeIds" resultType="com.vci.ubcs.omd.entity.BtmTypeAttribute">
        select <include refid="base_query_column"/>
        from <include refid="tableName" />
        where PKBTMTYPE = (select oid from <include refid="btmTypeTableName"/> where lower(id) = lower(#{btmTypeId,jdbcType=VARCHAR}) )
        <if test="ids.size() > 0">
            and
            <foreach collection="ids" item="item" index="arrayindex" open=" lower(ID) in ( " close=")" >
                lower(#{item,jdbcType=VARCHAR})
                <if test="(arrayindex != ids.size() -1)">
                    ,
                </if>
            </foreach>
        </if>
    </select>
    <select id="selectByBtmTypeIds" resultType="com.vci.ubcs.omd.entity.BtmTypeAttribute">
        select DISTINCT <include refid="base_query_column" />
        from <include refid="tableName" />
        where PKBTMTYPE IN (
        select oid from <include refid="btmTypeTableName"/> where
        <foreach collection="ids" item="item" index="arrayindex" open=" lower(ID) in ( " close=")" >
            lower(#{item,jdbcType=VARCHAR})
            <if test="(arrayindex != ids.size() -1)">
                ,
            </if>
        </foreach>
        )
        order by id asc
    </select>
 
</mapper>