Skip to content
New issue

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

deleted not work #573

Open
zhangguanzhang opened this issue Jun 26, 2020 · 2 comments
Open

deleted not work #573

zhangguanzhang opened this issue Jun 26, 2020 · 2 comments
Labels
kind/enhancement Categorizes issue or PR as related to enhancement.

Comments

@zhangguanzhang
Copy link
Contributor

zhangguanzhang commented Jun 26, 2020

下面代码意图是可以在url query里使用类似filter=deleted=true查询删除掉的对象

key, value := params[0], params[1]
// 兼容在filter中使用deleted参数
if key == "deleted" {
deleted, err := strconv.ParseBool(value)
if err != nil {
continue
}
qmap[key] = deleted
continue
}

但是我增加用户然后删除后看到数据库里记录被删除了,看了下是强删除
func (*userModel) DeleteUser(id int64) (err error) {
v := User{Id: id}
if err = Ormer().Read(&v); err != nil {
return
}
_, err = Ormer().Delete(&User{Id: id})
return
}

而不是把User的deleted字段 set为 true

@70data
Copy link
Collaborator

70data commented Jun 29, 2020

提个 pr 吧。

@70data 70data added the kind/enhancement Categorizes issue or PR as related to enhancement. label Jun 29, 2020
@cugxuan
Copy link
Contributor

cugxuan commented Jul 4, 2020

emm,这个不太好改,因为 namespace_user 和 user 表之间有关联关系。
现有的逻辑是硬删除,在 user 表中删除的时候由于 User 这个 struct 里面指针有 namespace_user 可以一起将 namespace_user 中的对应内容删除。
如果要改成 soft delete,将 user 表中的 deleted 置为 true,那么 namespace_user 中的逻辑如何处理?可以考虑增加一个 deleted 字段。
数据库修改之后就好改了,还需要修改后端的 api 中 user 和 namespace_user 的默认请求方式(默认不显示 deleted 为 true 的内容),以及修改前端(需要加入硬删除的操作?)

总体来说可能还需要探讨一下产品设计和逻辑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Categorizes issue or PR as related to enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants