From 8a025d3351fe4c6087c0dbf430624f4349e33d69 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 14 十一月 2024 08:59:08 +0800 Subject: [PATCH] 代码提交 --- xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java | 34 ++++++++++++++++++++++++++++------ 1 files changed, 28 insertions(+), 6 deletions(-) diff --git a/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java b/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java index 10608d9..2544863 100644 --- a/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java +++ b/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java @@ -1,15 +1,20 @@ package com.xinquan.meditation.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.xinquan.common.core.utils.DateUtils; import com.xinquan.common.core.utils.page.BeanUtils; -import com.xinquan.meditation.domain.Meditation; +import com.xinquan.meditation.api.domain.Meditation; import com.xinquan.meditation.domain.MeditationEveryday; +import com.xinquan.meditation.domain.MeditationMusic; import com.xinquan.meditation.domain.vo.ClientMeditationEverydayVO; import com.xinquan.meditation.domain.vo.ClientMeditationVO; import com.xinquan.meditation.mapper.MeditationEverydayMapper; import com.xinquan.meditation.mapper.MeditationMapper; +import com.xinquan.meditation.mapper.MeditationMusicMapper; import com.xinquan.meditation.service.MeditationEverydayService; -import java.time.LocalDateTime; + +import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -27,6 +32,8 @@ public class MeditationEverydayServiceImpl extends ServiceImpl<MeditationEverydayMapper, MeditationEveryday> implements MeditationEverydayService { private final MeditationMapper meditationMapper; + private final MeditationMusicMapper meditationMusicMapper; + /** * 查询每日冥想 @@ -35,13 +42,13 @@ */ @Override public ClientMeditationEverydayVO getTodayMeditation() { - ClientMeditationEverydayVO vo = null; + ClientMeditationEverydayVO vo = new ClientMeditationEverydayVO(); // 当前时间 - LocalDateTime now = LocalDateTime.now(); + String now = DateUtils.dateTimeNow("HH:mm:ss"); // 查询播放时间段在当前时间的每日冥想 Optional<MeditationEveryday> meditationEverydayOpt = this.lambdaQuery() - .le(MeditationEveryday::getStartPlayTime, now) - .ge(MeditationEveryday::getEndPlayTime, now) + .ge(MeditationEveryday::getStartPlayTime, now) + .le(MeditationEveryday::getEndPlayTime, now) .orderByDesc(MeditationEveryday::getUpdateTime) .last("limit 1").oneOpt(); if (!meditationEverydayOpt.isPresent()) { @@ -55,6 +62,9 @@ if (meditationEverydayOpt.isPresent()) { // 查询冥想详情 MeditationEveryday meditationEveryday = meditationEverydayOpt.get(); + + Long meditationId = meditationEveryday.getMeditationId(); + Meditation meditation = meditationMapper.selectById(meditationId); Optional<Meditation> meditationOpt = Optional.ofNullable( meditationMapper.selectById( meditationEveryday.getMeditationId())); @@ -64,8 +74,20 @@ ClientMeditationVO.class); vo = BeanUtils.copyBean(meditationEveryday, ClientMeditationEverydayVO.class); + clientMeditationVO.setBackgroundUrl(meditationOpt.get().getBackgroundUrl()); vo.setClientMeditationVO(clientMeditationVO); + if (meditation!=null){ + List<MeditationMusic> meditationId1 = meditationMusicMapper.selectList(new QueryWrapper<MeditationMusic>() + .eq("meditation_id", meditationId)); + int a= 0; + for (MeditationMusic meditationMusic : meditationId1) { + a += meditationMusic.getMusicSecond(); + } + vo.setTime(a); + } } + vo.setImageUrl(meditationEveryday.getImageUrl()); + } return vo; } -- Gitblit v1.7.1