package com.eshore.gringotts.web.domain.repository;

import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.entity.User;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.stereotype.Repository;

/**
 * User操作
 *
 * @author lanyuanxiaoyao
 * @date 2024-11-14
 */
@SuppressWarnings("NullableProblems")
@Repository
public interface UserRepository extends SimpleRepository<User, Long> {
    @Override
    @EntityGraph(value = "user.list", type = EntityGraph.EntityGraphType.FETCH)
    List<User> findAll();

    Boolean existsByUsername(String username);

    @EntityGraph(value = "user.detail", type = EntityGraph.EntityGraphType.FETCH)
    Optional<User> findByUsername(String username);
}
