ScheduleMapper.xml 1.3 KB

1234567891011121314151617181920212223242526
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.example.cinema.data.ScheduleMapper">
  4. <insert id="insertOneSchedule" parameterType="com.example.cinema.vo.ScheduleForm"
  5. useGeneratedKeys="true" keyProperty="id">
  6. insert into schedule(hall_id, movie_id, start_time, end_time, fare)
  7. values(#{hallId}, #{movieId}, #{startTime}, #{endTime}, #{fare})
  8. </insert>
  9. <select id="selectSchedule" resultMap="ScheduleItem">
  10. select * from
  11. (select * from schedule where hall_id = #{hallId} and start_time between #{startDate} and #{endDate}) s,
  12. (select name, id as movie_id from movie) m,
  13. (select name, id as hall_id from hall) h
  14. where s.movie_id = m.movie_id and s.hall_id = h.hall_id
  15. </select>
  16. <resultMap id="ScheduleItem" type="com.example.cinema.vo.ScheduleItem">
  17. <id column="id" property="id"></id>
  18. <result column="hall_id" property="hallId"></result>
  19. <result column="movie_id" property="movieId"></result>
  20. <result column="start_time" property="startTime"></result>
  21. <result column="end_time" property="endTime"></result>
  22. </resultMap>
  23. </mapper>