105 lines
3.1 KiB
XML
105 lines
3.1 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.QuestionMapper">
|
|
<resultMap id="questionResult" type="Question">
|
|
<result property="id" column="id"/>
|
|
<result property="content" column="content"/>
|
|
<result property="courseId" column="courseId"/>
|
|
<result property="addDate" column="addDate"/>
|
|
<result property="type" column="type"/>
|
|
</resultMap>
|
|
|
|
<insert id="add" parameterType="Question">
|
|
insert into t_question (content, courseId, addDate, type, userId)
|
|
values (#{content}, #{courseId}, now(), #{type}, #{userId});
|
|
</insert>
|
|
|
|
<select id="findNew" resultType="com.ledao.entity.Question">
|
|
select *
|
|
from t_question
|
|
order by id desc
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="getAllQuestion" resultMap="questionResult">
|
|
select *
|
|
from t_question
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="list" parameterType="map" resultMap="questionResult">
|
|
select *
|
|
from t_question
|
|
<where>
|
|
<if test="content != null and content != ''">
|
|
and content like #{content}
|
|
</if>
|
|
<if test="courseId != null">
|
|
and courseId = #{courseId}
|
|
</if>
|
|
<if test="userId != null">
|
|
and userId = #{userId}
|
|
</if>
|
|
</where>
|
|
order by id desc
|
|
<if test="start != null and size != null">
|
|
limit #{start},#{size}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="findById" parameterType="integer" resultType="com.ledao.entity.Question">
|
|
select *
|
|
from t_question
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="getMyQuestion" parameterType="integer" resultMap="questionResult">
|
|
select *
|
|
from t_question
|
|
where userId = #{userId}
|
|
order by id desc
|
|
</select>
|
|
|
|
<delete id="deleteById" parameterType="integer">
|
|
delete
|
|
from t_question
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
<update id="update" parameterType="Question">
|
|
update t_question
|
|
<set>
|
|
<if test="content != null and content != ''">
|
|
content=#{content},
|
|
</if>
|
|
<if test="courseId != null">
|
|
courseId=#{courseId},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<select id="getCount" parameterType="map" resultType="java.lang.Long">
|
|
select count(*)
|
|
from t_question
|
|
<where>
|
|
<if test="content != null and content != ''">
|
|
and content like #{content}
|
|
</if>
|
|
<if test="courseId != null">
|
|
and courseId = #{courseId}
|
|
</if>
|
|
<if test="userId != null">
|
|
and userId = #{userId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getQuestionByCourseIdAndQuestionType" resultMap="questionResult">
|
|
select *
|
|
from t_question
|
|
where courseId = #{param1}
|
|
and type = #{param2}
|
|
</select>
|
|
</mapper> |