miaosha/target/classes/mybatis/mapper/UserMapper.xml
2018-09-27 22:23:19 +08:00

75 lines
2.8 KiB
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.geekq.miaosha.dao.UserMapper">
<!--结果集映射-->
<resultMap id="BaseResultMap" type="com.geekq.miaosha.domain.MiaoshaUser">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
<result column="salt" property="salt" jdbcType="VARCHAR"/>
<result column="head" property="head" jdbcType="VARCHAR"/>
<result column="register_date" property="registerDate" jdbcType="TIMESTAMP"/>
<result column="last_login_date" property="lastLoginDate" jdbcType="TIMESTAMP"/>
<result column="login_Count" property="loginCount" jdbcType="INTEGER"/>
</resultMap>
<!--增加一条数据-->
<insert id="insertMiaoShaUser" parameterType="com.geekq.miaosha.domain.MiaoshaUser" keyProperty="id">
insert into miaosha_user (id, nickname, salt, register_date,last_login_date,login_Count ) values
(#{id,jdbcType=BIGINT},#{nickname,jdbcType=VARCHAR},
#{salt,jdbcType=VARCHAR},#{registerDate,jdbcType=DATE},#{lastLoginDate,jdbcType=DATE},
#{loginCount,jdbcType=INTEGER}
)
</insert>
<!--批量插入-->
<insert id="insertMiaoShaUserValues" useGeneratedKeys="true"
keyProperty="id">
insert into miaosha_user (id, nickname, salt, register_date,last_login_date,login_Count ) values
<foreach item="item" collection="list" separator=",">
(#{item.id,jdbcType=BIGINT},#{item.nickname,jdbcType=VARCHAR},
#{item.salt,jdbcType=VARCHAR},#{item.registerDate,jdbcType=DATE},#{item.lastLoginDate,jdbcType=DATE},
#{item.loginCount,jdbcType=INTEGER}
)
</foreach>
</insert>
<!--更新一条数据-->
<update id="updateMiaoShaUser" >
update miaosha_user set nickname = #{nickname},
login_Count = #{loginCount}
where id=#{id}
</update>
<!--删除一条数据-->
<delete id="deleteMiaoShaUser" parameterType="Long">
delete from miaosha_user
where id = #{id,jdbcType=BIGINT}
</delete>
<sql id="Base_Column_List"> id, nickname, salt, register_date,last_login_date,login_Count </sql>
<select id="getMiaoShaUserById" parameterType="LONG" resultType="miaoshauser">
SELECT
<include refid="Base_Column_List"/>
FROM miaosha_user WHERE id = #{id}
</select>
<select id="getMiaoShaUserNum" resultType="int">
select count(*) from miaosha_user
</select>
<select id="countbyMenuId" parameterType="java.lang.Integer"
resultType="java.lang.Integer"> select count(*) from miaosha_user
</select>
</mapper>