select 
func.functionname optName,
func.functionorder optCode,
func.functionurl text,
sum(CASE
    WHEN openid = :openid THEN 1
    ELSE 0
END )
as enable
from t_s_function func
left join t_s_role_function rolefunc on rolefunc.functionid = func.id
left join t_s_role_user ruser on rolefunc.roleid = ruser.roleid
left join t_s_user suser on ruser.userid = suser.id
where functiontype = '1'
group by optName,optCode,text