fix
This commit is contained in:
@@ -2,11 +2,15 @@ package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ldap_user ldap_用户id递增表
|
||||
type LdapUser struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
UserDn *string `gorm:"index;default:'';" json:"user_dn"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
type LdapUserModel struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -6,3 +6,18 @@ import "context"
|
||||
func (u *LdapUserModel) Create(ctx context.Context, data *LdapUser) error {
|
||||
return u.db.WithContext(ctx).Model(&LdapUser{}).Create(&data).Error
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user