package cn.novalon.manage.db.dao;

import cn.novalon.manage.db.entity.SysRoleEntity;
import org.springframework.data.domain.Sort;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Repository
public interface SysRoleDao extends R2dbcRepository<SysRoleEntity, Long> {

    Mono<SysRoleEntity> findByIdAndDeletedAtIsNull(Long id);

    Mono<SysRoleEntity> findByRoleKeyAndDeletedAtIsNull(String roleKey);

    Flux<SysRoleEntity> findByDeletedAtIsNull();

    Flux<SysRoleEntity> findByDeletedAtIsNull(Sort sort);

    Flux<SysRoleEntity> findByRoleNameLikeAndRoleKeyLikeAndDeletedAtIsNull(String roleName, String roleKey, Sort sort);

    Mono<Long> countByDeletedAtIsNull();

    Mono<Long> countByRoleNameLikeAndRoleKeyLikeAndDeletedAtIsNull(String roleName, String roleKey);

    Mono<SysRoleEntity> findByRoleNameAndDeletedAtIsNull(String roleName);

    Mono<Boolean> existsByRoleNameAndDeletedAtIsNull(String roleName);
}
