MISBoot快速开发平台

Mapper实现XML

一、通过自动生成代码功能生成代码

把生成出来的Mapper.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="cn.ewsd.mdama.mapper.SysUserMapper">

        <!-- 可根据自己的需求,是否要使用 -->
        <resultMap type="cn.ewsd.mdama.model.SysUser" id="sysUserMap">
            <result property="uuid" column="uuid"/>
            <result property="create_time" column="create_time"/>
            <result property="creator" column="creator"/>
            <result property="creator_id" column="creator_id"/>
            <result property="is_del" column="is_del"/>
            <result property="modifier" column="modifier"/>
            <result property="modifier_id" column="modifier_id"/>
            <result property="modify_time" column="modify_time"/>
            <result property="creator_org_id" column="creator_org_id"/>
            <result property="remark" column="remark"/>
            <result property="org_id" column="org_id"/>
            <result property="org_name" column="org_name"/>
            <result property="user_account" column="user_account"/>
            <result property="user_group" column="user_group"/>
            <result property="data_auth" column="data_auth"/>
            <result property="user_name" column="user_name"/>
            <result property="user_name_id" column="user_name_id"/>
            <result property="password" column="password"/>
            <result property="age" column="age"/>
            <result property="sex" column="sex"/>
            <result property="status" column="status"/>

        </resultMap>

      <sql id="Base_Column_List" >
                             uuid
              ,                          create_time
              ,                          creator
              ,                          creator_id
              ,                          is_del
              ,                          modifier
              ,                          modifier_id
              ,                          modify_time
              ,                          creator_org_id
              ,                          remark
              ,                          org_id
              ,                          org_name
              ,                          post
              ,                          school
              ,                          user_account
              ,                          user_group
              ,                          data_auth
              ,                          user_name
              ,                          user_name_id
              ,                          password
              ,                          id_card_no
              ,                          age
              ,                          id_card
              ,                          sex
              ,                          status
                      </sql>

        <select id="getPageSet" resultType="cn.ewsd.mdama.model.SysUser">
            select
            <include refid="Base_Column_List"></include>
            from sys_user
            <where>
                <if test="filterSort != null">
                    ${filterSort}
                </if>
            </where>
        </select>

        <select id="queryObject" resultType="cn.ewsd.mdama.model.SysUser">
            select  <include refid="Base_Column_List" />  from sys_user where uuid = #{value}
        </select>

        <select id="queryList" resultType="cn.ewsd.mdama.model.SysUser">
            select  <include refid="Base_Column_List" />  from sys_user
            <choose>
                <when test="sidx != null and sidx.trim() != ''">
                    order by ${sidx} ${order}
                </when>
                <otherwise>
                    order by uuid desc
                </otherwise>
            </choose>
            <if test="offset != null and limit != null">
                limit #{offset}, #{limit}
            </if>
        </select>

        <select id="queryTotal" resultType="int">
            select count(*) from sys_user
        </select>

        <insert id="executeSave" parameterType="cn.ewsd.mdama.model.SysUser">
            insert into sys_user
            (
                `uuid`,
                `create_time`,
                `creator`,
                `creator_id`,
                `is_del`,
                `modifier`,
                `modifier_id`,
                `modify_time`,
                `creator_org_id`,
                `remark`,
                `org_id`,
                `org_name`,
                `user_account`,
                `user_group`,
                `data_auth`,
                `user_name`,
                `user_name_id`,
                `password`,
                `id_card_no`,
                `age`,
                `id_card`,
                `sex`,
                `status`
            )
            values
            (
                #{uuid},
                #{create_time},
                #{creator},
                #{creator_id},
                #{is_del},
                #{modifier},
                #{modifier_id},
                #{modify_time},
                #{creator_org_id},
                #{remark},
                #{org_id},
                #{org_name},
                #{user_account},
                #{user_group},
                #{data_auth},
                #{user_name},
                #{user_name_id},
                #{password},
                #{id_card_no},
                #{age},
                #{id_card},
                #{sex},
                #{status},

            )
        </insert>

        <update id="executeUpdate" parameterType="cn.ewsd.mdama.model.SysUser">
            update sys_user
            <set>
                <if test="create_time != null">`create_time` = #{create_time}, </if>
                <if test="creator != null">`creator` = #{creator}, </if>
                <if test="creator_id != null">`creator_id` = #{creator_id}, </if>
                <if test="is_del != null">`is_del` = #{is_del}, </if>
                <if test="modifier != null">`modifier` = #{modifier}, </if>
                <if test="modifier_id != null">`modifier_id` = #{modifier_id}, </if>
                <if test="modify_time != null">`modify_time` = #{modify_time}, </if>
                <if test="creator_org_id != null">`creator_org_id` = #{creator_org_id}, </if>
                <if test="remark != null">`remark` = #{remark}, </if>
                <if test="org_id != null">`org_id` = #{org_id}, </if>
                <if test="org_name != null">`org_name` = #{org_name}, </if>
                <if test="post != null">`post` = #{post}, </if>
                <if test="school != null">`school` = #{school}, </if>
                <if test="user_account != null">`user_account` = #{user_account}, </if>
                <if test="user_group != null">`user_group` = #{user_group}, </if>
                <if test="data_auth != null">`data_auth` = #{data_auth}, </if>
                <if test="user_name != null">`user_name` = #{user_name}, </if>
                <if test="user_name_id != null">`user_name_id` = #{user_name_id}, </if>
                <if test="password != null">`password` = #{password}, </if>
                <if test="id_card_no != null">`id_card_no` = #{id_card_no}, </if>
                <if test="age != null">`age` = #{age}, </if>
                <if test="id_card != null">`id_card` = #{id_card}, </if>
                <if test="sex != null">`sex` = #{sex}, </if>
                <if test="status != null">`status` = #{status}</if>
            </set>
            where uuid = #{uuid}
        </update>

        <delete id="executeDelete">
            delete from sys_user where uuid = #{value}
        </delete>

        <delete id="executeDeleteBatch">
            delete from sys_user where uuid in
            <foreach item="uuid" collection="array" open="(" separator="," close=")">
                #{uuid}
            </foreach>
        </delete>

    </mapper>
QQ在线咨询
客服 QQ
251122361
微信/手机
18973127736
办公电话
0731-89565588