用SQL语句做权限控制

SELECT cu.customer_id, cu.customer_name, cu.province, cu.city, cu.address, cu.phone1, cu.industry, cu.responsible_id, cu.responsible, cu.operate_time, sb.item_value AS industry_name FROM (SELECT customer_id FROM crm_customer WHERE operator_id = 100223 OR responsible_id = 100223 UNION SELECT DISTINCT (csb.info_id) AS customer_id FROM crm_share_base csb WHERE (csb.owner_type = 'user' AND csb.owner_id = 100223) OR (csb.owner_type = 'role' AND csb.owner_id IN (SELECT role_id FROM sys_user_role WHERE user_id = 100223)) UNION SELECT DISTINCT (v.customer_id) FROM crm_share_link_customer_v v WHERE (v.status = '1' AND v.permi = '1' AND v.owner_type = 'user' AND v.owner_id = 100223) OR (v.status = '1' AND v.permi = '1' AND v.owner_type = 'role' AND v.owner_id IN (SELECT role_id FROM sys_user_role WHERE user_id = 100223))) x INNER JOIN crm_customer cu ON cu.customer_id = x.customer_id LEFT OUTER JOIN sys_busi_param sb ON sb.type_name = 'industry' AND sb.item_key = cu.industry WHERE (1 = 1)

你可能感兴趣的:(用SQL语句做权限控制)