select 
user.id userid,
openid,
user.mobilePhone mobilePhone,
post.post_name post,
baseuser.realname userName,
max(case acc.gatet_type when 'shenfenzhengfuyinjian2' then file.file_url else '' end ) picture0id,
max(case acc.gatet_type when 'zhengshencailiao5' then file.file_url else '' end) picture1id,
max(case acc.gatet_type when 'zhengshencailiao6' then file.file_url else '' end) picture2id,
max(case acc.gatet_type when 'tijianbiao1' then file.file_url else '' end) picture3id,
max(case acc.gatet_type when 'tijianbaogao7' then file.file_url else '' end) picture4id,
max(case acc.gatet_type when 'hukoubenshouye3' then file.file_url else '' end) picture5id,
max(case acc.gatet_type when 'hukoubenbenrenye4' then file.file_url else '' end) picture6id
from t_bus_accessory acc
left join t_sys_file file on file.busi_id = acc.id
left join t_s_user user on acc.userid = user.id
LEFT JOIN t_bus_user_personnel AS userpersonnel ON user.id = userpersonnel.userid
left join t_bus_post post on userpersonnel.in_postid = post.id
left join t_s_base_user  baseuser on user.id = baseuser.id
where acc.delete_flag = '0' 
and baseuser.delete_flag <> '1'
<#if userid ?exists && userid ?length gt 0>
	AND user.id = :userid 
</#if>
group by openid,userid,mobilePhone,post,userName
