111
wang-hao-jie
2022-08-25 d90da0759bd93c7f429f6a20bc835782ad927c02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.boying.dao;
 
import com.boying.common.BaseDao;
import com.boying.entity.StudyRecord;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
 
import java.util.Date;
import java.util.List;
 
@Repository("studyRecordDao")
public interface StudyRecordDao extends BaseDao<StudyRecord, Long>{
    @Query(value = "select count(DISTINCT studyId) from StudyRecord where type=:type and userId=:userId")
    int countByType(int type,Long userId);
 
    @Query(value = "select sum(time) from StudyRecord where userId=:userId")
    Integer sumByTime(Long userId);
 
    @Query(value = "select sum(xueShi) from StudyRecord where userId=:userId and createTime >:date")
    Integer sumByTime2(Long userId, Date date);
 
    @Query(nativeQuery = true,value = "select sum(xueShi) as t,userName from studyRecord group by userName order by t desc LIMIT 3")
    List<Object> paiMing();
 
    @Query(value = "from StudyRecord where userId=:userId and studyId=:id")
    StudyRecord findByUserIdAndStudyId(Long userId, Long id);
 
    @Query(value = "select sum(xueShi) from StudyRecord where userId=:userId")
    Integer sumByXueShi(Long userId);
 
    @Query(value = "select sum(time) from StudyRecord where userId=:userId and createTime >:date")
    Integer sumByTime22(Long userId, Date d);
}