记得上下班打卡 | git大法好,push需谨慎

Commit 27e934f6 authored by 胡佳晨's avatar 胡佳晨

偷摸 优化志愿者sql

parent 128cf2bd
...@@ -30,27 +30,25 @@ ...@@ -30,27 +30,25 @@
<select id="selectProjectList" resultType="com.liquidnet.service.smile.entity.dto.SmileVolunteersProjectListDto"> <select id="selectProjectList" resultType="com.liquidnet.service.smile.entity.dto.SmileVolunteersProjectListDto">
select a.project_id, select a.project_id,
title, title,
a.time_start, a.time_start,
a.time_end, a.time_end,
a.created_at, a.created_at,
a.status, a.status,
IF(now() >time_end,2,1) as 'time_status', IF(now() > time_end, 2, 1) as 'time_status',
-- count(b0.project_id) + count(b1.project_id) + count(b2.project_id) as 'all', count(b0.status) as 'all',
(select count(0) as 'count'from smile_volunteers as b0 where a.project_id = b0.project_id and b0.status = 0) as 'un_audit', sum(IF(b0.status = 0, 1, 0)) as 'un_audit',
(select count(0) as 'count'from smile_volunteers as b0 where a.project_id = b0.project_id and b0.status = 1) as 'audit', sum(IF(b0.status = 1, 1, 0)) as 'audit',
(select count(0) as 'count'from smile_volunteers as b0 where a.project_id = b0.project_id and b0.status = 2) as 'refuse' sum(IF(b0.status = 2, 1, 0)) as 'refuse'
from smile_volunteers_project as a from smile_volunteers_project as a
-- LEFT JOIN smile_volunteers as b0 on a.project_id = b0.project_id and b0.status = 0 LEFT JOIN smile_volunteers as b0 on a.project_id = b0.project_id
-- LEFT JOIN smile_volunteers as b1 on a.project_id = b1.project_id and b1.status = 1
-- LEFT JOIN smile_volunteers as b2 on a.project_id = b2.project_id and b2.status = 2
<where> <where>
<if test="title!='' and title !=null"> <if test="title!='' and title !=null">
AND title Like concat('%',#{title},'%') AND title Like concat('%',#{title},'%')
</if> </if>
</where> </where>
GROUP BY a.project_id GROUP BY a.project_id
ORDER BY a.created_at desc ORDER BY a.created_at desc
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment