package com.psg.dlsysinfo.dl_sysinfo_server.repository;

import com.psg.dlsysinfo.dl_sysinfo_server.entity.UserAuth;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface UserAuthRepository extends JpaRepository<UserAuth, Long> {

    @Query("SELECT u FROM UserAuth u JOIN FETCH u.client WHERE u.username = :username")
    Optional<UserAuth> findByUsernameWithClient(@Param("username") String username);

    Optional<UserAuth> findByUsername(String username); // still used by Spring Security
}
