2023-11-16 08:57:29 +00:00
|
|
|
package gmodel
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
// TODO: 使用model的属性做你想做的
|
|
|
|
func (u *LdapUserModel) Create(ctx context.Context, data *LdapUser) error {
|
|
|
|
return u.db.WithContext(ctx).Model(&LdapUser{}).Create(&data).Error
|
|
|
|
}
|
2023-11-21 07:07:44 +00:00
|
|
|
func (u *LdapUserModel) Update(ctx context.Context, userDN string, data *LdapUser) error {
|
|
|
|
return u.db.WithContext(ctx).Model(&LdapUser{}).Where("user_dn = ?", userDN).Updates(&data).Error
|
|
|
|
}
|
|
|
|
|
2023-11-22 10:15:25 +00:00
|
|
|
func (u *LdapUserModel) UpdateById(ctx context.Context, id int64, data *LdapUser) error {
|
|
|
|
return u.db.WithContext(ctx).Model(&LdapUser{}).Where("id = ?", id).Updates(&data).Error
|
|
|
|
}
|
|
|
|
|
2023-11-21 07:07:44 +00:00
|
|
|
func (u *LdapUserModel) Delete(ctx context.Context, id int64) error {
|
|
|
|
return u.db.WithContext(ctx).Model(&LdapUser{}).Where("id = ?", id).Delete(&LdapUser{}).Error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *LdapUserModel) GetAllByIds(ctx context.Context, ids []int64) (resp []LdapUser, err error) {
|
|
|
|
if len(ids) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = u.db.WithContext(ctx).Model(&LdapUser{}).Where("id in (?)", ids).Find(&resp).Error
|
|
|
|
return resp, err
|
|
|
|
}
|