Commit e3be2346 authored by hujiebin's avatar hujiebin

feat:庆幸有冗余数据

parent f44d7fed
......@@ -83,11 +83,12 @@ type CpInfo struct {
type CpLevel struct {
CpId uint64
Level uint64
CreatedTime time.Time
}
func main() {
var cpInfos []*CpInfo
if err := mysql.ProdReadOnlyDB.Table("cp_relation").Select("id,user_id1,user_id2,created_time").Find(&cpInfos).Error; err != nil {
if err := mysql.ProdReadOnlyDB.Table("cp_relation").Select("id,user_id1,user_id2").Find(&cpInfos).Error; err != nil {
panic(err)
}
var cpIds []uint64
......@@ -95,7 +96,7 @@ func main() {
cpIds = append(cpIds, v.Id)
}
var cpLevels []CpLevel
if err := mysql.ProdReadOnlyDB.Table("cp_level").Select("cp_id,level").Where("cp_id in ?", cpIds).Find(&cpLevels).Error; err != nil {
if err := mysql.ProdReadOnlyDB.Table("cp_level").Select("cp_id,level,created_time").Where("cp_id in ?", cpIds).Find(&cpLevels).Error; err != nil {
panic(err)
}
var userIds []uint64
......@@ -106,6 +107,7 @@ func main() {
for _, v2 := range cpLevels {
if v.Id == v2.CpId {
cpInfos[i].Level = v2.Level
cpInfos[i].CreatedTime = v2.CreatedTime
break
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment