We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
由于没有时间测试, 所以我简单处理了一下,目前我的解决方案是 iw, _ := goSnowFlake.NewIdWorker(1) for _, v := range names { pid, _ := strconv.Atoi(v) id, err := iw.NextId() if err != nil { id, _ = iw.NextId() } groupPermission.Id = id groupPermission.Permissionid = int64(pid) err = AddGroupsPermission(groupPermission) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
func (this *ManageGroupPermissionController) Post() {
在这个函数中, 在for循环中使用了SnowFlakeId来生成id
但实际使用过程中发现, 如果更新太快, 会导致snowFlakeid获取的id重复, 导致设置权限失败
看了一下snowFlakeid, 发现这个东西是根据当前毫秒级时间戳+线程id+序号
由于每次都生成新的序号, 导致在同已毫秒内获取到的id都是一样的,建议对Util的SnowFlakeId进行修改
由于没有时间测试, 所以我简单处理了一下,目前我的解决方案是
iw, _ := goSnowFlake.NewIdWorker(1)
for _, v := range names {
pid, _ := strconv.Atoi(v)
id, err := iw.NextId()
if err != nil {
id, _ = iw.NextId()
}
groupPermission.Id = id
groupPermission.Permissionid = int64(pid)
err = AddGroupsPermission(groupPermission)
}
The text was updated successfully, but these errors were encountered: