-- Separate the user enterprise-certification menu from the existing enterprise business records. UPDATE fa_auth_rule SET title='企业业务档案', remark='企业业务记录、订单、员工和开票档案', updatetime=UNIX_TIMESTAMP() WHERE name='merchant'; INSERT INTO fa_auth_rule (type,pid,name,title,icon,ismenu,weigh,status,createtime,updatetime) SELECT 'file',p.id,'merchant/certificates','企业资质认证','fa fa-id-card-o',1,164,'normal',UNIX_TIMESTAMP(),UNIX_TIMESTAMP() FROM fa_auth_rule p WHERE p.name='user' AND NOT EXISTS (SELECT 1 FROM fa_auth_rule WHERE name='merchant/certificates'); -- Preserve access for existing roles that could already view merchant records. UPDATE fa_auth_group g JOIN fa_auth_rule oldrule ON oldrule.name='merchant' JOIN fa_auth_rule cert ON cert.name='merchant/certificates' SET g.rules=CONCAT(g.rules,',',cert.id) WHERE g.rules <> '*' AND FIND_IN_SET(oldrule.id,g.rules)>0 AND FIND_IN_SET(cert.id,g.rules)=0;