1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
| <?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.scy.sms.dao.mapper.StudentMapper"> <resultMap id="studentMap" type="com.scy.sms.dao.entity.Student"> <id column="student_id" property="studentId" jdbcType="VARCHAR"/> <result column="student_name" property="studentName" jdbcType="VARCHAR"/> <result column="student_number" property="studentNumber" jdbcType="VARCHAR"/> <result column="student_sex" property="studentSex" jdbcType="VARCHAR"/> <result column="student_phone_number" property="studentPhoneNumber" jdbcType="VARCHAR"/> <result column="student_email" property="studentEmail" jdbcType="VARCHAR"/> <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/> <result column="student_enrollment_date" property="studentEnrollmentDate" jdbcType="VARCHAR"/> </resultMap> <sql id="insertKey"> <trim suffixOverrides=","> student_id, <if test="studentName != null and studentName != ''"> student_name, </if> <if test="studentNumber != null and studentNumber != ''"> student_number, </if> <if test="studentSex != null and studentSex != ''"> student_sex, </if> <if test="studentPhoneNumber != null and studentPhoneNumber != ''"> student_phone_number, </if> <if test="studentEmail != null and studentEmail != ''"> student_email, </if> <if test="studentEnrollmentDate != null and studentEnrollmentDate != ''"> student_enrollment_date, </if> </trim> </sql>
<sql id="insertValues"> <trim suffixOverrides=","> #{studentId}, <if test="studentName != null and studentName != ''"> #{studentName}, </if> <if test="studentNumber != null and studentNumber != ''"> #{studentNumber}, </if> <if test="studentSex != null and studentSex != ''"> #{studentSex}, </if> <if test="studentPhoneNumber != null and studentPhoneNumber != ''"> #{studentPhoneNumber}, </if> <if test="studentEmail != null and studentEmail != ''"> #{studentEmail}, </if> <if test="studentEnrollmentDate != null and studentEnrollmentDate != ''"> #{studentEnrollmentDate}, </if> </trim> </sql> <select id="studentPageQuery" parameterType="map" resultType="com.scy.sms.dto.StudentDTO"> SELECT student_id, student_name, student_number, student_sex, student_phone_number, student_email, create_time, modify_time, student_enrollment_date FROM student <where> <if test="studentId != null and studentId != ''"> and student_id = #{studentId} </if> <if test="studentName != null and studentName != ''"> and student_name = #{studentName} </if> <if test="studentNumber != null and studentNumber != ''"> and student_number = #{studentNumber} </if> </where> order by student_id desc limit #{offset} , #{limit} </select> <select id="studentDetailQuery" parameterType="java.lang.String" resultType="com.scy.sms.dto.StudentDTO"> SELECT student_id, student_name, student_number, student_sex, student_phone_number, student_email, create_time, modify_time, student_enrollment_date FROM student WHERE student_id = #{studentId} </select>
update student <trim prefix="set" suffixOverrides=","> <if test="studentName != null and studentName != ''"> student_name = #{studentName}, </if> <if test="studentNumber != null and studentNumber != ''"> student_number = #{studentNumber}, </if> <if test="studentSex != null and studentSex != ''"> student_sex = #{studentSex}, </if> <if test="studentPhoneNumber != null and studentPhoneNumber != ''"> student_phone_number = #{studentPhoneNumber}, </if> <if test="studentEmail != null and studentEmail != ''"> studentEmail = #{studentEmail}, </if> <if test="studentEnrollmentDate != null and studentEnrollmentDate != ''"> student_enrollment_date = #{studentEnrollmentDate}, </if> </trim> where student_id = #{studentId,jdbcType=VARCHAR} </update>--> <update id="studentUpdate" parameterType="com.scy.sms.dto.StudentDTO"> update student <set> <if test="studentName != null and studentName != ''"> student_name = #{studentName}, </if> <if test="studentNumber != null and studentNumber != ''"> student_number = #{studentNumber}, </if> <if test="studentSex != null and studentSex != ''"> student_sex = #{studentSex}, </if> <if test="studentPhoneNumber != null and studentPhoneNumber != ''"> student_phone_number = #{studentPhoneNumber}, </if> <if test="studentEmail != null and studentEmail != ''"> student_email = #{studentEmail}, </if> <if test="studentEnrollmentDate != null and studentEnrollmentDate != ''"> student_enrollment_date = #{studentEnrollmentDate}, </if> </set> where student_id = #{studentId,jdbcType=VARCHAR} </update>
<insert id="studentInsert" parameterType="com.scy.sms.dto.StudentDTO"> insert into student(<include refid="insertKey"/>) values(<include refid="insertValues"/>) </insert>
<delete id="studentDelete" parameterType="com.scy.sms.dto.StudentDTO"> delete from student where student_id=#{studentId} </delete> </mapper>
|