|
@@ -59,40 +59,45 @@ class WeeklyPlanService {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- fun mapCurrentWeek(start: Long, self: Boolean = true): Map<String, List<WeeklyPlan>> {
|
|
|
- val list = findCurrentWeek(start, self)
|
|
|
- list.sortedBy { it.startTime!! }
|
|
|
- val result = LinkedHashMap<String,List<WeeklyPlan>>()
|
|
|
- return result
|
|
|
- }
|
|
|
+ fun mapCurrentMonth(start: Long, userId: Long?, self: Boolean = true): Map<String, List<WeeklyPlan>> {
|
|
|
+ val list = findCurrentMoon(start, userId, self)
|
|
|
+ val planList = mutableListOf<WeeklyPlan>()
|
|
|
+ for (plan in list) {
|
|
|
+ plan.dayOfMonth = DateUtil.getDay(plan.startTime)
|
|
|
+ planList.add(plan)
|
|
|
+ }
|
|
|
+ val map = planList.groupBy { it.dayOfMonth }
|
|
|
|
|
|
- fun mapCurrentMonth(start: Long, self: Boolean = true):Map<String,List<WeeklyPlan>>{
|
|
|
- val result = LinkedHashMap<String,List<WeeklyPlan>>()
|
|
|
+ val monthDay = DateUtil.getMonthDay(Date(start))
|
|
|
+ val result = LinkedHashMap<String, List<WeeklyPlan>>()
|
|
|
+ for (i in 1..monthDay) {
|
|
|
+ result[i.toString()] = map.getOrDefault(i, arrayListOf())
|
|
|
+ }
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
- @Transactional(readOnly = true)
|
|
|
- fun findCurrentWeek(start: Long, self: Boolean): List<WeeklyPlan> {
|
|
|
- val time = Date(start)
|
|
|
- val first = DateUtil.getFirstDayOfWeek(time)
|
|
|
- val last = DateUtil.getLastDayOfWeek(time)
|
|
|
- if (!self) {
|
|
|
- return weeklyPlanRepo.findAllByStartTimeBetween(first, last)
|
|
|
- }
|
|
|
- val userId = userService.currentUserId()
|
|
|
- return weeklyPlanRepo.findAllByUserIdAndStartTimeBetween(userId!!, first, last)
|
|
|
- }
|
|
|
+// @Transactional(readOnly = true)
|
|
|
+// fun findCurrentWeek(start: Long, self: Boolean): List<WeeklyPlan> {
|
|
|
+// val time = Date(start)
|
|
|
+// val first = DateUtil.getFirstDayOfWeek(time)
|
|
|
+// val last = DateUtil.getLastDayOfWeek(time)
|
|
|
+// if (!self) {
|
|
|
+// return weeklyPlanRepo.findAllByStartTimeBetween(first, last)
|
|
|
+// }
|
|
|
+// val userId = userService.currentUserId()
|
|
|
+// return weeklyPlanRepo.findAllByUserIdAndStartTimeBetween(userId!!, first, last)
|
|
|
+// }
|
|
|
|
|
|
@Transactional(readOnly = true)
|
|
|
- fun findCurrentMoon(start: Long, self: Boolean = true): List<WeeklyPlan> {
|
|
|
+ fun findCurrentMoon(start: Long, userId: Long?, self: Boolean = true): List<WeeklyPlan> {
|
|
|
+ val id = userId ?: userService.currentUserId()
|
|
|
val time = Date(start)
|
|
|
val first = DateUtil.getFirstDayOfMonth(time)
|
|
|
val last = DateUtil.getLastDayOfMonth(time)
|
|
|
if (!self) {
|
|
|
return weeklyPlanRepo.findAllByStartTimeBetween(first, last)
|
|
|
}
|
|
|
- val userId = userService.currentUserId()
|
|
|
- return weeklyPlanRepo.findAllByUserIdAndStartTimeBetween(userId!!, first, last)
|
|
|
+ return weeklyPlanRepo.findAllByUserIdAndStartTimeBetween(id!!, first, last)
|
|
|
}
|
|
|
|
|
|
}
|