无关风月
2025-04-03 b01f752252eaadd1fa31eda6a9ad43146660b721
xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/controller/client/ClientHomeController.java
@@ -12,6 +12,7 @@
import com.xinquan.common.security.service.TokenService;
import com.xinquan.meditation.domain.HomeBackgroundMusic;
import com.xinquan.meditation.domain.HomeBackgroundMusicUser;
import com.xinquan.meditation.domain.MeditationMusic;
import com.xinquan.meditation.domain.vo.ClientHomeBackgroundMusicVO;
import com.xinquan.meditation.domain.vo.ClientMeditationAndCateVO;
import com.xinquan.meditation.domain.vo.ClientMeditationCategoryVO;
@@ -57,6 +58,8 @@
    private final MeditationService meditationService;
    private final MeditationCategoryService meditationCategoryService;
    private final MeditationEverydayService meditationEverydayService;
    @Resource
    private  RemoteHotWordsService remoteHotWordsService;
    private final MeditationQuestionService meditationQuestionService;
@@ -64,6 +67,19 @@
    private HomeBackgroundMusicUserService homeBackgroundMusicUserService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private MeditationMusicService meditationMusicService;
    @PostMapping("/testObs")
    @ApiOperation(value = "OBS", tags = "OBS")
    public R testObs() {
        List<MeditationMusic> list = meditationMusicService.list();
        for (MeditationMusic meditationMusic : list) {
            String replace = meditationMusic.getMusicUrl().replace("https://xqgwzh.obs.cn-south-1.myhuaweicloud.com", "http://obs.xq.xqzhihui.com");
            meditationMusic.setMusicUrl(replace);
        }
        meditationMusicService.updateBatchById(list);
        return R.ok();
    }
    // 新增需求 用户注册默认给一个背景音频设置
    @GetMapping("/addHomeBackgroundMusicDefault/{id}")
    public R addHomeBackgroundMusicDefault(@PathVariable("id") Long id) {
@@ -167,18 +183,38 @@
    public R<ClientHomeBackgroundMusicVO> getHomeBackgroundMusicByUserId() {
        if (tokenService.getLoginUser()==null){
            // 游客登录模式 不要返回登录失效 返回空即可
            return R.ok(new ClientHomeBackgroundMusicVO());
            List<HomeBackgroundMusic> list = homeBackgroundMusicService.list();
            if (list.isEmpty()){
                return R.ok(new ClientHomeBackgroundMusicVO());
            }
            ClientHomeBackgroundMusicVO clientHomeBackgroundMusicVO = new ClientHomeBackgroundMusicVO();
            BeanUtils.copyProperties(list.get(0), clientHomeBackgroundMusicVO);
            return R.ok(clientHomeBackgroundMusicVO);
        }
        HomeBackgroundMusicUser homeBackgroundMusicUser = homeBackgroundMusicUserService.lambdaQuery()
                .eq(HomeBackgroundMusicUser::getAppUserId, tokenService.getLoginUser().getAppUserId())
                .one();
        if (homeBackgroundMusicUser==null){
            return R.ok(new ClientHomeBackgroundMusicVO());
            List<HomeBackgroundMusic> list = homeBackgroundMusicService.list();
            if (list.isEmpty()){
                return R.ok(new ClientHomeBackgroundMusicVO());
            }
            ClientHomeBackgroundMusicVO clientHomeBackgroundMusicVO = new ClientHomeBackgroundMusicVO();
            BeanUtils.copyProperties(list.get(0), clientHomeBackgroundMusicVO);
            return R.ok(clientHomeBackgroundMusicVO);
        }
        HomeBackgroundMusic homeBackgroundMusic = homeBackgroundMusicService.lambdaQuery()
                .eq(HomeBackgroundMusic::getId, homeBackgroundMusicUser.getHomeBackgroundMusicId())
                .one();
        if (homeBackgroundMusic==null)return R.ok(new ClientHomeBackgroundMusicVO());
        if (homeBackgroundMusic==null){
            List<HomeBackgroundMusic> list = homeBackgroundMusicService.list();
            if (list.isEmpty()){
                return R.ok(new ClientHomeBackgroundMusicVO());
            }
            ClientHomeBackgroundMusicVO clientHomeBackgroundMusicVO = new ClientHomeBackgroundMusicVO();
            BeanUtils.copyProperties(list.get(0), clientHomeBackgroundMusicVO);
            return R.ok(clientHomeBackgroundMusicVO);
        }
        ClientHomeBackgroundMusicVO clientHomeBackgroundMusicVO = new ClientHomeBackgroundMusicVO();
        BeanUtils.copyProperties(homeBackgroundMusic, clientHomeBackgroundMusicVO);
        return R.ok(clientHomeBackgroundMusicVO);