79 lines
2.5 KiB
XML
79 lines
2.5 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--suppress ALL-->
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.ledao.mapper.PaperMapper">
|
|
<resultMap id="paperResult" type="Paper">
|
|
<result property="id" column="id"/>
|
|
<result property="userId" column="userId"/>
|
|
<result property="userName" column="userName"/>
|
|
<result property="courseName" column="courseName"/>
|
|
<result property="createDate" column="createDate"/>
|
|
<result property="score" column="score"/>
|
|
</resultMap>
|
|
|
|
<insert id="add" parameterType="Paper">
|
|
insert into t_paper (userId, courseName, createDate, score, userName)
|
|
values (#{userId}, #{courseName}, now(), 0, #{userName});
|
|
</insert>
|
|
|
|
<select id="findByUserIdLastOne" parameterType="integer" resultType="com.ledao.entity.Paper">
|
|
select *
|
|
from t_paper
|
|
where userId = #{userId}
|
|
order by createDate desc
|
|
limit 1
|
|
</select>
|
|
|
|
<update id="update" parameterType="Paper">
|
|
update t_paper
|
|
<set>
|
|
<if test="score != null">
|
|
score=#{score},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<select id="getListFindByUserId" parameterType="integer" resultMap="paperResult">
|
|
select *
|
|
from t_paper
|
|
where userId = #{userId}
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="findById" parameterType="integer" resultType="com.ledao.entity.Paper">
|
|
select *
|
|
from t_paper
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="list" parameterType="map" resultMap="paperResult">
|
|
select *
|
|
from t_paper
|
|
<where>
|
|
<if test="userId != null">
|
|
and userId = #{userId}
|
|
</if>
|
|
<if test="userName != null and userName != ''">
|
|
and userName like #{userName}
|
|
</if>
|
|
</where>
|
|
order by id desc
|
|
<if test="start != null and size != null">
|
|
limit #{start},#{size}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getCount" parameterType="map" resultType="java.lang.Long">
|
|
select count(*)
|
|
from t_paper
|
|
<where>
|
|
<if test="userId != null">
|
|
and userId = #{userId}
|
|
</if>
|
|
<if test="userName != null and userName != ''">
|
|
and userName like #{userName}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
</mapper> |