fusenapi/model/gmodel/ldap_group_menus_logic.go
laodaming 1a2c9a8f49 fix
2023-11-15 16:32:07 +08:00

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
}