123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?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.miaxis.exam.mapper.ExamInfoMapper">
- <resultMap type="ExamInfo" id="ExamInfoResult">
- <result property="id" column="id" />
- <result property="name" column="name" />
- <result property="image" column="image" />
- <result property="provinceId" column="province_id" />
- <result property="province" column="province" />
- <result property="cityId" column="city_id" />
- <result property="city" column="city" />
- <result property="price" column="price" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <select id="selectExamInfoList" parameterType="ExamInfo" resultMap="ExamInfoResult">
- select * from exam_info
- <where>
- <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
- <if test="image != null and image != ''"> and image = #{image}</if>
- <if test="provinceId != null and provinceId != ''"> and province_id = #{provinceId}</if>
- <if test="province != null and province != ''"> and province = #{province}</if>
- <if test="cityId != null and cityId != ''"> and city_id = #{cityId}</if>
- <if test="city != null and city != ''"> and city = #{city}</if>
- </where>
- </select>
- <sql id="selectExamInfoVo">
- select *,(select count(1) from vip_exam_video v where v.exam_id = e.id) as video_count from exam_info e
- </sql>
- <select id="selectExamInfoList" parameterType="com.miaxis.exam.dto.ExamInfoDto" resultType="com.miaxis.exam.vo.ExamInfoVipVo">
- SELECT e.*,
- (SELECT COUNT(1) FROM vip_exam_video v WHERE v.exam_id = e.id) AS video_count,
- (SELECT expiration_time FROM vip_user_exam WHERE e.id = exam_id AND user_id = #{userId} AND NOW() <![CDATA[<=]]> expiration_time) AS expiration_time,
- (CASE WHEN NOW() <![CDATA[<=]]> (SELECT expiration_time FROM vip_user_exam WHERE e.id = exam_id AND user_id = #{userId}) THEN 1 ELSE 0 END) AS is_vip
- FROM exam_info e
- <where>
- <if test="province != null and province != ''" > AND e.province = #{province}</if>
- <if test="provinceId != null and provinceId != ''" > AND e.province_id = #{provinceId}</if>
- <if test="cityId != null and cityId != ''" > AND e.city_id = #{cityId}</if>
- <if test="city != null and city != ''" > AND e.city = #{city}</if>
- <if test="name != null and name != ''"> and e.name like concat('%', #{name}, '%')</if>
- </where>
- </select>
- <select id="selectMyExamInfoList" parameterType="com.miaxis.exam.dto.ExamInfoDto" resultType="com.miaxis.exam.vo.ExamInfoVipVo">
- SELECT e.*,
- (SELECT COUNT(1) FROM vip_exam_video v WHERE v.exam_id = e.id) AS video_count,
- (SELECT expiration_time FROM vip_user_exam WHERE e.id = exam_id AND user_id = #{userId} AND NOW() <![CDATA[<=]]> expiration_time) AS expiration_time,
- (CASE WHEN NOW() <![CDATA[<=]]> (SELECT expiration_time FROM vip_user_exam WHERE e.id = exam_id AND user_id = #{userId}) THEN 1 ELSE 0 END) AS is_vip
- FROM exam_info e join vip_user_exam vu on e.id = vu.exam_id
- <where>
- <if test="province != null and province != ''" > AND e.province = #{province}</if>
- <if test="provinceId != null and provinceId != ''" > AND e.province_id = #{provinceId}</if>
- <if test="cityId != null and cityId != ''" > AND e.city_id = #{cityId}</if>
- <if test="city != null and city != ''" > AND e.city = #{city}</if>
- <if test="name != null and name != ''"> and e.name like concat('%', #{name}, '%')</if>
- <if test="userId != null"> and vu.user_id = #{userId}</if>
- </where>
- </select>
- <!--
- <select id="selectExamInfoList" parameterType="ExamInfo" resultMap="ExamInfoResult">
- <include refid="selectExamInfoVo"/>
- <where>
- <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
- <if test="image != null and image != ''"> and image = #{image}</if>
- <if test="provinceId != null and provinceId != ''"> and province_id = #{provinceId}</if>
- <if test="province != null and province != ''"> and province = #{province}</if>
- <if test="cityId != null and cityId != ''"> and city_id = #{cityId}</if>
- <if test="city != null and city != ''"> and city = #{city}</if>
- </where>
- </select>
- -->
- <select id="getProvice" resultType="com.miaxis.exam.vo.ExamInfoProviceVo">
- select province_id,province from exam_info group by province_id,province
- </select>
- <select id="getCity" resultType="com.miaxis.exam.vo.ExamInfoCityVo">
- select city_id,city from exam_info where province_id = #{provinceId}
- GROUP BY city_id,city
- </select>
- </mapper>
|