VolunteerMapper.xml 6.56 KB
Newer Older
licc's avatar
licc committed
1 2 3 4 5 6
<?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.VolunteerMapper">
    <resultMap id="userMap" type="cn.wisenergy.model.app.Volunteer">
        <id column="id" property="id"/>
licc's avatar
licc committed
7
        <result column="type" property="type"/>
licc's avatar
licc committed
8
        <result column="scheme_id" property="schemeId"/>
licc's avatar
licc committed
9 10 11 12 13 14
        <result column="major_name" property="majorName"/>
        <result column="academy" property="academy"/>
        <result column="course_demand" property="courseDemand"/>
        <result column="nature" property="nature"/>
        <result column="year_limit" property="yearLimit"/>
        <result column="plan_num" property="planNum"/>
licc's avatar
licc committed
15
        <result column="cast_archives_num" property="castArchivesNum"/>
licc's avatar
licc committed
16 17 18
        <result column="launch_num" property="launchNum"/>
        <result column="lowest_mark" property="lowestMark"/>
        <result column="lowest_rank" property="lowestRank"/>
licc's avatar
licc committed
19
        <result column="is_delete" property="isDelete"/>
licc's avatar
licc committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="table">
        volunteer
    </sql>

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

    <sql id="cols_exclude_id">
licc's avatar
licc committed
34
        type,scheme_id,major_name,academy, course_demand,nature,year_limit,plan_num,
licc's avatar
licc committed
35
        cast_archives_num,launch_num,lowest_mark,
licc's avatar
licc committed
36
        lowest_rank,is_delete,create_time,update_time
licc's avatar
licc committed
37 38 39
    </sql>

    <sql id="vals">
licc's avatar
licc committed
40
        #{type},#{scheme},#{majorName},#{academy},#{courseDemand},#{nature},#{yearLimit},#{planNum},#{castArchivesNum},
licc's avatar
licc committed
41 42
        #{launchNum},
        #{lowestMark}, #{lowestRank},#{isDelete},now(),now()
licc's avatar
licc committed
43 44 45
    </sql>

    <sql id="updateCondition">
licc's avatar
licc committed
46
        <if test="type != null">type = #{type},</if>
licc's avatar
licc committed
47
        <if test="scheme != null">scheme = #{scheme},</if>
licc's avatar
licc committed
48 49 50 51 52 53
        <if test="majorName != null">major_name = #{majorName},</if>
        <if test="academy != null">academy =#{academy},</if>
        <if test="courseDemand != null">course_demand =#{courseDemand},</if>
        <if test="nature != null">nature =#{nature},</if>
        <if test="yearLimit != null">year_limit =#{yearLimit},</if>
        <if test="planNum != null">plan_num =#{planNum},</if>
licc's avatar
licc committed
54
        <if test="castArchivesNum != null">cast_archives_num = #{castArchivesNum},</if>
licc's avatar
licc committed
55 56 57
        <if test="launchNum != null">launch_num = #{launchNum},</if>
        <if test="lowestMark != null">lowest_mark = #{lowestMark},</if>
        <if test="lowestRank != null">lowestMark = #{lowestRank},</if>
licc's avatar
licc committed
58
        <if test="isDelete != null">is_delete = #{isDelete},</if>
licc's avatar
licc committed
59 60 61 62 63
        update_time =now()
    </sql>

    <sql id="criteria">
        <if test="id != null">id = #{id}</if>
licc's avatar
licc committed
64
        <if test="type != null">and type = #{type}</if>
licc's avatar
licc committed
65
        <if test="scheme != null">and scheme = #{scheme}</if>
licc's avatar
licc committed
66 67 68 69 70 71
        <if test="majorName != null">and major_name = #{majorName}</if>
        <if test="academy != null">and academy =#{academy}</if>
        <if test="courseDemand != null">and course_demand =#{courseDemand}</if>
        <if test="nature != null">and nature =#{nature}</if>
        <if test="yearLimit != null">and year_limit =#{yearLimit}</if>
        <if test="planNum != null">and plan_num =#{planNum}</if>
licc's avatar
licc committed
72
        <if test="castArchivesNum != null">and cast_archives_num = #{castArchivesNum}</if>
licc's avatar
licc committed
73 74 75
        <if test="launchNum != null">and launch_num = #{launchNum}</if>
        <if test="lowestMark != null">and lowest_mark = #{lowestMark}</if>
        <if test="lowestRank != null">and lowestMark = #{lowestRank}</if>
licc's avatar
licc committed
76
        <if test="isDelete != null">and is_delete = #{isDelete}</if>
licc's avatar
licc committed
77 78 79 80 81 82 83 84 85 86 87 88 89
        <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.Volunteer" keyProperty="id" useGeneratedKeys="true">
        insert into
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        value(
        <include refid="vals"/>
        )
    </insert>

licc's avatar
licc committed
90 91 92 93 94 95 96 97 98 99 100 101 102

    <update id="updateBySchemeId">
        UPDATE
        <include refid="table"/>
        <set>
            is_delete=1
        </set>
        <where>
            scheme_id = #{schemeId}
            and is_delete=0
        </where>
    </update>

licc's avatar
licc committed
103 104 105 106 107 108 109 110 111 112 113 114 115
    <select id="getFillList" resultType="cn.wisenergy.model.app.Volunteer">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        <where>
            is_delete =0
            <if test="upGrade != null">
                and #{upGrade} > lowest_mark
            </if>
            <if test="downGrade != null">
                and lowest_mark >#{downGrade}
            </if>
116
            <if test="volunteerIds != null and volunteerIds.size > 0 ">
licc's avatar
licc committed
117 118
                and id NOT IN
                <foreach collection="volunteerIds" index="index" item="id" separator="," open="(" close=")">
licc's avatar
licc committed
119 120 121
                    #{id}
                </foreach>
            </if>
licc's avatar
licc committed
122
            order by major_name,lowest_mark desc
licc's avatar
licc committed
123
            limit #{number}
licc's avatar
licc committed
124
        </where>
licc's avatar
licc committed
125 126
    </select>

licc's avatar
licc committed
127 128 129 130 131 132 133 134 135 136 137 138 139
    <select id="getListByIds" resultType="cn.wisenergy.model.app.Volunteer">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        <where>
            id IN
            <foreach collection="list" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </where>
    </select>

licc's avatar
licc committed
140 141 142 143 144 145 146 147 148 149 150 151 152
    <select id="getVolunteerList" resultType="cn.wisenergy.model.app.Volunteer">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        <where>
            is_delete =0
            <if test="upGrade != null">
                and #{upGrade} > lowest_mark
            </if>
            <if test="downGrade != null">
                and lowest_mark >#{downGrade}
            </if>
licc's avatar
licc committed
153
            <if test="classNames != null">
licc's avatar
licc committed
154
                and
licc's avatar
licc committed
155 156
                <foreach collection="classNames" index="index" item="id" separator="or" open="(" close=")">
                    course_demand LIKE CONCAT('%',#{id},'%')
licc's avatar
licc committed
157 158
                </foreach>
            </if>
licc's avatar
licc committed
159
            <if test="professionNames != null">
licc's avatar
licc committed
160
                and
licc's avatar
licc committed
161 162
                <foreach collection="professionNames" index="index" item="id" separator="or" open="(" close=")">
                    major_name LIKE CONCAT('%',#{id},'%')
licc's avatar
licc committed
163 164
                </foreach>
            </if>
licc's avatar
licc committed
165
            order by lowest_mark desc
licc's avatar
licc committed
166 167 168
        </where>
    </select>

licc's avatar
licc committed
169
</mapper>