| | |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.domain.HomeBackgroundMusic; |
| | | import com.xinquan.meditation.domain.MeditationHall; |
| | | import com.xinquan.meditation.domain.vo.ClientHomeBackgroundMusicVO; |
| | | import com.xinquan.meditation.domain.vo.ClientMeditationAndCateVO; |
| | | import com.xinquan.meditation.domain.vo.ClientMeditationCategoryVO; |
| | |
| | | import com.xinquan.meditation.service.MeditationService; |
| | | import com.xinquan.system.api.RemoteHotWordsService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | |
| | | private final RemoteHotWordsService remoteHotWordsService; |
| | | private final MeditationQuestionService meditationQuestionService; |
| | | |
| | | @PostMapping("/listHomeBackgroundMusic") |
| | | @ApiOperation(value = "背景音乐列表查询-分页", notes = "管理后台-首页背景音乐管理") |
| | | @GetMapping("/listHomeBackgroundMusic") |
| | | @ApiOperation(value = "背景音乐列表查询-分页", tags = "管理后台-首页背景音乐管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true)}) |
| | | public R<PageDTO<HomeBackgroundMusic>> listHomeBackgroundMusic(@RequestParam Integer pageCurr, @RequestParam Integer pageSize) { |
| | | PageDTO<HomeBackgroundMusic> pageDTO = PageDTO.empty(0L, 0L); |
| | | |
| | | // 查询 |
| | | Page<HomeBackgroundMusic> page = homeBackgroundMusicService.lambdaQuery() |
| | | .orderByDesc(HomeBackgroundMusic::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | // 如果没有查到数据直接返回 |
| | | if (Optional.ofNullable(page.getRecords()).isPresent()) { |
| | | return R.ok(pageDTO); |
| | | if (page.getRecords().isEmpty()) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | // 将实体类转换为VO |
| | | pageDTO = PageDTO.of(page, HomeBackgroundMusic.class); |
| | | for (HomeBackgroundMusic homeBackgroundMusic : pageDTO.getList()) { |
| | | for (HomeBackgroundMusic homeBackgroundMusic : page.getRecords()) { |
| | | homeBackgroundMusic.setUid(homeBackgroundMusic.getId() + ""); |
| | | } |
| | | return R.ok(pageDTO); |
| | | return R.ok(PageDTO.of(page, HomeBackgroundMusic.class)); |
| | | } |
| | | |
| | | @PostMapping("/addHomeBackgroundMusic") |
| | | @ApiOperation(value = "新增背景", notes = "管理后台-首页背景音乐管理") |
| | | @ApiOperation(value = "新增背景", tags = "管理后台-首页背景音乐管理") |
| | | public R addHomeBackgroundMusic(@RequestBody HomeBackgroundMusic homeBackgroundMusic) { |
| | | return R.ok(homeBackgroundMusicService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailHomeBackgroundMusic") |
| | | @ApiOperation(value = "查看详情", notes = "管理后台-首页背景音乐管理") |
| | | public R detailHomeBackgroundMusic(String uid) { |
| | | @ApiOperation(value = "查看详情", tags = "管理后台-首页背景音乐管理") |
| | | public R<HomeBackgroundMusic> detailHomeBackgroundMusic(String uid) { |
| | | return R.ok(homeBackgroundMusicService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateHomeBackgroundMusic") |
| | | @ApiOperation(value = "修改背景", notes = "管理后台-首页背景音乐管理") |
| | | @ApiOperation(value = "修改背景", tags = "管理后台-首页背景音乐管理") |
| | | public R updateHomeBackgroundMusic(@RequestBody HomeBackgroundMusic homeBackgroundMusic) { |
| | | return R.ok(homeBackgroundMusicService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteHomeBackgroundMusic") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-首页背景音乐管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-首页背景音乐管理") |
| | | public R deleteHomeBackgroundMusic(String ids) { |
| | | return R.ok(homeBackgroundMusicService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(homeBackgroundMusicService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | /** |
| | | * 获取首页背景音乐列表 |
| | |
| | | }) |
| | | public R<PageDTO<ClientMeditationVO>> search(@RequestParam String condition, |
| | | @RequestParam Integer pageCurr, @RequestParam Integer pageSize) { |
| | | |
| | | |
| | | return R.ok(meditationService.search(condition, pageCurr, pageSize)); |
| | | } |
| | | |
| | |
| | | @ApiOperation("获取冥想音频详情") |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true) |
| | | public R<ClientMeditationDetailsVO> getMeditationDetails(@RequestParam("id") Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | return R.ok(meditationService.getMeditationDetails(id)); |
| | | } |
| | | @GetMapping("/getMeditationDetailsShare") |
| | | @ApiOperation(value = "获取冥想音频详情",tags = "H5分享") |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true) |
| | | public R<ClientMeditationDetailsVO> getMeditationDetailsShare(Long id) { |
| | | return R.ok(meditationService.getMeditationDetails1(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "收藏/取消收藏") |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true) |
| | | public R<?> favorite(@RequestParam("id") Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | meditationService.favorite(id); |
| | | return R.ok(); |
| | | } |
| | |
| | | public R<PageDTO<ClientMeditationQuestionVO>> getMeditationQuestionPage( |
| | | @RequestParam("id") Long id, @RequestParam("pageCurr") Integer pageCurr, |
| | | @RequestParam("pageSize") Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | return R.ok(meditationService.getMeditationQuestionPage(id, pageCurr, pageSize)); |
| | | } |
| | | |
| | | @GetMapping("/getMeditationQuestionPageShare") |
| | | @ApiOperation(value = "获取冥想音频提问列表-分页",tags = "H5分享") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<ClientMeditationQuestionVO>> getMeditationQuestionPageShare( |
| | | @RequestParam("id") Long id, @RequestParam("pageCurr") Integer pageCurr, |
| | | @RequestParam("pageSize") Integer pageSize) { |
| | | return R.ok(meditationService.getMeditationQuestionPageShare(id, pageCurr, pageSize)); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/addQuestion") |
| | | @ApiOperation(value = "发布提问") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "meditationId", value = "冥想音频id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "content", value = "提问内容", dataType = "String", required = true), |
| | | }) |
| | | public R addQuestion(Long meditationId,String content) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | MeditationQuestion meditationQuestion = new MeditationQuestion(); |
| | | meditationQuestion.setMeditationId(meditationId); |
| | | meditationQuestion.setLikeCount(0); |
| | | meditationQuestion.setFavorite(2); |
| | | meditationQuestion.setContent(content); |
| | | meditationQuestion.setPublishTime(LocalDateTime.now()); |
| | | meditationQuestion.setAppUserId(userId); |
| | | meditationQuestion.setShowFlag(1); |
| | | meditationQuestion.setReportStatus(1); |
| | | meditationQuestionService.save(meditationQuestion); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 举报提问 |
| | | * |