mybatis 一对一 一对多 多对一 多对多

xiaoxiao2021-02-27  297

<?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.superr.powerful.progect.user.dao.FornowUserInfoMapper" >   <resultMap id="BaseResultMap" type="com.superr.powerful.progect.user.entity.FornowUserInfo" >     <id column="fnuser_id" property="fnuserId" jdbcType="BIGINT" />     <result column="createDateTime" property="createdatetime" jdbcType="TIMESTAMP" />     <result column="lastModifyDateTime" property="lastmodifydatetime" jdbcType="TIMESTAMP" />     <result column="nickname" property="nickname" jdbcType="VARCHAR" />     <result column="position" property="position" jdbcType="VARCHAR" />     <result column="sex" property="sex" jdbcType="INTEGER" />     <result column="status" property="status" jdbcType="INTEGER" />     <result column="user_id" property="userId" jdbcType="BIGINT" />     <result column="parent_id" property="parentId" jdbcType="BIGINT" />     <result column="type" property="type" jdbcType="INTEGER" />     <result column="is_parent" property="isParent" jdbcType="INTEGER" />     <result column="userNum" property="usernum" jdbcType="VARCHAR" />     <result column="createDate" property="createdate" jdbcType="BIGINT" />     <result column="lastModifyDate" property="lastmodifydate" jdbcType="BIGINT" />     <result column="version" property="version" jdbcType="INTEGER" />          < association property="user" javaType="com.superr.powerful.progect.user.entity.User">              <!-- id:关联查询用户的唯一标识                   column:指定唯一标识用户信息的列                  property:映射到user的那个属性              -->               <!--  private User user; -->              <id column="user_id" property="userId"/>             <result column="createDateTime" property="createdatetime" jdbcType="TIMESTAMP" />    <result column="lastModifyDateTime" property="lastmodifydatetime" jdbcType="TIMESTAMP" />    <result column="email" property="email" jdbcType="VARCHAR" />    <result column="password" property="password" jdbcType="VARCHAR" />    <result column="phone" property="phone" jdbcType="VARCHAR" />    <result column="type" property="type" jdbcType="INTEGER" />    <result column="username" property="username" jdbcType="VARCHAR" />    <result column="validDateTime" property="validdatetime" jdbcType="TIMESTAMP" />    <result column="email_kf" property="emailKf" jdbcType="VARCHAR" />    <result column="createDate" property="createdate" jdbcType="BIGINT" />    <result column="lastModifyDate" property="lastmodifydate" jdbcType="BIGINT" />    <result column="point" property="point" jdbcType="INTEGER" />    <result column="status" property="status" jdbcType="INTEGER" />    <result column="roles" property="roles" jdbcType="VARCHAR" />    <result column="company_id" property="companyId" jdbcType="BIGINT" />    <result column="dept_id" property="deptId" jdbcType="BIGINT" />    <result column="birthday_time" property="birthdayTime" jdbcType="VARCHAR" />    <result column="sex" property="sex" jdbcType="INTEGER" />    <result column="balance" property="balance" jdbcType="DECIMAL" />    <result column="ease_name" property="easeName" jdbcType="VARCHAR" />    <result column="ease_password" property="easePassword" jdbcType="VARCHAR" />    <result column="age" property="age" jdbcType="INTEGER" />    <result column="version" property="version" jdbcType="INTEGER" />    <result column="isfirst" property="isfirst" jdbcType="INTEGER" />          </association>          <association property="parentUser" javaType="com.superr.powerful.progect.user.entity.FornowUserInfo">                <id column="fnuser_id" property="fnuserId" jdbcType="BIGINT" />    <result column="createDateTime" property="createdatetime" jdbcType="TIMESTAMP" />    <result column="lastModifyDateTime" property="lastmodifydatetime" jdbcType="TIMESTAMP" />    <result column="nickname" property="nickname" jdbcType="VARCHAR" />    <result column="position" property="position" jdbcType="VARCHAR" />    <result column="sex" property="sex" jdbcType="INTEGER" />    <result column="status" property="status" jdbcType="INTEGER" />    <result column="user_id" property="userId" jdbcType="BIGINT" />    <result column="parent_id" property="parentId" jdbcType="BIGINT" />    <result column="type" property="type" jdbcType="INTEGER" />    <result column="is_parent" property="isParent" jdbcType="INTEGER" />    <result column="userNum" property="usernum" jdbcType="VARCHAR" />    <result column="createDate" property="createdate" jdbcType="BIGINT" />    <result column="lastModifyDate" property="lastmodifydate" jdbcType="BIGINT" />    <result column="version" property="version" jdbcType="INTEGER" />          </association>   </resultMap>      <!-- private List<OrderDetail> orderdetails; -->   <!--     < collection property="orderdetails" ofType="com.mybatis.entity.OrderDetail"> id:唯一标识 property:要将订单明细的唯一标识映射到com.mybatis.entity.OrderDetail的那个属性   <id column="orderdetail_id" property="id"/> <result column="items_id" property="itemsId"/> <result column="items_num" property="itemsNum"/> <result column="orders_id" property="ordersId"/> </collection> -->   <sql id="Base_Column_List" >     fnuser_id, createDateTime, lastModifyDateTime, nickname, position, sex, status, user_id,      parent_id, type, is_parent, userNum, createDate, lastModifyDate, version   </sql>    <sql id="User_Column_List" >     user_id, createDateTime, lastModifyDateTime, email, password, phone, type, username,      validDateTime, email_kf, createDate, lastModifyDate, point, status, roles, company_id,      dept_id, birthday_time, sex, balance, ease_name, ease_password, age, version, isfirst   </sql>   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >     select      <include refid="Base_Column_List" />,     <include refid="User_Column_List"/>     from fornow_fnuser f inner join fornow_user u     on f.user_id=u.user_id      where fnuser_id = #{fnuserId,jdbcType=BIGINT}   </select>   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >     delete from fornow_fnuser     where fnuser_id = #{fnuserId,jdbcType=BIGINT}   </delete>   <insert id="insert" parameterType="com.superr.powerful.progect.user.entity.FornowUserInfo" >     insert into fornow_fnuser (fnuser_id, createDateTime, lastModifyDateTime,        nickname, position, sex,        status, user_id, parent_id,        type, is_parent, userNum,        createDate, lastModifyDate, version       )     values (#{fnuserId,jdbcType=BIGINT}, #{createdatetime,jdbcType=TIMESTAMP}, #{lastmodifydatetime,jdbcType=TIMESTAMP},        #{nickname,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER},        #{status,jdbcType=INTEGER}, #{userId,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT},        #{type,jdbcType=INTEGER}, #{isParent,jdbcType=INTEGER}, #{usernum,jdbcType=VARCHAR},        #{createdate,jdbcType=BIGINT}, #{lastmodifydate,jdbcType=BIGINT}, #{version,jdbcType=INTEGER}       )   </insert>   <insert id="insertSelective" parameterType="com.superr.powerful.progect.user.entity.FornowUserInfo" >     insert into fornow_fnuser     <trim prefix="(" suffix=")" suffixOverrides="," >       <if test="fnuserId != null" >         fnuser_id,       </if>       <if test="createdatetime != null" >         createDateTime,       </if>       <if test="lastmodifydatetime != null" >         lastModifyDateTime,       </if>       <if test="nickname != null" >         nickname,       </if>       <if test="position != null" >         position,       </if>       <if test="sex != null" >         sex,       </if>       <if test="status != null" >         status,       </if>       <if test="userId != null" >         user_id,       </if>       <if test="parentId != null" >         parent_id,       </if>       <if test="type != null" >         type,       </if>       <if test="isParent != null" >         is_parent,       </if>       <if test="usernum != null" >         userNum,       </if>       <if test="createdate != null" >         createDate,       </if>       <if test="lastmodifydate != null" >         lastModifyDate,       </if>       <if test="version != null" >         version,       </if>     </trim>     <trim prefix="values (" suffix=")" suffixOverrides="," >       <if test="fnuserId != null" >         #{fnuserId,jdbcType=BIGINT},       </if>       <if test="createdatetime != null" >         #{createdatetime,jdbcType=TIMESTAMP},       </if>       <if test="lastmodifydatetime != null" >         #{lastmodifydatetime,jdbcType=TIMESTAMP},       </if>       <if test="nickname != null" >         #{nickname,jdbcType=VARCHAR},       </if>       <if test="position != null" >         #{position,jdbcType=VARCHAR},       </if>       <if test="sex != null" >         #{sex,jdbcType=INTEGER},       </if>       <if test="status != null" >         #{status,jdbcType=INTEGER},       </if>       <if test="userId != null" >         #{userId,jdbcType=BIGINT},       </if>       <if test="parentId != null" >         #{parentId,jdbcType=BIGINT},       </if>       <if test="type != null" >         #{type,jdbcType=INTEGER},       </if>       <if test="isParent != null" >         #{isParent,jdbcType=INTEGER},       </if>       <if test="usernum != null" >         #{usernum,jdbcType=VARCHAR},       </if>       <if test="createdate != null" >         #{createdate,jdbcType=BIGINT},       </if>       <if test="lastmodifydate != null" >         #{lastmodifydate,jdbcType=BIGINT},       </if>       <if test="version != null" >         #{version,jdbcType=INTEGER},       </if>     </trim>   </insert>   <update id="updateByPrimaryKeySelective" parameterType="com.superr.powerful.progect.user.entity.FornowUserInfo" >     update fornow_fnuser     <set >       <if test="createdatetime != null" >         createDateTime = #{createdatetime,jdbcType=TIMESTAMP},       </if>       <if test="lastmodifydatetime != null" >         lastModifyDateTime = #{lastmodifydatetime,jdbcType=TIMESTAMP},       </if>       <if test="nickname != null" >         nickname = #{nickname,jdbcType=VARCHAR},       </if>       <if test="position != null" >         position = #{position,jdbcType=VARCHAR},       </if>       <if test="sex != null" >         sex = #{sex,jdbcType=INTEGER},       </if>       <if test="status != null" >         status = #{status,jdbcType=INTEGER},       </if>       <if test="userId != null" >         user_id = #{userId,jdbcType=BIGINT},       </if>       <if test="parentId != null" >         parent_id = #{parentId,jdbcType=BIGINT},       </if>       <if test="type != null" >         type = #{type,jdbcType=INTEGER},       </if>       <if test="isParent != null" >         is_parent = #{isParent,jdbcType=INTEGER},       </if>       <if test="usernum != null" >         userNum = #{usernum,jdbcType=VARCHAR},       </if>       <if test="createdate != null" >         createDate = #{createdate,jdbcType=BIGINT},       </if>       <if test="lastmodifydate != null" >         lastModifyDate = #{lastmodifydate,jdbcType=BIGINT},       </if>       <if test="version != null" >         version = #{version,jdbcType=INTEGER},       </if>     </set>     where fnuser_id = #{fnuserId,jdbcType=BIGINT}   </update>   <update id="updateByPrimaryKey" parameterType="com.superr.powerful.progect.user.entity.FornowUserInfo" >     update fornow_fnuser     set createDateTime = #{createdatetime,jdbcType=TIMESTAMP},       lastModifyDateTime = #{lastmodifydatetime,jdbcType=TIMESTAMP},       nickname = #{nickname,jdbcType=VARCHAR},       position = #{position,jdbcType=VARCHAR},       sex = #{sex,jdbcType=INTEGER},       status = #{status,jdbcType=INTEGER},       user_id = #{userId,jdbcType=BIGINT},       parent_id = #{parentId,jdbcType=BIGINT},       type = #{type,jdbcType=INTEGER},       is_parent = #{isParent,jdbcType=INTEGER},       userNum = #{usernum,jdbcType=VARCHAR},       createDate = #{createdate,jdbcType=BIGINT},       lastModifyDate = #{lastmodifydate,jdbcType=BIGINT},       version = #{version,jdbcType=INTEGER}     where fnuser_id = #{fnuserId,jdbcType=BIGINT}   </update> </mapper>
转载请注明原文地址: https://www.6miu.com/read-4317.html

最新回复(0)