24 lines
1.1 KiB
Go
24 lines
1.1 KiB
Go
package gmodel
|
|
|
|
import "context"
|
|
|
|
func (gm *LdapGroupMenusModel) FindOne(ctx context.Context, menuId, groupId int64) (resp *LdapGroupMenus, err error) {
|
|
err = gm.db.WithContext(ctx).Model(&LdapGroupMenus{}).Where("menu_id = ? and group_id = ?", menuId, groupId).Take(&resp).Error
|
|
return resp, err
|
|
}
|
|
|
|
func (gm *LdapGroupMenusModel) Create(ctx context.Context, data *LdapGroupMenus) error {
|
|
return gm.db.WithContext(ctx).Model(&LdapGroupMenus{}).Create(&data).Error
|
|
}
|
|
|
|
func (gm *LdapGroupMenusModel) Delete(ctx context.Context, menuId, groupId int64) error {
|
|
return gm.db.WithContext(ctx).Model(&LdapGroupMenus{}).Where("menu_id = ? and group_id", menuId, groupId).Delete(&LdapGroupMenus{}).Error
|
|
}
|
|
|
|
func (gm *LdapGroupMenusModel) DeleteByMenuId(ctx context.Context, menuId int64) error {
|
|
return gm.db.WithContext(ctx).Model(&LdapGroupMenus{}).Where("menu_id = ?", menuId).Delete(&LdapGroupMenus{}).Error
|
|
}
|
|
func (gm *LdapGroupMenusModel) DeleteByGroupId(ctx context.Context, groupId int64) error {
|
|
return gm.db.WithContext(ctx).Model(&LdapGroupMenus{}).Where("group_id = ?", groupId).Delete(&LdapGroupMenus{}).Error
|
|
}
|