package cn.novalon.manage.sys.core.repository;

import cn.novalon.manage.sys.core.domain.SysUser;
import cn.novalon.manage.sys.core.query.SysUserQuery;
import cn.novalon.manage.common.dto.PageRequest;
import cn.novalon.manage.common.dto.PageResponse;
import org.springframework.data.domain.Sort;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * 用户仓储接口
 * 
 * @author 张翔
 * @date 2026-03-13
 */
public interface ISysUserRepository {

    Mono<SysUser> findByUsername(String username);

    Mono<SysUser> findByEmail(String email);

    Mono<SysUser> findById(Long id);

    Mono<SysUser> findByIdIncludingDeleted(Long id);

    Mono<SysUser> save(SysUser sysUser);

    Mono<Void> deleteById(Long id);

    Flux<SysUser> findAll();

    Flux<SysUser> findAll(Sort sort);

    Flux<SysUser> findByDeletedAtIsNull();

    Flux<SysUser> findByDeletedAtIsNull(Sort sort);

    Mono<Long> count();

    Mono<PageResponse<SysUser>> findByQueryWithPagination(SysUserQuery query, PageRequest pageRequest);

    Mono<Boolean> existsByUsername(String username);

    Mono<Boolean> existsByEmail(String email);

    Mono<Void> logicalDeleteById(Long id);

    Mono<Void> logicalDeleteByIds(List<Long> ids);

    Mono<Void> restoreById(Long id);

    Mono<Void> restoreByIds(List<Long> ids);

    Mono<Void> updateRoleIdToNullByRoleId(Long roleId);
}