package com.lideeyunji.service.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lideeyunji.service.system.entity.RoleOAuth2ClientDO;
import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

@Mapper
public interface RoleOAuth2ClientMapper extends BaseMapperX<RoleOAuth2ClientDO> {

    default List<RoleOAuth2ClientDO> selectListByRoleId(Long roleId) {
        return selectList(RoleOAuth2ClientDO::getRoleId, roleId);
    }

    default List<RoleOAuth2ClientDO> selectListByRoleId(Collection<Long> roleIds) {
        return selectList(RoleOAuth2ClientDO::getRoleId, roleIds);
    }

    default List<RoleOAuth2ClientDO> selectListByMenuId(Long clientId) {
        return selectList(RoleOAuth2ClientDO::getOauthClientId, clientId);
    }

    default void deleteListByRoleIdAndOauthClientId(Long roleId, Collection<Long> clientIds) {
        delete(new LambdaQueryWrapper<RoleOAuth2ClientDO>()
                .eq(RoleOAuth2ClientDO::getRoleId, roleId)
                .in(RoleOAuth2ClientDO::getOauthClientId, clientIds));
    }

    default void deleteListByRoleId(Long roleId) {
        delete(new LambdaQueryWrapper<RoleOAuth2ClientDO>().eq(RoleOAuth2ClientDO::getRoleId, roleId));
    }

}
