当前位置:   article > 正文

Jpa之@Query的使用_jpa nativequery=true join

jpa nativequery=true join
  1. /**
  2. * 本周注册人数
  3. *
  4. * @return
  5. */
  6. @Query(nativeQuery = true, value = "SELECT COUNT(1) AS num FROM `user` WHERE YEARWEEK(DATE_FORMAT(create_time,'%Y-%m-%d')) = YEARWEEK(NOW())")
  7. Integer weekTotalNum();
  8. /**
  9. * 查询注册用户数
  10. *
  11. * @param startDay
  12. * @param limitDay
  13. */
  14. @Query(nativeQuery = true, value = "SELECT a.create_date AS createDate, IFNULL(b.num, 0) AS num FROM (SELECT @date \\:= DATE_SUB(@date, INTERVAL 1 DAY) AS create_date FROM (SELECT @date \\:= DATE_SUB(CURDATE(), INTERVAL ?1 DAY) FROM `user` LIMIT ?2) t) a LEFT JOIN (SELECT LEFT(create_time, 10) AS date_time, COUNT(1) AS num FROM `user` GROUP BY date_time) b ON a.create_date = b.date_time ORDER BY a.create_date DESC")
  15. List<Map<String, Object>> registerList(@Param("startDay") Integer startDay, @Param("limitDay") Integer limitDay);
  16. /**
  17. * 根据Kol的认证ID查询音乐人认证ID
  18. *
  19. * @param idList
  20. * @return
  21. */
  22. @Query(value = "SELECT uak.musicId FROM UserAuthKol uak WHERE uak.id IN ( :idList ) AND uak.musicId>0 ")
  23. List<Integer> musicIdList(@Param("idList") List<Integer> idList);
  24. /**
  25. * 批量审核同意
  26. *
  27. * @param idList
  28. * @param status
  29. */
  30. @Modifying
  31. @Transactional(rollbackFor = Exception.class)
  32. @Query(value = "UPDATE UserAuthKol uak SET uak.status =:status WHERE uak.id IN ( :idList )")
  33. void checkAgreeByIdList(@Param("idList") List<Integer> idList, @Param("status") Byte status);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/974883
推荐阅读
相关标签
  

闽ICP备14008679号