| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?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.ym.mec.biz.dal.dao.StudentCompetitionDao">
- <resultMap type="com.ym.mec.biz.dal.entity.StudentCompetition" id="StudentCompetition">
- <result column="id_" property="id" />
- <result column="user_id_" property="userId" />
- <result column="username_" property="username" />
- <result column="id_card_no_" property="idCardNo" />
- <result column="age_" property="age" />
- <result column="gender_" property="gender" />
- <result column="grade_" property="grade" />
- <result column="subject_" property="subject" />
- <result column="chapter_" property="chapter" />
- <result column="picture_url_" property="pictureUrl" />
- <result column="video_url_" property="videoUrl" />
- <result column="score_" property="score" />
- <result column="prize_level_" property="prizeLevel" />
- <result column="is_show_" property="isShow" />
- <result column="comment_" property="comment" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="StudentCompetition" >
- SELECT * FROM student_competition WHERE id_ = #{id}
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="StudentCompetition">
- SELECT * FROM student_competition ORDER BY id_
- </select>
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCompetition" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- <!--
- <selectKey resultClass="int" keyProperty="id" >
- SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
- </selectKey>
- -->
- INSERT INTO student_competition (id_,user_id_,username_,id_card_no_,age_,gender_,grade_,subject_,chapter_,picture_url_,video_url_,score_,prize_level_,is_show_,comment_,create_time_,update_time_)
- VALUES(#{id},#{userId},#{username},#{idCardNo},#{age},#{gender},#{grade},#{subject},#{chapter},#{pictureUrl},#{videoUrl},#{score},#{prizeLevel},#{isShow},#{comment},NOW(),NOW())
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCompetition">
- UPDATE student_competition <set>
- <if test="isShow != null">
- is_show_ = #{isShow},
- </if>
- <if test="id != null">
- id_ = #{id},
- </if>
- <if test="gender != null">
- gender_ = #{gender},
- </if>
- <if test="score != null">
- score_ = #{score},
- </if>
- <if test="prizeLevel != null">
- prize_level_ = #{prizeLevel},
- </if>
- <if test="age != null">
- age_ = #{age},
- </if>
- <if test="videoUrl != null">
- video_url_ = #{videoUrl},
- </if>
- <if test="username != null">
- username_ = #{username},
- </if>
- <if test="chapter != null">
- chapter_ = #{chapter},
- </if>
- <if test="userId != null">
- user_id_ = #{userId},
- </if>
- <if test="subject != null">
- subject_ = #{subject},
- </if>
- <if test="comment != null">
- comment_ = #{comment},
- </if>
- <if test="pictureUrl != null">
- picture_url_ = #{pictureUrl},
- </if>
- <if test="idCardNo != null">
- id_card_no_ = #{idCardNo},
- </if>
- <if test="grade != null">
- grade_ = #{grade},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{id}
- </update>
-
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM student_competition WHERE id_ = #{id}
- </delete>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="StudentCompetition" parameterType="map">
- SELECT * FROM student_competition ORDER BY id_ <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM student_competition
- </select>
- <sql id="queryStudentCondition">
- <where>
- <if test="grade!=null">
- AND grade_=#{grade}
- </if>
- <if test="gender!=null">
- AND gender_=#{gender}
- </if>
- <if test="subject != null and subject != ''">
- AND subject_=#{subject}
- </if>
- <if test="prizeLevel!=null">
- AND prize_level_=#{prizeLevel}
- </if>
- <if test="isShow!=null">
- AND is_show_=#{isShow}
- </if>
- <if test="isReview!=null and isReview==0">
- AND score_ IS NULL
- </if>
- <if test="isReview!=null and isReview==1">
- AND score_ IS NOT NULL
- </if>
- <if test="search!=null and search!=''">
- AND (CAST(age_ AS CHAR)=#{search} OR CAST(user_id_ AS CHAR)=#{search} OR username_ LIKE CONCAT('%', #{search}, '%') OR id_card_no_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </where>
- </sql>
- <select id="queryStudentCompetitions" resultMap="StudentCompetition">
- SELECT
- id_,
- user_id_,
- username_,
- id_card_no_,
- age_,
- gender_,
- grade_,
- subject_,
- chapter_,
- picture_url_,
- video_url_,
- CASE WHEN score_ IS NULL THEN -1 ELSE score_ END score_,
- CASE WHEN prize_level_ IS NULL THEN -1 ELSE prize_level_ END prize_level_,
- is_show_,
- comment_,
- create_time_,
- update_time_
- FROM student_competition
- <include refid="queryStudentCondition"/>
- ORDER BY id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countStudentCompetitions" resultType="int">
- SELECT COUNT(*) FROM student_competition
- <include refid="queryStudentCondition"/>
- </select>
- <select id="getWinnerList" resultMap="StudentCompetition">
- SELECT * FROM student_competition WHERE is_show_ = 1
- ORDER BY ISNULL(score_),score_ DESC
- </select>
- <select id="getCompetitionWithUser" resultMap="StudentCompetition">
- SELECT * FROM student_competition WHERE user_id_ = #{userId}
- </select>
- <select id="getCompetitionsWithPrizeLevel" resultType="long">
- SELECT id_ FROM student_competition WHERE prize_level_ = #{prizeLevel} FOR UPDATE
- </select>
- </mapper>
|