mybatis Xml模板

<?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.thinkgem.jeesite.modules.user.dao.UserUserinfoBankDao">

    <sql id="userUserinfoBankColumns">
      a.id AS "id",
      a.user_name AS "userName",
      a.bank_name AS "bankName",
      a.bank_user_num AS "bankUserNum",
      a.bank_user_name AS "bankUserName",
      a.bank_user_address AS "bankUserAddress",
      a.bank_code AS "bankCode",
      a.provinces AS "provinces",
      a.citys AS "citys",
      a.area AS "area",
      a.create_by AS "createBy.id",
      a.create_date AS "createDate",
      a.update_by AS "updateBy.id",
      a.update_date AS "updateDate",
      a.remarks AS "remarks",
      a.del_flag AS "delFlag"
   </sql>

    <sql id="userUserinfoBankJoins">
    </sql>

    <select id="get" resultType="UserUserinfoBank">
        SELECT
        <include refid="userUserinfoBankColumns"/>
        FROM user_userinfo_bank a
        <include refid="userUserinfoBankJoins"/>
        WHERE a.id = #{id}
    </select>

    <select id="getByBankUserNum" resultType="UserUserinfoBank">
        SELECT
        <include refid="userUserinfoBankColumns"/>
        FROM user_userinfo_bank a
        <include refid="userUserinfoBankJoins"/>
        WHERE a.bank_user_num = #{bankUserNum}
        AND a.user_name = #{userName}
    </select>

    <select id="getByUserName" resultType="UserUserinfoBank">
        SELECT
        <include refid="userUserinfoBankColumns"/>
        FROM user_userinfo_bank a
        <include refid="userUserinfoBankJoins"/>
        WHERE a.user_name = #{userName}
        limit 1
    </select>

    <select id="findList" resultType="UserUserinfoBank">
        SELECT

        <include refid="userUserinfoBankColumns"/>
        FROM user_userinfo_bank a
        <include refid="userUserinfoBankJoins"/>
        <where>
            a.del_flag = #{DEL_FLAG_NORMAL}
            <if test="id != null and id != ''">
                AND a.id = #{id}
            </if>
            <if test="userName != null and userName != ''">
                AND a.user_name = #{userName}
            </if>
            <if test="bankUserNum != null and bankUserNum != ''">
                AND a.bank_user_num = #{bankUserNum}
            </if>
        </where>
        <choose>
            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                ORDER BY ${page.orderBy}
            </when>
            <when test="orderBy !=null and orderBy != ''">
                ORDER BY ${orderBy}
            </when>
            <otherwise>
                ORDER BY a.id DESC
            </otherwise>
        </choose>
        <if test="topLimit != null and topLimit != '' ">
            limit 0,#{topLimit}
        </if>
    </select>
    <update id="byBankIdUpdateBankInfo">
      UPDATE user_userinfo_bank SET
         bank_name = #{bankName},
         bank_user_num = #{bankUserNum},
         bank_user_address = #{bankUserAddress},
         bank_code = #{bankCode}
      WHERE id = #{id}
   </update>

    <insert id="insert">
      INSERT INTO user_userinfo_bank(
         id,
         user_name,
         bank_name,
         bank_user_num,
         bank_user_name,
         provinces,
         citys,
         area,
         bank_user_address,
         bank_code,
         create_by,
         create_date,
         update_by,
         update_date,
         remarks,
         del_flag
      ) VALUES (
         #{id},
         #{userName},
         #{bankName},
         #{bankUserNum},
         #{bankUserName},
         #{provinces},
         #{citys},
         #{area},
         #{bankUserAddress},
         #{bankCode},
         #{createBy.id},
         #{createDate},
         #{updateBy.id},
         #{updateDate},
         #{remarks},
         #{delFlag}
      )
   </insert>

    <update id="update">
      UPDATE user_userinfo_bank SET  
         user_name = #{userName},
         bank_name = #{bankName},
         bank_user_num = #{bankUserNum},
         bank_user_name = #{bankUserName},
         provinces = #{provinces},
         citys = #{citys},
         area = #{area},
         bank_user_address = #{bankUserAddress},
         bank_code = #{bankCode},
         update_by = #{updateBy.id},
         update_date = #{updateDate},
         remarks = #{remarks}
      WHERE id = #{id}
   </update>

    <update id="delete">
      delete from  user_userinfo_bank
      WHERE id = #{id}
   </update>

</mapper>

猜你喜欢

转载自blog.csdn.net/zn65786412qq/article/details/81432962