package com.YuyeTech.HeartRate.game.userinfo.repository;

import com.YuyeTech.HeartRate.common.repository.CommonRepository;
import com.YuyeTech.HeartRate.game.userinfo.projo.UserInfo;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author:slambb
 * @date:2019/12/5
 */
public interface UserInfoRepository extends CommonRepository<UserInfo,String> {

    /**
     * 根据用户id 列表获取用户
     * @param userIdList
     * @return
     */
    @Query(value = "select * from user_info where `user_id` in :userIdList order by FIELD(`user_id`,:userIdList)" , nativeQuery = true)
    List<UserInfo> findByUserIdIn(List<String> userIdList);


    @Query(value = "select b from UserInfo b where (b.username like %:username%)")
    Page<UserInfo> searchByUsername(Pageable pageable, @Param("username") String username);
}
