Browse Source

查询老师的课程

周箭河 5 năm trước cách đây
mục cha
commit
c07a97cbd6

+ 1 - 0
mec-web/src/main/java/com/ym/mec/web/dal/dao/ClassGroupDao.java

@@ -15,4 +15,5 @@ public interface ClassGroupDao extends BaseDAO<Integer, ClassGroup> {
      * @return
      */
     List<ClassGroup> findClassGroup4Teacher(@Param("teacherId") int teacherId);
+
 }

+ 35 - 15
mec-web/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -5,7 +5,6 @@
 不要修改此文件。所有改动将在下次重新自动生成时丢失。
 -->
 <mapper namespace="com.ym.mec.web.dal.dao.ClassGroupDao">
-
     <resultMap type="com.ym.mec.web.dal.entity.ClassGroup" id="ClassGroup">
         <result column="id_" property="id"/>
         <result column="music_group_id_" property="musicGroupId"/>
@@ -20,6 +19,39 @@
         <result column="teacher_salary_" property="teacherSalary"/>
     </resultMap>
 
+
+    <insert id="insert" parameterType="com.ym.mec.web.dal.entity.ClassGroup" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO class_group
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id!=null">id_,</if>
+            <if test="musicGroupId!=null">music_group_id_,</if>
+            <if test="subjectId!=null">subject_id_,</if>
+            <if test="name!=null">name_,</if>
+            <if test="studentNum!=null">student_num_,</if>
+            <if test="assistantTeacherId!=null">assistant_teacher_id_,</if>
+            <if test="mainTeacherId!=null">main_teacher_id_,</if>
+            <if test="createTime!=null">create_time_,</if>
+            <if test="updateTime!=null">update_time_,</if>
+            <if test="type!=null">type_,</if>
+            <if test="teacherSalary!=null">teacher_salary_</if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id!=null">#{id},</if>
+            <if test="musicGroupId!=null">#{musicGroupId},</if>
+            <if test="subjectId!=null">#{subjectId},</if>
+            <if test="name!=null">#{name},</if>
+            <if test="studentNum!=null">#{studentNum},</if>
+            <if test="assistantTeacherId!=null">#{assistantTeacherId},</if>
+            <if test="mainTeacherId!=null">#{mainTeacherId},</if>
+            <if test="createTime!=null">#{createTime},</if>
+            <if test="updateTime!=null">#{updateTime},</if>
+            <if test="type!=null">#{type},</if>
+            <if test="teacherSalary!=null">#{teacherSalary}</if>
+        </trim>
+    </insert>
+
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="ClassGroup">
         SELECT * FROM class_group WHERE id_ = #{id}
@@ -30,19 +62,6 @@
 		SELECT * FROM class_group ORDER BY id_
 	</select>
 
-    <!-- 向数据库增加一条记录 -->
-    <insert id="insert" parameterType="com.ym.mec.web.dal.entity.ClassGroup" useGeneratedKeys="true" keyColumn="id"
-            keyProperty="id">
-        <!--
-        <selectKey resultClass="int" keyProperty="id" >
-        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
-        </selectKey>
-        -->
-        INSERT INTO class_group
-        (id_,music_group_id_,subject_id_,name_,student_num_,assistant_teacher_id_,main_teacher_id_,create_time_,update_time_,type_,teacher_salary_)
-        VALUES(#{id},#{musicGroupId},#{subjectId},#{name},#{studentNum},#{assistantTeacherId},#{mainTeacherId},#{createTime},#{updateTime},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{teacherSalary})
-    </insert>
-
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.web.dal.entity.ClassGroup">
         UPDATE class_group
@@ -93,6 +112,8 @@
     <select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM class_group
 	</select>
+
+    <!-- 查询根据主教助教查询班级信息 -->
     <select id="findClassGroup4Teacher" resultMap="ClassGroup">
         SELECT
         c.*,
@@ -104,6 +125,5 @@
         c.main_teacher_id_ = #{teacherId}
         OR
         c.assistant_teacher_id_ = #{teacherId}
-
     </select>
 </mapper>