<?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.yunniu.farming.webadmin.dao.AddressDao" > <resultMap id="BaseResultMap" type="com.yunniu.farming.webadmin.model.Address" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="customerid" property="customerid" jdbcType="INTEGER" /> <result column="itype" property="itype" jdbcType="INTEGER" /> <result column="isex" property="isex" jdbcType="INTEGER" /> <result column="sname" property="sname" jdbcType="VARCHAR" /> <result column="sphone" property="sphone" jdbcType="VARCHAR" /> <result column="sprovince" property="sprovince" jdbcType="VARCHAR" /> <result column="scity" property="scity" jdbcType="VARCHAR" /> <result column="sregion" property="sregion" jdbcType="VARCHAR" /> <result column="saddress" property="saddress" jdbcType="VARCHAR" /> <result column="isdefault" property="isdefault" jdbcType="INTEGER" /> <result column="spoiaddr" property="spoiaddr" jdbcType="VARCHAR" /> <result column="dlng" property="dlng" jdbcType="DECIMAL" /> <result column="dlat" property="dlat" jdbcType="DECIMAL" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> <!-- 一对一关联用户信息 --> <association property="customer" column="customerid" select="findCustomer"></association> </resultMap> <!-- 一对一关联用户信息 --> <select id="findCustomer" parameterType="String" resultType="com.yunniu.farming.webadmin.model.Customer"> select * from customer where id = #{customerid,jdbcType=INTEGER} </select> <sql id="Base_Column_List" > id, customerid, itype, isex, sname, sphone, sprovince, scity, sregion, saddress, isdefault, spoiaddr, dlng, dlat, sdef1, sdef2, sdef3, sdef4, sdef5, idef6, idef7, ddef8, ddef9, ddef10 </sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select 'false' as QUERYID, <include refid="Base_Column_List" /> from address where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from address where id = #{id,jdbcType=INTEGER} </delete> <!-- 更新默认地址 --> <update id="updateDefault" parameterType="com.yunniu.farming.webadmin.model.Address" > update address set isdefault = 0 where customerid = #{customerid,jdbcType=INTEGER} AND id != #{id,jdbcType=INTEGER} </update> <!-- 带参分页查询 --> <select id="selectByParamPageList" resultMap="BaseResultMap" parameterType="com.yunniu.farming.webadmin.model.Address"> select <include refid="Base_Column_List"/> from address <where> <if test="customerid != null" > AND customerid = #{customerid,jdbcType=INTEGER} </if> <if test="sname != null" > AND sname = #{sname,jdbcType=VARCHAR} </if> <if test="isdefault != null" > AND isdefault = #{isdefault,jdbcType=INTEGER} </if> <if test="itype != null" > AND itype = #{itype,jdbcType=INTEGER} </if> </where> </select> <!-- 带参不分页查询 --> <select id="selectByParam" resultMap="BaseResultMap" parameterType="com.yunniu.farming.webadmin.model.Address"> select <include refid="Base_Column_List"/> from address <where> <if test="customerid != null" > AND customerid = #{customerid,jdbcType=INTEGER} </if> <if test="isdefault != null" > AND isdefault = #{isdefault,jdbcType=INTEGER} </if> <if test="itype != null" > AND itype = #{itype,jdbcType=INTEGER} </if> </where> </select> </mapper>