package com.dtok.repository;

import com.dtok.entity.Account;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Description
 * @Author C.J
 * @Date 2024-03-08
 */

public interface AccountRepository extends JpaRepository<Account, Integer>, JpaSpecificationExecutor<Account> {

    Account findUserByUsernameAndPassword(String code, String password);

    Account findUserByUsername(String code);

    Account findFirstById(Integer id);
    Account getFirstByUsername(String code);

    @Query(value = "select * from acc_account  where binary username = :username", nativeQuery = true)
    Account getUserLoginEntity(@Param("username") String code);

    List<Account> findUsersByRoleCode(String roleCode);


}
