From fcc87c34af059168624b6523e5b90e7a191481f6 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 26 Aug 2019 11:44:47 +0800 Subject: [PATCH] =?UTF-8?q?-=20TransferLegacyWeixins=E4=B8=AD=E9=87=87?= =?UTF-8?q?=E7=94=A8=E5=A2=9E=E9=87=8F=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/authz.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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)