标签:
1. 功能复用,写成公共方法。
2.mybatis 不应该用 select *
<?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.hengxin.qianee.mapper.DictBankingMapper" > <resultMap id="BaseResultMap" type="com.hengxin.qianee.model.DictBanking" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="name" property="name" jdbcType="VARCHAR" /> <result column="bank_code" property="bankCode" jdbcType="VARCHAR" /> <result column="amount_day_limit" property="amount_day_limit" jdbcType="DECIMAL" /> <result column="amount_single_limit" property="amount_single_limit" jdbcType="DECIMAL" /> <result column="amount_month_limit" property="amount_month_limit" jdbcType="DECIMAL" /> <result column="is_use" property="is_use" jdbcType="INTEGER" /> <result column="images_path" property="images_path" jdbcType="VARCHAR" /> <result column="images_path_wx" property="imagesPathWx" jdbcType="VARCHAR" /> <result column="images_path_wx" property="imagesPathWx" jdbcType="VARCHAR" /> </resultMap> <sql id="Base_Column_List" > id, name, images_path,amount_single_limit,amount_day_limit,amount_month_limit,is_use,images_path_wx </sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select <include refid="Base_Column_List" /> from t_dict_banking where id = #{id,jdbcType=INTEGER} </select> <!-- 查询所有银行信息/图标、图片地址 --> <select id="selectBankingAll" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from t_dict_banking </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from t_dict_banking where id = #{id,jdbcType=INTEGER} </delete> <!-- 增加银行 --> <insert id="insert" parameterType="com.hengxin.qianee.model.DictBanking" > insert into t_dict_banking (id, name, images_path,amount_day_limit,amount_single_limit,amount_month_limit,is_use ) values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{images_path,jdbcType=VARCHAR},#{amount_day_limit,jdbcType=DECIMAL}, #{amount_single_limit,jdbcType=DECIMAL},#{amount_month_limit,jdbcType=DECIMAL},#{is_use,jdbcType=INTEGER} ) </insert> <insert id="insertSelective" parameterType="com.hengxin.qianee.model.DictBanking" > insert into t_dict_banking <trim prefix="(" suffix=")" suffixOverrides="," > <if test="id != null" > id, </if> <if test="name != null" > name, </if> <if test="images_path != null" > images_path, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="id != null" > #{id,jdbcType=INTEGER}, </if> <if test="name != null" > #{name,jdbcType=VARCHAR}, </if> <if test="images_path != null" > #{images_path,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.hengxin.qianee.model.DictBanking" > update t_dict_banking <set > <if test="name != null" > name = #{name,jdbcType=VARCHAR}, </if> <if test="images_path != null" > images_path = #{images_path,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <!-- 保存修改银行卡信息 --> <update id="updateByPrimaryKey" parameterType="com.hengxin.qianee.model.DictBanking" > update t_dict_banking set name = #{name,jdbcType=VARCHAR}, images_path = #{images_path,jdbcType=VARCHAR}, amount_day_limit = #{amount_day_limit,jdbcType=DECIMAL}, amount_single_limit = #{amount_single_limit,jdbcType=DECIMAL}, amount_month_limit = #{amount_month_limit,jdbcType=DECIMAL}, is_use = #{is_use,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} </update> <!-- 微信用:根据银行编码获得银行信息 --> <select id="selectByBankCode" resultMap="BaseResultMap" parameterType="string" > select <include refid="Base_Column_List" /> from t_dict_banking where bank_code = #{bankCode} and type = 2 and is_use = 1 </select> </mapper>
标签:
原文地址:http://www.cnblogs.com/weixiaole/p/5340895.html