zhangback
7 天以前 ca412ade3b178fbc8ba0a4b6215a040acdede954
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?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.ruoyi.tms.mapper.TmsRegionMapper">
 
    <resultMap type="com.ruoyi.tms.domain.TmsRegion" id="TmsRegionResult">
        <result property="id"    column="id"    />
        <result property="level"    column="level"    />
        <result property="regionCode"    column="region_code"    />
        <result property="regionName"    column="region_name"    />
        <result property="postalCode"    column="postal_code"    />
        <result property="nameTree"    column="name_tree"    />
        <result property="parentRegionCode"    column="parent_region_code"    />
        <result property="sortOrder"    column="sort_order"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>
 
    <sql id="selectTmsRegionVo">
        select thisTab.id, thisTab.level, thisTab.region_code, thisTab.region_name, thisTab.postal_code, thisTab.name_tree, thisTab.parent_region_code, thisTab.sort_order, thisTab.status, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.remark from tms_region AS thisTab
    </sql>
    <sql id="selectTmsRegionVoCount">
        select count(0) from tms_region as thisTab
    </sql>
 
    <sql id="whereCondition">
        <if test="level != null "> and thisTab.level = #{level}</if>
        <if test="regionCode != null  and regionCode != ''"> and thisTab.region_code = #{regionCode}</if>
        <if test="regionName != null  and regionName != ''"> and  thisTab.region_name like concat('%', #{regionName}, '%')</if>
        <if test="postalCode != null  and postalCode != ''"> and thisTab.postal_code = #{postalCode}</if>
        <if test="nameTree != null  and nameTree != ''"> and thisTab.name_tree = #{nameTree}</if>
        <if test="parentRegionCode != null  and parentRegionCode != ''"> and thisTab.parent_region_code = #{parentRegionCode}</if>
        <if test="sortOrder != null "> and thisTab.sort_order = #{sortOrder}</if>
        <if test="status != null "> and thisTab.status = #{status}</if>
        <if test="updateBy != null  and updateBy != ''"> and thisTab.update_by = #{updateBy}</if>
        <if test="updateTime != null "> and thisTab.update_time = #{updateTime}</if>
    </sql>
 
    <!--查询-->
    <select id="selectTmsRegionById" parameterType="Integer" resultMap="TmsRegionResult">
        <include refid="selectTmsRegionVo"/>
        where id = #{id}
    </select>
 
    <select id="selectTmsRegionCount" parameterType="com.ruoyi.tms.domain.TmsRegion" resultType="int">
        <include refid="selectTmsRegionVoCount"/>
        <where>
            <include refid="whereCondition"/>
        </where>
    </select>
 
    <select id="selectTmsRegionList" parameterType="com.ruoyi.tms.domain.TmsRegion" resultMap="TmsRegionResult">
        <include refid="selectTmsRegionVo"/>
        <where>
            <include refid="whereCondition"/>
        </where>
    </select>
    <select id="selectRegionVoList" resultType="com.ruoyi.tms.domain.vo.RegionVo">
        select      thisTab.region_code as code, thisTab.region_name as name   from tms_region thisTab
        <where>
            <if test="parentRegionCode != null  and parentRegionCode != ''"> and thisTab.parent_region_code = #{parentRegionCode}</if>
        </where>
    </select>
 
    <!-- 新增 -->
    <insert id="insertTmsRegion" parameterType="com.ruoyi.tms.domain.TmsRegion"  useGeneratedKeys="true" keyProperty="id">
        insert into tms_region
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="level != null">level,</if>
            <if test="regionCode != null and regionCode != ''">region_code,</if>
            <if test="regionName != null and regionName != ''">region_name,</if>
            <if test="postalCode != null">postal_code,</if>
            <if test="nameTree != null">name_tree,</if>
            <if test="parentRegionCode != null">parent_region_code,</if>
            <if test="sortOrder != null">sort_order,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="level != null">#{level},</if>
            <if test="regionCode != null and regionCode != ''">#{regionCode},</if>
            <if test="regionName != null and regionName != ''">#{regionName},</if>
            <if test="postalCode != null">#{postalCode},</if>
            <if test="nameTree != null">#{nameTree},</if>
            <if test="parentRegionCode != null">#{parentRegionCode},</if>
            <if test="sortOrder != null">#{sortOrder},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>
 
    <insert id="insertTmsRegionBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into tms_region
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            id,level,region_code,region_name,postal_code,name_tree,parent_region_code,sort_order,status,create_by,create_time,update_by,update_time,remark,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.id},#{item.level},#{item.regionCode},#{item.regionName},#{item.postalCode},#{item.nameTree},#{item.parentRegionCode},#{item.sortOrder},#{item.status},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.remark},
            </trim>
        </foreach>
    </insert>
 
    <!-- 修改 -->
    <update id="updateTmsRegion" parameterType="com.ruoyi.tms.domain.TmsRegion">
        update tms_region
        <trim prefix="SET" suffixOverrides=",">
            <if test="level != null">level = #{level},</if>
            <if test="regionCode != null and regionCode != ''">region_code = #{regionCode},</if>
            <if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
            <if test="postalCode != null">postal_code = #{postalCode},</if>
            <if test="nameTree != null">name_tree = #{nameTree},</if>
            <if test="parentRegionCode != null">parent_region_code = #{parentRegionCode},</if>
            <if test="sortOrder != null">sort_order = #{sortOrder},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 修改 -->
    <update id="updateTmsRegionBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";">
            update tms_region
            <trim prefix="SET" suffixOverrides=",">
                <if test="item.level != null">level = #{item.level},</if>
                <if test="item.regionCode != null and item.regionCode != ''">region_code = #{item.regionCode},</if>
                <if test="item.regionName != null and item.regionName != ''">region_name = #{item.regionName},</if>
                <if test="item.postalCode != null">postal_code = #{item.postalCode},</if>
                <if test="item.nameTree != null">name_tree = #{item.nameTree},</if>
                <if test="item.parentRegionCode != null">parent_region_code = #{item.parentRegionCode},</if>
                <if test="item.sortOrder != null">sort_order = #{item.sortOrder},</if>
                <if test="item.status != null">status = #{item.status},</if>
                <if test="item.createBy != null">create_by = #{item.createBy},</if>
                <if test="item.createTime != null">create_time = #{item.createTime},</if>
                <if test="item.updateBy != null">update_by = #{item.updateBy},</if>
                <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
            </trim>
        where id = #{item.id}
        </foreach>
    </update>
 
    <!--删除-->
    <delete id="deleteTmsRegionById" parameterType="Integer">
        delete from tms_region where id = #{id}
    </delete>
    <delete id="deleteTmsRegionByIds" parameterType="Integer">
        delete from tms_region where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>