From 46669f1f876ccbca0d4a5547b721ce73b309b18e Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 24 Mar 2023 14:14:46 +0800 Subject: [PATCH] Create sync_group_power_icon.go --- script/sync_group_power_icon.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 script/sync_group_power_icon.go diff --git a/script/sync_group_power_icon.go b/script/sync_group_power_icon.go new file mode 100644 index 0000000..73c2d26 --- /dev/null +++ b/script/sync_group_power_icon.go @@ -0,0 +1,26 @@ +package main + +import ( + "git.hilo.cn/hilo-common/script/model" + "git.hilo.cn/hilo-common/script/mysql" +) + +func main() { + var powerOwners []model.GroupPowerUser + if err := mysql.ProdReadOnlyDB.Model(model.GroupPowerUser{}).Where("role = 2").Find(&powerOwners).Error; err != nil { + panic(err) + } + for _, owner := range powerOwners { + var groupInfo model.GroupInfo + if err := mysql.ProdReadOnlyDB.Model(model.GroupInfo{}).Where("owner = ?", owner.UserId).First(&groupInfo).Error; err != nil { + continue + } + if owner.GroupPowerId <= 0 { + panic("0 powerId") + } + if err := mysql.ProdWriteDB.Model(model.GroupPower{}).Where("id = ?", owner.GroupPowerId).UpdateColumn("icon", groupInfo.FaceUrl).Error; err != nil { + panic(err) + } + //break + } +} -- 2.22.0