AreaMapper.xml
2.04 KB
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
<?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.yoho.order.dal.AreaMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.Area">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="INTEGER" />
<result column="caption" property="caption" jdbcType="VARCHAR" />
<result column="is_support" property="isSupport" jdbcType="VARCHAR" />
<result column="is_delivery" property="isDelivery" jdbcType="VARCHAR" />
<result column="is_cash_delivery" property="isCashDelivery" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id, code, caption, is_support, is_delivery, is_cash_delivery, status
</sql>
<select id="selectByCodeList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from area where 1=1
<if test="codeList != null and codeList.size()>0">
and id in
<foreach collection="codeList" item="code" open="(" close=")" separator=",">
#{code}
</foreach>
</if>
</select>
<select id="selectByParentCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from area where 1=1
<if test='parentCode=="0"'>
and length(id)=2
</if>
<if test="parentCode.length()==2">
and length(id)=4 and left(id,2)=#{parentCode}
</if>
<if test="parentCode.length()==4">
and left(id,4)=#{parentCode} and length(id) >4 and length(id) <9
</if>
<if test="parentCode.length()==6">
and left(id, 6)=#{parentCode} and length(id) >6
</if>
</select>
<insert id="insertArea" parameterType="com.yoho.order.model.Area">
insert into area(id, code, caption)
values (#{id}, #{code}, #{caption})
</insert>
</mapper>