一.不带有动态条件的查询 分页的实现

实例代码:

controller:返回的是Page<>对象

  1. @Controller
  2. @RequestMapping(value = "/egg")
  3. public class EggController {
  4. @ResponseBody
  5. @RequestMapping(value = "/statisticsList")
  6. public Page<StatisticsDto> statisticsList(@RequestParam("actId") Long actId,HttpServletRequest request,
  7. Pageable pageable){
  8. Long entId = CasUtils.getEntId(request);
  9. return eggService.findStatisticsWithPage(entId,actId,pageable) ;
  10. }
  11. }

serviceImpl中的实现方法:这里需要查询出数据的数量total,以及查询到的数据list,最后new一个实现类 new PageImpl(list,pageable,total)

Page 的实现类是PageImpl          Pageable 的实现类是PagerRequest

  1. public Page<StatisticsDto> findStatisticsWithPage(Long entId, Long actId, Pageable pageable) {
  2. int total = wactPlayRecordDao.findDistinctPlayRecordTotal(entId, actId);
  3. //        List<String> openIdList = wactPlayRecordDao.findDistinctPlayRecordList(entId, actId);
  4. List<WactPlayRecord> wactPlayRecordList = wactPlayRecordDao.findDistinctPlayRecordList(entId,actId);
  5. List<StatisticsDto> statisticsDtoList = new ArrayList<>();
  6. if (wactPlayRecordList.size()>0){
  7. //            statisticsDtoList = new ArrayList<>(wactPlayRecordList.size());
  8. for (WactPlayRecord wactPlayRecord:wactPlayRecordList){
  9. StatisticsDto statisticsDto = new StatisticsDto();
  10. String openid = wactPlayRecord.getOpenid();
  11. Long playRecordId = wactPlayRecord.getId();
  12. Mpuser mpuser = mpuserDao.findMpUserByOpenId(openid);
  13. List<CustomerCollItemInfo> customerCollItemInfoList = customerCollitemInfoDao.findCustomerCollItemInfoByOpenId(openid,entId,actId,playRecordId);
  14. List<CustCollItemsInfoDto> custCollItemsInfoDtoList = new ArrayList<>();
  15. if (customerCollItemInfoList.size()>0){
  16. statisticsDto.setDetailIsShow("able");
  17. custCollItemsInfoDtoList = new ArrayList<>(customerCollItemInfoList.size());
  18. for (CustomerCollItemInfo customerCollItemInfo:customerCollItemInfoList){
  19. CustCollItemsInfoDto custCollItemsInfoDto = new CustCollItemsInfoDto(customerCollItemInfo);
  20. custCollItemsInfoDtoList.add(custCollItemsInfoDto);
  21. }
  22. }else{
  23. //已中奖但是未填写&&未中奖
  24. statisticsDto.setDetailIsShow("unable");
  25. }
  26. if (wactPlayRecord.getIsWin()==0){
  27. wactPlayRecord.setIsUse(2);
  28. }
  29. WactPlayRecordDto wactPlayRecordDto = new WactPlayRecordDto(wactPlayRecord);
  30. MpuserDto mpuserDto = null;
  31. if (mpuser!= null){
  32. mpuserDto = new MpuserDto(mpuser);
  33. }
  34. statisticsDto.setWactPlayRecordDto(wactPlayRecordDto);
  35. statisticsDto.setCustCollItemsInfoDtoList(custCollItemsInfoDtoList);
  36. statisticsDto.setMpuserDto(mpuserDto);
  37. statisticsDtoList.add(statisticsDto);
  38. }
  39. }
  40. return new PageImpl(statisticsDtoList,pageable,total);
  41. }

