diff --git a/business/jxstore/cms/authz.go b/business/jxstore/cms/authz.go index 578d2ab57..38740f37d 100644 --- a/business/jxstore/cms/authz.go +++ b/business/jxstore/cms/authz.go @@ -26,9 +26,13 @@ func TransferLegacyWeixins() (err error) { // TRUNCATE TABLE casbin_rule; sql := ` - SELECT * - FROM weixins - ORDER BY parentid` + SELECT t1.* + FROM weixins t1 + LEFT JOIN user t2 ON t2.mobile = t1.tel + LEFT JOIN auth_bind t3 ON t3.auth_id = t1.openid AND t3.type = 'weixinsns' + LEFT JOIN auth_bind t4 ON t4.auth_id = t1.openid_mini AND t4.type = 'weixinmini' + WHERE t2.id IS NULL OR (t1.openid <> '' AND t3.id IS NULL) OR (t1.openid_mini <> '' AND t4.id IS NULL) + ORDER BY t1.parentid;` var weixinList []*legacymodel.WeiXins db := dao.GetDB() err = dao.GetRows(db, &weixinList, sql)