<?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.yida.data.school.secondClass.mapper.EduSecondClassVenueMapper">
  <select id="listVenue" resultType="com.yida.data.school.vo.secondClass.VenueVO">
    select id,
           name,
           province_id,
           city_id,
           county_id,
           village_id,
           address,
           mobile,
           open_date,
           open_time,
           remark,
           remark_file_cover,
           visit_num,
           subject_id
    from edu_second_class_venue
      where del_flag = 0
        and dept_id = #{deptId}
    <if test="name != null and name != ''">
      and name like concat('%', #{name}, '%')
    </if>
    <if test="status != null">
      and status = #{status}
    </if>
    <if test="homeRecommed != null">
      and home_recommend = #{homeRecommed}
    </if>
    <if test="subjectId != null">
      and subject_id = #{subjectId}
    </if>
    <choose>
      <when test="sortType != null and sortType == 1">
        order by visit_num desc
      </when>
      <otherwise>
        order by create_date desc
      </otherwise>
    </choose>
    <if test="limit != null">
      limit #{limit}
    </if>
  </select>

  <update id="incrVisitNum">
    update edu_second_class_venue
    set visit_num=visit_num+1
    where id=#{venueId}
  </update>
</mapper>