dao:需要继承JpaRepository

  1. public interface WactPlayRecordDao extends JpaRepository<WactPlayRecord, Long>{
  2. @Query("FROM WactPlayRecord w WHERE w.entId = :endId AND w.actId = :actId AND w.status = 1")
  3. List<WactPlayRecord> findDistinctPlayRecordList(@Param("endId") Long endId,@Param("actId") Long actId);
  4. <pre name="code" class="java">@Query("SELECT count(w.openid) FROM WactPlayRecord w WHERE w.entId = :endId AND w.actId = :actId AND w.status = 1")
  5. int findDistinctPlayRecordTotal(@Param("endId") Long endId,@Param("actId") Long actId);

}

二。带有查询条件,两种方法

方式1(使用与查询条件在一个实体类中).:

controller:同样是返回的Page<>对象 ,增加了表单提交的数据对象

  1. @Controller
  2. @RequestMapping("/news")
  3. public class NewsController {
  4. private NewsService newsService;
  5. private NewsCategoryService newsCategoryService;
  1. @RequestMapping("/list")
  2. @ResponseBody
  3. public Page<NewsDto> list(Pageable pageable, NewsCondition newsCondition) {
  4. Long id = AppUtils.getBean("loginInfo", LoginInfo.class).getEntId();
  5. newsCondition.setEntId(id);
  6. return newsService.find(newsCondition, pageable);
  7. }

serviceImpl

  1. @Service
  2. public class NewsServiceImpl implements NewsService {
  3. @Override
  4. @Transactional(readOnly = true)
  5. public Page<NewsDto> find(final NewsCondition condition, Pageable pageable) {
  6. Page<NewsEntity> page = newsDao.findAll(new Specification<NewsEntity>() {
  7. @Override
  8. public Predicate toPredicate(Root<NewsEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  9. List<Predicate> list = new ArrayList<>();
  10. list.add(cb.equal(root.get("entId").as(Long.class), condition.getEntId()));
  11. list.add(cb.equal(root.get("deleted").as(Boolean.class), false));
  12. Join<NewsEntity, NewsCategoryEntity> newsCategoryJoin = root.join("newsCategory");
  13. list.add(cb.equal(newsCategoryJoin.get("enable").as(Boolean.class), true));
  14. list.add(cb.equal(newsCategoryJoin.get("deleted").as(Boolean.class), false));
  15. if (condition.getCategoryId() != null) {
  16. list.add(cb.equal(newsCategoryJoin.get("id").as(Long.class), condition.getCategoryId()));
  17. }
  18. if (StringUtils.isNotBlank(condition.getTitle())) {
  19. list.add(cb.like(root.get("title").as(String.class), "%" + condition.getTitle() + "%"));
  20. }
  21. if (condition.getFromDate() != null) {
  22. list.add(cb.greaterThanOrEqualTo(root.get("createdDate").as(Date.class), DateUtils.getDateWithStartSecond(condition.getFromDate())));
  23. }
  24. if (condition.getToDate() != null) {
  25. list.add(cb.lessThanOrEqualTo(root.get("createdDate").as(Date.class), DateUtils.getDateWithLastSecond(condition.getToDate())));
  26. }
  27. query.orderBy(cb.desc(root.get("top")), cb.desc(root.get("id")));
  28. Predicate[] predicates = new Predicate[list.size()];
  29. predicates = list.toArray(predicates);
  30. return cb.and(predicates);
  31. }
  32. }, pageable);
  33. if (page.hasContent()) {
  34. List<NewsEntity> newsEntities = page.getContent();
  35. List<NewsDto> newsDtos = new ArrayList<>(newsEntities.size());
  36. List<Long> pids = new ArrayList<>();
  37. for (NewsEntity newsEntity : newsEntities) {
  38. if (newsEntity.getTitleImage() != null) {
  39. pids.add(newsEntity.getTitleImage());
  40. }
  41. }
  42. Map<Long, MediaFileEntity> map = null;
  43. if (CollectionUtils.isNotEmpty(pids)) {
  44. map = mediaFileDao.findWithMap(pids);
  45. }
  46. for (NewsEntity newsEntity : newsEntities) {
  47. newsDtos.add(new NewsDto(newsEntity, map != null ? map.get(newsEntity.getTitleImage()) : null));
  48. }
  49. return new PageImpl(newsDtos, pageable, page.getTotalElements());
  50. }
  51. return null;
  52. }
  53. }

dao:这里一定要继承JpasSpecificationExecutor,然后使用其中的findAll()方法,其中封装了分页方法,排序方法等

  1. public interface NewsDao extends JpaRepository<NewsEntity, Long>, JpaSpecificationExecutor<NewsEntity> {
  2. }

方式二(查询条件在不同表中的情形):底层DAO使用sql拼装,service中仍然使用new PageImpl的方法

controller

  1. @Controller
  2. @RequestMapping(value = "/egg")
  3. public class EggController {
  4. @ResponseBody
  5. @RequestMapping(value = "/statisticsList")
  6. public Page<StatisticsDto> statisticsList(@RequestParam("actId") Long actId,HttpServletRequest request,
  7. Pageable pageable,StatisticsCondition statisticsCondition){
  8. Long entId = CasUtils.getEntId(request);
  9. return eggService.findStatisticsWithPage(entId,actId,pageable,statisticsCondition) ;
  10. }

serviceImpl

  1. @Override
  2. @Transactional
  3. public Page<StatisticsDto> findStatisticsWithPage(Long entId, Long actId, Pageable pageable, StatisticsCondition statisticsCondition) {
  4. Long total = wactPlayRecordDao.findTotalByCondition(entId,actId,
  5. statisticsCondition.getParticipateBegin(),statisticsCondition.getParticipateEnd()
  6. ,statisticsCondition.getTelephone(),statisticsCondition.getIsWin(),statisticsCondition.getIsUse());
  7. List<StatisticsDto> statisticsDtoList = new ArrayList<>();
  8. if (total >0){
  9. List<Object[]> objectList = wactPlayRecordDao.findStatisticsByConditionWithPage(entId,actId,
  10. statisticsCondition.getParticipateBegin(),statisticsCondition.getParticipateEnd()
  11. ,statisticsCondition.getTelephone(),statisticsCondition.getIsWin(),statisticsCondition.getIsUse(),pageable);
  12. for (Object[] obj:objectList){
  13. StatisticsDto statisticsDto = new StatisticsDto();
  14. Long id = new BigInteger(obj[0].toString()).longValue();
  15. Integer isWin = new Short(obj[1].toString()).intValue();
  16. Integer isUse = new Short(obj[2].toString()).intValue();
  17. String createdDateStr = com.raipeng.micro.core.utils.DateUtils.format((Date)obj[4], com.raipeng.micro.core.utils.DateUtils.PATTERN_2);
  18. WactAwards wactAwards = new WactAwards();
  19. Long awardsId = new BigInteger(obj[5].toString()).longValue();
  20. if (awardsId != 0l){
  21. wactAwards = wactAwardsDao.findAwardByAwardId(awardsId);
  22. }
  23. if (isWin == 0){
  24. isUse = 2;
  25. }
  26. WactPlayRecordDto wactPlayRecordDto = new WactPlayRecordDto(id,isWin,isUse,(String)obj[3],wactAwards.getName(),wactAwards.getGradeName(),createdDateStr);
  27. String openid = (String)obj[3];
  28. Long playRecordId = wactPlayRecordDto.getId();
  29. List<CustomerCollItemInfo> customerCollItemInfoList = customerCollitemInfoDao.findCustomerCollItemInfoByPlayRecordId(playRecordId);
  30. List<CustCollItemsInfoDto> custCollItemsInfoDtoList = new ArrayList<>();
  31. if (customerCollItemInfoList.size()>0){
  32. statisticsDto.setDetailIsShow("able");
  33. custCollItemsInfoDtoList = new ArrayList<>(customerCollItemInfoList.size());
  34. for (CustomerCollItemInfo customerCollItemInfo:customerCollItemInfoList){
  35. //                        customerCollItemsIds +=customerCollItemInfo.getCustomerCollectitemsId()+"#";
  36. CustCollItemsInfoDto custCollItemsInfoDto = new CustCollItemsInfoDto(customerCollItemInfo);
  37. custCollItemsInfoDtoList.add(custCollItemsInfoDto);
  38. }
  39. }else{
  40. //已中奖但是未填写&&未中奖
  41. statisticsDto.setDetailIsShow("unable");
  42. }
  43. Object[] object = wactPlayRecordDao.findUserInfoByOpenId(openid);
  44. MpuserDto mpuserDto = new MpuserDto();
  45. if (object[1] != null){
  46. mpuserDto.setHeadImg((String)object[1]);
  47. }else if (object[3] != null){
  48. mpuserDto.setHeadImg((String)object[3]);
  49. }else {
  50. mpuserDto.setHeadImg("");
  51. }
  52. if (object[2] != null){
  53. mpuserDto.setNickName((String)object[2]);
  54. }else if (object[4] != null){
  55. mpuserDto.setNickName((String)object[4]);
  56. }else {
  57. mpuserDto.setNickName("");
  58. }
  59. if (wactPlayRecordDto.getIsWin()=="已中奖" && custCollItemsInfoDtoList.size()==0){
  60. wactPlayRecordDto.setIsUse("");
  61. }
  62. if (mpuserDto.getHeadImg()==""){
  63. statisticsDto.setHeadImg("unable");
  64. }else{
  65. statisticsDto.setHeadImg("able");
  66. }
  67. if (wactPlayRecordDto.getIsUse()=="已领取"){
  68. statisticsDto.setHaveReceived("able");
  69. }else {
  70. statisticsDto.setHaveReceived("unable");
  71. }
  72. statisticsDto.setWactPlayRecordDto(wactPlayRecordDto);
  73. statisticsDto.setCustCollItemsInfoDtoList(custCollItemsInfoDtoList);
  74. statisticsDto.setMpuserDto(mpuserDto);
  75. if (wactPlayRecordDto.getIsUse()=="未领取"){
  76. statisticsDto.setSetReceive("able");
  77. }else {
  78. statisticsDto.setSetReceive("unable");
  79. }
  80. String customerCollItemsIds = "";
  81. List<CustomerCollectItems> customerCollectItemsList = customerCollectItemsDao.findListByActivityId(actId);
  82. if (customerCollectItemsList != null && customerCollectItemsList.size()>0){
  83. for (CustomerCollectItems customerCollectItems:customerCollectItemsList){
  84. customerCollItemsIds += customerCollectItems.getCollectItemsId()+"#";
  85. }
  86. }
  87. statisticsDto.setCustomerCollectItemsIds(customerCollItemsIds);
  88. statisticsDtoList.add(statisticsDto);
  89. }
  90. }
  91. return new PageImpl<StatisticsDto>(statisticsDtoList,pageable,total);
  92. }

dao   daoplus  daoImpl(dao继承daoPlus,daoImpl实现daoPlus)

daoplus

  1. public interface WactPlayRecordPlusDao {
  2. Long findTotalByCondition(Long entId,Long actId,Date participateBegin,Date participateEnd,String telephone,Integer isWin,Integer isUse);
  3. List<Object[]> findStatisticsByConditionWithPage(Long entId, Long actId, Date participateBegin, Date participateEnd, String telephone, Integer isWin, Integer isUse,Pageable pageable);
  4. }

daoImpl

    1. public class WactPlayRecordDaoImpl implements WactPlayRecordPlusDao {
    2. @PersistenceContext
    3. private EntityManager entityManager;
    4. public void setEntityManager(EntityManager entityManager) {
    5. this.entityManager = entityManager;
    6. }
    7. @Override
    8. public Long findTotalByCondition(Long entId, Long actId, Date participateBegin, Date participateEnd, String telephone, Integer isWin, Integer isUse) {
    9. StringBuffer sql = null;
    10. if (telephone != null && !"".equals(telephone)){
    11. //            hql = new StringBuffer("SELECT w.id,w.isWin,w.isUse,W.openid " +//表没有关联所以不能使用面向对象语句的left outer join inner join 等
    12. //                    "FROM WactPlayRecord w inner join CustomerCollItemInfo c " +
    13. //                    "ON w.id = c.playRecordId" +
    14. //                    "WHERE w.entId = :entId AND w.actId = :actId AND w.status = 1 " +
    15. //                    "AND c.entId = :entId AND c.actId = :actId AND c.status = 1 And c.val = :telephone ");
    16. sql =new StringBuffer("SELECT count(p.id)" +
    17. "FROM rp_act_play_record p inner join rp_act_customer_collitem_info c " +
    18. "ON p.id = c.play_record_id " +
    19. "WHERE p.ent_id = :entId AND p.act_id = :actId AND p.status = 1 " +
    20. "AND c.ent_id = :entId AND c.act_id = :actId AND c.status = 1 And c.val = :telephone ");
    21. }else {
    22. //            hql = new StringBuffer("SELECT w.id,w.isWin,w.isUse,w.openid " +
    23. //                    "FROM WactPlayRecord w " +
    24. //                    "WHERE w.entId = :entId AND w.actId = :actId AND w.status = 1 " );
    25. sql = new StringBuffer("SELECT count(p.id) " +
    26. "FROM rp_act_play_record p " +
    27. "WHERE p.ent_id = :entId AND p.act_id = :actId AND p.status = 1 " );
    28. }
    29. if (participateBegin != null){
    30. sql.append("AND p.created_date >= :participateBegin ");
    31. }
    32. if (participateEnd != null){
    33. sql.append("AND p.created_date <= :participateEnd ");
    34. }
    35. if (isWin == 0){
    36. sql.append("AND p.is_win = 0 ");
    37. }else if (isWin ==1){
    38. sql.append("AND p.is_win = 1 ");
    39. }
    40. if (isUse == 0){
    41. sql.append("AND p.is_use = 0 ");
    42. }else if (isUse == 1){
    43. sql.append("AND p.is_use = 1 ");
    44. }
    45. sql.append("order by p.created_date ASC");
    46. Query query = entityManager.createNativeQuery(sql.toString());
    47. query.setParameter("entId", entId).setParameter("actId", actId);
    48. if (participateBegin != null){
    49. query.setParameter("participateBegin", participateBegin);
    50. }
    51. if (participateEnd != null){
    52. query.setParameter("participateEnd", participateEnd);
    53. }
    54. if (telephone != null && !"".equals(telephone)){
    55. query.setParameter("telephone",telephone);
    56. }
    57. Long total = new BigInteger(query.getSingleResult().toString()).longValue();
    58. return total;
    59. }
    60. @Override
    61. public List<Object[]> findStatisticsByConditionWithPage(Long entId, Long actId, Date participateBegin, Date participateEnd, String telephone, Integer isWin, Integer isUse,Pageable pageable) {
    62. StringBuffer sql = null;
    63. if (telephone != null && !"".equals(telephone)){
    64. //            hql = new StringBuffer("SELECT w.id,w.isWin,w.isUse,W.openid " +
    65. //                    "FROM WactPlayRecord w inner join CustomerCollItemInfo c " +
    66. //                    "ON w.id = c.playRecordId" +
    67. //                    "WHERE w.entId = :entId AND w.actId = :actId AND w.status = 1 " +
    68. //                    "AND c.entId = :entId AND c.actId = :actId AND c.status = 1 And c.val = :telephone ");
    69. sql =new StringBuffer("SELECT p.id,p.is_win,p.is_use,p.openid,p.created_date,p.awards_id " +
    70. "FROM rp_act_play_record p inner join rp_act_customer_collitem_info c " +
    71. "ON p.id = c.play_record_id " +
    72. "WHERE p.ent_id = :entId AND p.act_id = :actId AND p.status = 1 " +
    73. "AND c.ent_id = :entId AND c.act_id = :actId AND c.status = 1 And c.val = :telephone ");
    74. }else {
    75. //            hql = new StringBuffer("SELECT w.id,w.isWin,w.isUse,w.openid " +
    76. //                    "FROM WactPlayRecord w " +
    77. //                    "WHERE w.entId = :entId AND w.actId = :actId AND w.status = 1 " );
    78. sql = new StringBuffer("SELECT p.id,p.is_win,p.is_use,p.openid,p.created_date,p.awards_id " +
    79. "FROM rp_act_play_record p " +
    80. "WHERE p.ent_id = :entId AND p.act_id = :actId AND p.status = 1 " );
    81. }
    82. if (participateBegin != null){
    83. sql.append("AND p.created_date >= :participateBegin ");
    84. }
    85. if (participateEnd != null){
    86. sql.append("AND p.created_date <= :participateEnd ");
    87. }
    88. if (isWin == 0){
    89. sql.append("AND p.is_win = 0 ");
    90. }else if (isWin ==1){
    91. sql.append("AND p.is_win = 1 ");
    92. }
    93. if (isUse == 0){
    94. sql.append("AND p.is_use = 0 ");
    95. }else if (isUse == 1){
    96. sql.append("AND p.is_use = 1 ");
    97. }
    98. sql.append("order by p.created_date DESC");
    99. Query query = entityManager.createNativeQuery(sql.toString());
    100. query.setParameter("entId", entId).setParameter("actId", actId);
    101. if (participateBegin != null){
    102. query.setParameter("participateBegin", participateBegin);
    103. }
    104. if (participateEnd != null){
    105. query.setParameter("participateEnd", participateEnd);
    106. }
    107. if (telephone != null && !"".equals(telephone)){
    108. query.setParameter("telephone",telephone);
    109. }
    110. query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
    111. query.setMaxResults(pageable.getPageSize());
    112. List<Object[]> objectList = query.getResultList();
    113. return objectList;
    114. }

【spring data jpa】带有条件的查询后分页和不带条件查询后分页实现的更多相关文章

  1. springboot集成Spring Data JPA数据查询

    1.JPA介绍 JPA(Java Persistence API)是Sun官方提出的Java持久化规范.它为Java开发人员提供了一种对象/关联映射工具来管理Java应用中的关系数据.它的出现主要是为 ...

  2. 使用Spring Data JPA的Specification构建数据库查询

    Spring Data JPA最为优秀的特性就是可以通过自定义方法名称生成查询来轻松创建查询SQL.Spring Data JPA提供了一个Repository编程模型,最简单的方式就是通过扩展Jpa ...

  3. 转:使用 Spring Data JPA 简化 JPA 开发

    从一个简单的 JPA 示例开始 本文主要讲述 Spring Data JPA,但是为了不至于给 JPA 和 Spring 的初学者造成较大的学习曲线,我们首先从 JPA 开始,简单介绍一个 JPA 示 ...

  4. 了解 Spring Data JPA

    前言 自 JPA 伴随 Java EE 5 发布以来,受到了各大厂商及开源社区的追捧,各种商用的和开源的 JPA 框架如雨后春笋般出现,为开发者提供了丰富的选择.它一改之前 EJB 2.x 中实体 B ...

  5. Spring Data JPA

    转自: http://www.cnblogs.com/WangJinYang/p/4257383.html Spring 框架对 JPA 的支持 Spring 框架对 JPA 提供的支持主要体现在如下 ...

  6. 使用 Spring Data JPA 简化 JPA 开发

    从一个简单的 JPA 示例开始 本文主要讲述 Spring Data JPA,但是为了不至于给 JPA 和 Spring 的初学者造成较大的学习曲线,我们首先从 JPA 开始,简单介绍一个 JPA 示 ...

  7. Spring Data JPA 梳理 - 使用方法

    1.下载需要的包. 需要先 下载Spring Data JPA 的发布包(需要同时下载 Spring Data Commons 和 Spring Data JPA 两个发布包,Commons 是 Sp ...

  8. spring data jpa使用详解

    https://blog.csdn.net/liuchuanhong1/article/details/52042477 使用Spring data JPA开发已经有一段时间了,这期间学习了一些东西, ...

  9. Spring Data JPA基本了解

    前言 自 JPA 伴随 Java EE 5 发布以来,受到了各大厂商及开源社区的追捧,各种商用的和开源的 JPA 框架如雨后春笋般出现,为开发者提供了丰富的选择.它一改之前 EJB 2.x 中实体 B ...

  10. SpringBoot学习笔记:Spring Data Jpa的使用

    更多请关注公众号 Spring Data Jpa 简介 JPA JPA(Java Persistence API)意即Java持久化API,是Sun官方在JDK5.0后提出的Java持久化规范(JSR ...

随机推荐

  1. Shell 脚本中 '$' 符号的多种用法

    通常情况下,在工作中用的最多的有如下几项: $0:Shell 的命令本身 $1 到 $9:表示 Shell 的第几个参数 $? :显示最后命令的执行情况 $#:传递到脚本的参数个数 $$:脚本运行的当 ...

  2. 【使用篇二】SpringBoot整合mybatis(7)

    说明:使用SpringBoot+Mybatis+Jsp实现简单的用户增删查改 #用户表 DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `) NO ...

  3. 学习:逆向PUSH越界/INT 68/反调试导致的程序

    自己根据shark恒老师的分析,总结一下: 一般反调试自动关闭程序利用的函数有: 1.CreateToolhelp32Snapshot 2.FindWindow 3.ExitProcess 4.Pos ...

  4. postgres判断字符串是否为时间,数字

    时间判断函数定义: -- FUNCTION: public.isdate(character varying) -- DROP FUNCTION public.isdate(character var ...

  5. [LeetCode] 878. Nth Magical Number 第N个神奇数字

    A positive integer is magical if it is divisible by either A or B. Return the N-th magical number.  ...

  6. Note | PyTorch官方教程学习笔记

    目录 1. 快速入门PYTORCH 1.1. 什么是PyTorch 1.1.1. 基础概念 1.1.2. 与NumPy之间的桥梁 1.2. Autograd: Automatic Differenti ...

  7. 基于Redis实现分布式定时任务调度

    项目开发过程中,难免会有许多定时任务的需求进来.如果项目中还没有引入quarzt框架的情况下,我们通常会使用Spring的@Schedule(cron="* * * * *")注解 ...

  8. 推荐一款运动步行App爱步行

    推荐一款运动步行App爱步行 1 介绍 爱步行,是一款倡导健步运动.绿色生活.提升散步乐趣的APP,让大众在享受运动的同时,让用户的每一步都能产生价值.爱步行以步数为基础,用户在每天的行走过程中,可以 ...

  9. 2条最佳实践App疯狂增长逻辑

    2条最佳实践App疯狂增长逻辑 1.不断打造和强化产品的不可或缺属性 产品的核心价值是什么?对你的客户来言,为什么是你? 2.等待“阿哈时刻” 进入快速推广 用户使用产品眼前一亮的时刻,是用户真正发现 ...

  10. SpringBoot+EventBus使用教程(一)

    一.简介 EventBus是一个基于发布订阅的事件总线,在Java和Android里都可以使用. 二.使用 1.引入pom <dependency> <groupId>org. ...