Skip to content

Commit

Permalink
update authorizers
Browse files Browse the repository at this point in the history
  • Loading branch information
carolmao committed Apr 18, 2022
1 parent bd5cc50 commit 6b31cd7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api/admin/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,22 @@ func getAuthorizerListHandler(c *gin.Context) {
}(i, record)
}
wg.Wait()

// 异步更新数据库
go func(oldRecords []*model.Authorizer, newRecords *[]getAuthorizerInfoResp) {
var updateRecords []model.Authorizer
for i, newRecord := range *newRecords {
newRecord.ID = oldRecords[i].ID
if *oldRecords[i] != newRecord.Authorizer {
updateRecords = append(updateRecords, newRecord.Authorizer)
}
}
if len(updateRecords) != 0 {
log.Info("update records: ", updateRecords)
dao.BatchCreateOrUpdateAuthorizerRecord(&updateRecords)
} else {
log.Info("no update")
}
}(records, &resp)
c.JSON(http.StatusOK, errno.OK.WithData(gin.H{"total": total, "records": resp}))
}

0 comments on commit 6b31cd7

Please sign in to comment.