Revert "fix delete user"

This reverts commit 07fe5a02
This commit is contained in:
CaIon 2023-12-27 15:31:28 +08:00
parent 45ed973f1c
commit 7cd1261a81
2 changed files with 24 additions and 25 deletions

View File

@ -6,7 +6,6 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
"one-api/common" "one-api/common"
"strings" "strings"
"time"
) )
// User if you add sensitive fields, don't forget to clean them in setupLogin function. // User if you add sensitive fields, don't forget to clean them in setupLogin function.
@ -32,7 +31,7 @@ type User struct {
AffQuota int `json:"aff_quota" gorm:"type:int;default:0;column:aff_quota"` // 邀请剩余额度 AffQuota int `json:"aff_quota" gorm:"type:int;default:0;column:aff_quota"` // 邀请剩余额度
AffHistoryQuota int `json:"aff_history_quota" gorm:"type:int;default:0;column:aff_history"` // 邀请历史额度 AffHistoryQuota int `json:"aff_history_quota" gorm:"type:int;default:0;column:aff_history"` // 邀请历史额度
InviterId int `json:"inviter_id" gorm:"type:int;column:inviter_id;index"` InviterId int `json:"inviter_id" gorm:"type:int;column:inviter_id;index"`
DeletedAt *time.Time `gorm:"index"` DeletedAt gorm.DeletedAt `gorm:"index"`
} }
// CheckUserExistOrDeleted check if user exist or deleted, if not exist, return false, nil, if deleted or exist, return true, nil // CheckUserExistOrDeleted check if user exist or deleted, if not exist, return false, nil, if deleted or exist, return true, nil
@ -63,7 +62,7 @@ func GetAllUsers(startIdx int, num int) (users []*User, err error) {
} }
func SearchUsers(keyword string) (users []*User, err error) { func SearchUsers(keyword string) (users []*User, err error) {
err = DB.Unscoped().Omit("password").Where("id = ? or username LIKE ? or email LIKE ? or display_name LIKE ?", keyword, keyword+"%", keyword+"%", keyword+"%").Find(&users).Error err = DB.Omit("password").Where("id = ? or username LIKE ? or email LIKE ? or display_name LIKE ?", keyword, keyword+"%", keyword+"%", keyword+"%").Find(&users).Error
return users, err return users, err
} }

View File

@ -72,13 +72,13 @@ const UsersTable = () => {
}, { }, {
title: '状态', dataIndex: 'status', render: (text, record, index) => { title: '状态', dataIndex: 'status', render: (text, record, index) => {
return (<div> return (<div>
{record.DeletedAt !== null? <Tag color='red'>已注销</Tag> : renderStatus(text)} {record.deleted_at !== null? <Tag color='red'>已注销</Tag> : renderStatus(text)}
</div>); </div>);
}, },
}, { }, {
title: '', dataIndex: 'operate', render: (text, record, index) => (<div> title: '', dataIndex: 'operate', render: (text, record, index) => (<div>
{ {
record.DeletedAt !== null ? <></>: record.deleted_at !== null ? <></>:
<> <>
<Popconfirm <Popconfirm
title="确定?" title="确定?"