diff --git a/script/sync_group_power_icon.go b/script/sync_group_power_icon.go new file mode 100644 index 0000000000000000000000000000000000000000..73c2d26c616b449e473bf92d5f96b2479ac6134d --- /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 + } +}