fix
This commit is contained in:
parent
ca6f0c51e5
commit
81f3eb6675
|
@ -8,14 +8,14 @@ import (
|
|||
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
func (u *LdapUsersModel) CreateOrUpdate(ctx context.Context, appId string, openId string, data *LdapUsers) error {
|
||||
func (u *LdapUsersModel) CreateOrUpdate(ctx context.Context, openId string, data *LdapUsers) error {
|
||||
var info LdapUsers
|
||||
err := u.db.WithContext(ctx).Where("app_id = ? and open_id = ?", appId, openId).Take(&info).Error
|
||||
err := u.db.WithContext(ctx).Where("open_id = ?", openId).Take(&info).Error
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return u.db.WithContext(ctx).Create(&data).Error
|
||||
}
|
||||
return err
|
||||
}
|
||||
return u.db.WithContext(ctx).Where("app_id = ? and open_id = ?", appId, openId).Updates(&data).Error
|
||||
return u.db.WithContext(ctx).Where("open_id = ?", openId).Updates(&data).Error
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user