|
@ -50,24 +50,49 @@ public class ActivityServiceImpl implements ActivityService { |
|
|
} |
|
|
} |
|
|
@Cacheable(key="#root.method.name + ':'+ #pageNum + '-' + #pageSize + '-' + #activity.hashCode() ") |
|
|
@Cacheable(key="#root.method.name + ':'+ #pageNum + '-' + #pageSize + '-' + #activity.hashCode() ") |
|
|
@Override |
|
|
@Override |
|
|
|
|
|
public PageInfo<Activity> searchForPage(Integer pageNum, Integer pageSize, Activity activity) { |
|
|
|
|
|
// PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
|
// List<Activity> list = activityMapper.select(activity); |
|
|
|
|
|
// return new PageInfo<>(list); |
|
|
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
|
List<Activity> list = activityMapper.select(activity); |
|
|
|
|
|
Date nowDate = new Date(); |
|
|
|
|
|
list.forEach(activity1 -> { |
|
|
|
|
|
// 假设 getStartTime() 和 getEndTime() 返回的是 java.util.Date 类型 |
|
|
|
|
|
Date startTime = activity1.getStartTime(); |
|
|
|
|
|
Date endTime = activity1.getEndTime(); |
|
|
|
|
|
|
|
|
|
|
|
// 使用 Date 类的 before 和 after 方法进行比较 |
|
|
|
|
|
if (nowDate.before(startTime)) { |
|
|
|
|
|
activity1.setStatus(0); // 设置状态为 0 |
|
|
|
|
|
} else if (nowDate.after(endTime)) { |
|
|
|
|
|
activity1.setStatus(2); // 设置状态为 2 |
|
|
|
|
|
} else { |
|
|
|
|
|
activity1.setStatus(1); // 设置状态为 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 保存修改后的对象 |
|
|
|
|
|
activityMapper.edit(activity1); |
|
|
|
|
|
}); |
|
|
|
|
|
return new PageInfo<>(list); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Cacheable(key="#root.method.name + ':'+ #pageNum + '-' + #pageSize + '-' + #activity.hashCode() ") |
|
|
|
|
|
// @Override |
|
|
// public PageInfo<Activity> searchForPage(Integer pageNum, Integer pageSize, Activity activity) { |
|
|
// public PageInfo<Activity> searchForPage(Integer pageNum, Integer pageSize, Activity activity) { |
|
|
//// PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
|
//// List<Activity> list = activityMapper.select(activity); |
|
|
|
|
|
//// return new PageInfo<>(list); |
|
|
|
|
|
// |
|
|
|
|
|
// PageHelper.startPage(pageNum, pageSize); |
|
|
// PageHelper.startPage(pageNum, pageSize); |
|
|
// List<Activity> list = activityMapper.select(activity); |
|
|
// List<Activity> list = activityMapper.select(activity); |
|
|
// Date nowDate = new Date(); |
|
|
|
|
|
// list.forEach(activity1 -> { |
|
|
|
|
|
// // 假设 getStartTime() 和 getEndTime() 返回的是 java.util.Date 类型 |
|
|
|
|
|
|
|
|
// LocalDateTime nowDate = LocalDateTime.now(); |
|
|
|
|
|
// |
|
|
|
|
|
// for (Activity activity1 : list) { |
|
|
// Date startTime = activity1.getStartTime(); |
|
|
// Date startTime = activity1.getStartTime(); |
|
|
// Date endTime = activity1.getEndTime(); |
|
|
// Date endTime = activity1.getEndTime(); |
|
|
// |
|
|
// |
|
|
// // 使用 Date 类的 before 和 after 方法进行比较 |
|
|
|
|
|
// if (nowDate.before(startTime)) { |
|
|
|
|
|
|
|
|
// if (nowDate.isBefore(startTime)) { |
|
|
// activity1.setStatus(0); // 设置状态为 0 |
|
|
// activity1.setStatus(0); // 设置状态为 0 |
|
|
// } else if (nowDate.after(endTime)) { |
|
|
|
|
|
|
|
|
// } else if (nowDate.isAfter(endTime)) { |
|
|
// activity1.setStatus(2); // 设置状态为 2 |
|
|
// activity1.setStatus(2); // 设置状态为 2 |
|
|
// } else { |
|
|
// } else { |
|
|
// activity1.setStatus(1); // 设置状态为 1 |
|
|
// activity1.setStatus(1); // 设置状态为 1 |
|
@ -75,32 +100,9 @@ public class ActivityServiceImpl implements ActivityService { |
|
|
// |
|
|
// |
|
|
// // 保存修改后的对象 |
|
|
// // 保存修改后的对象 |
|
|
// activityMapper.edit(activity1); |
|
|
// activityMapper.edit(activity1); |
|
|
// }); |
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// // 返回分页信息 |
|
|
|
|
|
// return new PageInfo<>(list); |
|
|
// } |
|
|
// } |
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
public PageInfo<Activity> searchForPage(Integer pageNum, Integer pageSize, Activity activity) { |
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
|
List<Activity> list = activityMapper.select(activity); |
|
|
|
|
|
LocalDateTime nowDate = LocalDateTime.now(); |
|
|
|
|
|
|
|
|
|
|
|
for (Activity activity1 : list) { |
|
|
|
|
|
LocalDateTime startTime = activity1.getStartTime(); |
|
|
|
|
|
LocalDateTime endTime = activity1.getEndTime(); |
|
|
|
|
|
|
|
|
|
|
|
if (nowDate.isBefore(startTime)) { |
|
|
|
|
|
activity1.setStatus(0); // 设置状态为 0 |
|
|
|
|
|
} else if (nowDate.isAfter(endTime)) { |
|
|
|
|
|
activity1.setStatus(2); // 设置状态为 2 |
|
|
|
|
|
} else { |
|
|
|
|
|
activity1.setStatus(1); // 设置状态为 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 保存修改后的对象 |
|
|
|
|
|
activityMapper.edit(activity1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 返回分页信息 |
|
|
|
|
|
return new PageInfo<>(list); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//} |