<?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.srs.dormitory.mapper.DmsRepairRecordsMapper">
	
	<!-- 通用查询映射结果 -->
	<resultMap id="BaseResultMap" type="com.srs.dormitory.domain.DmsRepairRecords">
		<id column="id" property="id"/>
		<result column="user_id" property="userId"/>
		<result column="stu_no" property="stuNo"/>
		<result column="dorm_id" property="dormId"/>
		<result column="repair_number" property="repairNumber"/>
		<result column="expected_visit_time" property="expectedVisitTime"/>
		<result column="content" property="content"/>
		<result column="description" property="description"/>
		<result column="status" property="status"/>
		<result column="assign_time" property="assignTime"/>
		<result column="fix_time" property="fixTime"/>
		<result column="satisfaction" property="satisfaction"/>
		<result column="appraise" property="appraise"/>
		<result column="create_time" property="createTime"/>
		<result column="update_time" property="updateTime"/>
	</resultMap>
	<select id="selectDormName" resultType="java.util.Map">
		SELECT build.`name` building, unit.`name` unit, dorm.room_no as room_no
		FROM dms_dormitory dorm
			     left JOIN dms_dormitory_unit unit ON dorm.unit_id = unit.id
			     left JOIN dms_dormitory_building build ON build.id = unit.building_id
		WHERE dorm.id = #{dormId}
	</select>
	<select id="selectSrsStudentByStuNo" resultType="com.srs.comprehensive.domain.SrsStudent">
		SELECT *
		FROM `srs_student`
		WHERE stu_no = #{stuNo}
	</select>
	<select id="selectRepairList" resultType="com.srs.dormitory.domain.Vo.RepairListVo">
		SELECT id,
		       stu.stu_no,
		       stu.`name` stu_name,
		       repair_number,
		       description,
		       rep.`status`,
		       rep.create_time
		FROM dms_repair_records rep
			     JOIN srs_student stu ON rep.stu_no = stu.stu_no
			${ew.customSqlSegment}
	</select>

</mapper>
