package com.cirle.scientific.dao;

import com.cirle.scientific.po.QkjMemberTaskInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface QkjMemberTaskInfoDao  extends PagingAndSortingRepository<QkjMemberTaskInfo, Long>, JpaSpecificationExecutor<QkjMemberTaskInfo> {


    @Query(value = "SELECT * FROM qkj_member_task_info WHERE mem_card = ?1 " ,nativeQuery = true)
    public QkjMemberTaskInfo findByMemCard (String memCard);

//    @Query(value = "SELECT * FROM qkj_member_task_info order by mem_total_points desc" ,nativeQuery = true)
//    List<QkjMemberTaskInfo> findUserjfRanking();

    @Query(value = "SELECT a.* FROM qkj_member_task_info a left join qkj_member b on a.mem_card = b.mem_card " +
            "where b.mem_nickname is not null order by a.mem_residual_points desc ,b.mem_register_time asc limit 50" ,nativeQuery = true)
    List<QkjMemberTaskInfo> findUserjfRanking();

    @Query(value = "SELECT * FROM qkj_member_task_info order by mem_residual_points desc limit 50" ,nativeQuery = true)
    List<QkjMemberTaskInfo> findUserjfRankingNew();
}
