1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?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.yunzhi.demo.mapper.TaPostMapper">
-
- <select id="getPostStatis" resultType="com.yunzhi.demo.vo.StatisPost">
- SELECT
- *
- FROM
- (
- SELECT
- t.*,
- sum( IF ( s.serial_no IS NULL, 0, 1 ) ) AS p_v,
- count( DISTINCT s.person_id ) AS u_v,
- sum( IF ( m.serial_no IS NULL, 0, 1 ) ) AS saved_num
- FROM
- ta_post t
- LEFT JOIN ta_read_log s ON t.post_id = s.post_id
- LEFT JOIN ta_post_save m ON t.post_id = m.post_id
- AND m.`status` > - 1
- WHERE
- 1 = 1
- <if test="startDate != null and startDate != ''">
- AND s.create_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d' )
- AND m.create_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d' )
- </if>
- <if test="startDate != null and startDate != ''">
- AND s.create_date <= DATE_FORMAT( #{endDate}, '%Y-%m-%d' )
- AND m.create_date <= DATE_FORMAT( #{endDate}, '%Y-%m-%d' )
- </if>
- <if test="typeId != null and typeId != ''">
- AND t.type_id = #{typeId}
- </if>
- <if test="name != null and name != ''">
- AND t.name LIKE CONCAT('%', #{name}, '%')
- </if>
- GROUP BY
- t.post_id
- ) a
- ORDER BY
- <if test="asc != null and asc != ''">
- ${asc} ASC
- </if>
- <if test="desc != null and desc != ''">
- ${desc} DESC
- </if>
- </select>
- </mapper>
|