ScoreInfoMapper.xml 4.85 KB
Newer Older
licc's avatar
licc committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?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="cn.wisenergy.mapper.ScoreInfoMapper">
    <resultMap id="userMap" type="cn.wisenergy.model.app.ScoreInfo">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="culture_grade" property="cultureGrade"/>
        <result column="major_grade" property="majorGrade"/>
        <result column="language_grade" property="languageGrade"/>
        <result column="math_grade" property="mathGrade"/>
        <result column="english_grade" property="englishGrade"/>
        <result column="physics_grade" property="physicsGrade"/>
        <result column="chemistry_grade" property="chemistryGrade"/>
        <result column="biology_grade" property="biologyGrade"/>
        <result column="history_grade" property="historyGrade"/>
        <result column="geography_grade" property="geographyGrade"/>
        <result column="politics_grade" property="politicsGrade"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="table">
licc's avatar
licc committed
24
        score
licc's avatar
licc committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
        user_id,culture_grade, major_grade,language_grade,math_grade,english_grade, physics_grade,chemistry_grade,
        biology_grade,history_grade,geography_grade,politics_grade, create_time,update_time
    </sql>

    <sql id="vals">
        #{userId},#{cultureGrade},#{majorGrade},#{languageGrade},#{mathGrade},#{englishGrade},#{physicsGrade},
        #{chemistryGrade},#{biologyGrade}, #{historyGrade},#{geographyGrade},#{politicsGrade},now(),now()
    </sql>

    <sql id="updateCondition">
        <if test="userId != null">user_id = #{userId},</if>
        <if test="cultureGrade != null">culture_grade =#{cultureGrade},</if>
        <if test="majorGrade != null">major_grade =#{majorGrade},</if>
        <if test="languageGrade != null">language_grade =#{languageGrade},</if>
        <if test="mathGrade != null">math_grade =#{mathGrade},</if>
        <if test="englishGrade != null">english_grade =#{englishGrade},</if>
        <if test="physicsGrade != null">physics_grade = #{physicsGrade},</if>
        <if test="chemistryGrade != null">chemistry_grade = #{chemistryGrade},</if>
        <if test="biologyGrade != null">biology_grade = #{biologyGrade},</if>
        <if test="historyGrade != null">history_grade = #{historyGrade},</if>
        <if test="geographyGrade != null">geography_grade = #{geographyGrade},</if>
        <if test="politicsGrade != null">politics_grade = #{politicsGrade},</if>
        update_time =now()
    </sql>

    <sql id="criteria">
        <if test="id != null">id = #{id}</if>
        <if test="userId != null">and user_id = #{userId}</if>
        <if test="cultureGrade != null">and culture_grade =#{cultureGrade}</if>
        <if test="majorGrade != null">and major_grade =#{majorGrade}</if>
        <if test="languageGrade != null">and language_grade =#{languageGrade}</if>
        <if test="mathGrade != null">and math_grade =#{mathGrade}</if>
        <if test="englishGrade != null">and english_grade =#{englishGrade}</if>
        <if test="physicsGrade != null">and physics_grade = #{physicsGrade}</if>
        <if test="chemistryGrade != null">and chemistry_grade = #{chemistryGrade}</if>
        <if test="biologyGrade != null">and biology_grade = #{biologyGrade}</if>
        <if test="historyGrade != null">and history_grade = #{historyGrade}</if>
        <if test="geographyGrade != null">and geography_grade = #{geographyGrade}</if>
        <if test="politicsGrade != null">and politics_grade = #{politicsGrade}</if>
        <if test="createTime != null">and create_time &gt;= #{createTime}</if>
        <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
    </sql>

    <insert id="add" parameterType="cn.wisenergy.model.app.ScoreInfo" keyProperty="id" useGeneratedKeys="true">
        insert into
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        value(
        <include refid="vals"/>
        )
    </insert>

    <update id="edit" parameterType="cn.wisenergy.model.app.ScoreInfo">
        UPDATE
        <include refid="table"/>
        <set>
            <include refid="updateCondition"/>
        </set>
        <where>
            id = #{id}
        </where>
    </update>

    <delete id="delById" parameterType="java.lang.Integer">
        delete from
        <include refid="table"/>
        where id = #{id}
    </delete>

liaoanyuan's avatar
liaoanyuan committed
102
    <select id="getById" resultMap="userMap">
licc's avatar
licc committed
103 104 105 106
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
liaoanyuan's avatar
liaoanyuan committed
107 108 109 110
        <where>
            user_id=#{userId}
        </where>
    </select>
licc's avatar
licc committed
111
</mapper>