| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <?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.keao.edu.user.dao.TeacherDao">
-
- <resultMap type="com.keao.edu.user.entity.Teacher" id="Teacher">
- <result column="user_id_" property="userId" />
- <result column="title_" property="title" />
- <result column="subject_id_list_" property="subjectIdList" />
- <result column="salary_settlement_type_" property="salarySettlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
- <result column="salary_" property="salary" />
- <result column="del_flag_" property="delFlag" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
- <result column="total_invigilation_num_" property="totalInvigilationNum"/>
- <result column="total_invigilation_student_num_" property="totalInvigilationStudentNum"/>
- <result column="total_settlement_fee_" property="totalSettlementCost"/>
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="tenant_id_" property="tenantId" />
- <result column="organ_id_" property="organId" />
- <association property="sysUser" columnPrefix="sys_user_" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
- </resultMap>
- <resultMap id="TeacherDto" type="com.keao.edu.user.dto.TeacherDto" extends="Teacher">
- <result property="subjectNames" column="subject_names_"/>
- </resultMap>
- <select id="get" resultMap="Teacher">
- SELECT t.*,
- su.id_ sys_user_id_,
- su.username_ sys_user_username_,
- su.phone_ sys_user_phone_,
- su.avatar_ sys_user_avatar_,
- su.real_name_ sys_user_real_name_,
- su.user_type_ sys_user_user_type_
- FROM teacher t
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- WHERE t.user_id_ = #{id}
- </select>
- <update id="update" parameterType="com.keao.edu.user.entity.Teacher">
- UPDATE teacher
- <set>
- <if test="title != null">
- title_ = #{title},
- </if>
- <if test="subjectIdList != null">
- subject_id_list_ = #{subjectIdList},
- </if>
- <if test="salarySettlementType != null">
- salary_settlement_type_ = #{salarySettlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="delFlag != null">
- del_flag_ = #{delFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="salary != null">
- salary_ = #{salary},
- </if>
- <if test="tenantId != null">
- tenant_id_ = #{tenantId},
- </if>
- <if test="organId != null">
- organ_id_ = #{organId},
- </if>
- <if test="totalInvigilationNum != null">
- total_invigilation_num_ = #{totalInvigilationNum},
- </if>
- <if test="totalInvigilationStudentNum != null">
- total_invigilation_student_num_ = #{totalInvigilationStudentNum},
- </if>
- <if test="totalSettlementCost != null">
- total_settlement_fee_ = #{totalSettlementCost},
- </if>
- update_time_ = NOW()
- </set>
- WHERE user_id_ = #{userId}
- </update>
- <update id="batchUpdate" parameterType="com.keao.edu.user.entity.Teacher">
- <foreach collection="teachers" item="teacher" separator=";">
- UPDATE teacher
- <set>
- <if test="teacher.totalInvigilationNum != null">
- total_invigilation_num_ = #{teacher.totalInvigilationNum},
- </if>
- <if test="teacher.totalInvigilationStudentNum != null">
- total_invigilation_student_num_ = #{teacher.totalInvigilationStudentNum},
- </if>
- <if test="teacher.totalSettlementCost != null">
- total_settlement_fee_ = #{teacher.totalSettlementCost},
- </if>
- update_time_ = NOW()
- </set>
- WHERE user_id_ = #{teacher.userId}
- </foreach>
- </update>
- <!-- 全查询 -->
- <select id="findAll" resultMap="Teacher">
- SELECT * FROM teacher WHERE tenant_id_ = #{tenantId}
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.keao.edu.user.entity.Teacher" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO teacher (user_id_,title_,subject_id_list_,salary_settlement_type_,salary_,create_time_,update_time_,tenant_id_,organ_id_)
- VALUES(#{userId},#{title},#{subjectIdList},#{salarySettlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{salary},NOW(),NOW(),#{tenantId},#{organId})
- </insert>
- <update id="delete">
- UPDATE teacher SET del_flag_ = 1,update_time_ = NOW() WHERE user_id_ = #{id}
- </update>
- <sql id="teacherQueryPage">
- <where>
- t.del_flag_ = 0
- <if test="search != null and search != ''">
- AND (t.user_id_ = #{search}
- OR su.real_name_ LIKE CONCAT('%',#{search},'%')
- OR su.phone_ LIKE CONCAT('%',#{search},'%'))
- </if>
- <if test="tenantId != null and tenantId != 0">
- AND t.tenant_id_ = #{tenantId}
- </if>
- <if test="organId != null and organId != 0">
- AND t.organ_id_ = #{organId}
- </if>
- <if test="settlementType != null and settlementType != ''">
- AND t.salary_settlement_type_ = #{settlementType}
- </if>
- </where>
- </sql>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="Teacher" parameterType="map">
- SELECT t.*,
- su.id_ sys_user_id_,
- su.username_ sys_user_username_,
- su.phone_ sys_user_phone_,
- su.avatar_ sys_user_avatar_,
- su.real_name_ sys_user_real_name_
- FROM teacher t
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- <include refid="teacherQueryPage"/>
- <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(DISTINCT t.user_id_) FROM teacher t
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- <include refid="teacherQueryPage"/>
- </select>
- <select id="getWithTeachers" resultMap="Teacher">
- SELECT * FROM teacher WHERE user_id_ IN
- <foreach collection="teacherIds" item="teacherId" separator="," open="(" close=")">
- #{teacherId}
- </foreach>
- </select>
- <select id="queryTeacherSubjectNames" resultType="java.util.Map">
- SELECT t.user_id_ 'key',GROUP_CONCAT(s.name_) 'value' FROM teacher t
- LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_list_)
- WHERE t.user_id_ IN
- <foreach collection="teacherIds" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- GROUP BY t.user_id_
- </select>
- </mapper>
|