21 lines
859 B
Go
21 lines
859 B
Go
package gmodel
|
|
|
|
import "context"
|
|
|
|
// TODO: 使用model的属性做你想做的
|
|
func (m *LdapMenusModel) Create(ctx context.Context, data *LdapMenus) error {
|
|
return m.db.WithContext(ctx).Model(&LdapMenus{}).Create(&data).Error
|
|
}
|
|
func (m *LdapMenusModel) FindOne(ctx context.Context, id int64) (resp *LdapMenus, err error) {
|
|
err = m.db.WithContext(ctx).Model(&LdapMenus{}).Where("id= ? and status = ?", id, 1).Take(&resp).Error
|
|
return resp, err
|
|
}
|
|
|
|
func (m *LdapMenusModel) FindByPath(ctx context.Context, path string) (resp *LdapMenus, err error) {
|
|
err = m.db.WithContext(ctx).Model(&LdapMenus{}).Where("path= ? and status = ?", path, 1).Take(&resp).Error
|
|
return resp, err
|
|
}
|
|
func (m *LdapMenusModel) Update(ctx context.Context, id int64, data *LdapMenus) error {
|
|
return m.db.WithContext(ctx).Model(&LdapMenus{}).Where("id = ?", id).Updates(&data).Error
|
|
}
|