| | |
| | | package com.xinquan.meditation.controller.client; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.domain.dto.MeditationDTO; |
| | | import com.xinquan.meditation.api.domain.dto.UserAnswerDTO; |
| | | import com.xinquan.meditation.domain.*; |
| | | import com.xinquan.meditation.domain.export.MeditationExport; |
| | | import com.xinquan.meditation.service.*; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.system.api.domain.NoticeRecord; |
| | | import com.xinquan.system.api.domain.Tag; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | private MeditationCategoryService meditationCategoryService; |
| | | @Autowired |
| | | private MeditationQuestionService meditationQuestionService; |
| | | |
| | | @Autowired |
| | | private MeditationEverydayService meditationEverydayService; |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @GetMapping("/getMeditationCount") |
| | | public R<String> getMeditationCount() { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | List<Meditation> list = meditationService.lambdaQuery().eq(BaseModel::getDelFlag, 0) |
| | | .list(); |
| | | stringBuilder.append(list.size()).append(","); |
| | | List<Meditation> collect1 = list.stream().filter(t -> t.getChargeType() == 1).collect(Collectors.toList()); |
| | | List<Meditation> collect2 = list.stream().filter(t -> t.getChargeType() == 2).collect(Collectors.toList()); |
| | | List<Meditation> collect3 = list.stream().filter(t -> t.getChargeType() == 3).collect(Collectors.toList()); |
| | | stringBuilder.append(collect1.size()).append(","); |
| | | stringBuilder.append(collect2.size()).append(","); |
| | | stringBuilder.append(collect3.size()).append(","); |
| | | return R.ok(stringBuilder.toString()); |
| | | } |
| | | @PostMapping("/confirmOrder") |
| | | @ApiOperation(value = "确认订单页面",tags = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "冥想id", name = "meditationId", required = true, dataType = "Long") |
| | | }) |
| | | public R<Meditation> studyPageByChapterId(@RequestParam(value = "meditationId")Long meditationId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userid = loginUser.getUserid(); |
| | | Meditation byId = meditationService.getById(meditationId); |
| | | AppUser data = remoteAppUserService.getAppUserById(userid + "").getData(); |
| | | byId.setBalance(data.getBalance()); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/successOrder") |
| | | @ApiOperation(value = "支付成功页面") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "冥想id", name = "meditationId", required = true, dataType = "Long") |
| | | }) |
| | | public R<List<Meditation>> successOrder(@RequestParam(value = "meditationId")Long meditationId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Meditation byId = meditationService.getById(meditationId); |
| | | List<Meditation> list = meditationService.lambdaQuery().eq(Meditation::getCateId, byId.getCateId()) |
| | | .list(); |
| | | |
| | | List<Meditation> courses = new ArrayList<>(); |
| | | |
| | | // 如果list集合数据大于2 随机获取两个返回 |
| | | if (CollUtils.isNotEmpty(list) && list.size() > 4) { |
| | | int size = list.size(); |
| | | int index = (int) (Math.random() * size); |
| | | for (int i = 0; i < 4; i++) { |
| | | courses.add(list.get(index)); |
| | | } |
| | | return R.ok(courses); |
| | | }else { |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 远程调用 通过疗愈名字查询疗愈ids |
| | |
| | | .collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | @GetMapping("/getMeditationById/{pageCurr}/{pageSize}") |
| | | public R<Page<Meditation>> getMeditationById(@PathVariable("pageCurr") Integer pageCurr,@PathVariable("pageSize") Integer pageSize) |
| | | @GetMapping("/getMeditationById/{pageCurr}/{pageSize}/{id}") |
| | | public R<Page<Meditation>> getMeditationById(@PathVariable("pageCurr") Integer pageCurr |
| | | ,@PathVariable("pageSize") Integer pageSize,@PathVariable("id")Long id) |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | List<Long> collect = meditationUserFavoriteService |
| | | .lambdaQuery() |
| | | .eq(MeditationUserFavorite::getAppUserId, userId).list().stream() |
| | | .eq(MeditationUserFavorite::getAppUserId, id).list().stream() |
| | | .map(MeditationUserFavorite::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1L); |
| | | Page<Meditation> page = meditationService |
| | | .lambdaQuery() |
| | | .in(Meditation::getId, collect) |
| | |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | | } |
| | | // 查询人数 |
| | | return R.ok(page); |
| | | } |
| | | @GetMapping("/getMeditationByIds/{pageCurr}/{pageSize}/{ids}") |
| | | public R<Page<Meditation>> getMeditationByIds(@PathVariable("pageCurr") Integer pageCurr, |
| | | @PathVariable("pageSize") Integer pageSize, |
| | | @PathVariable("ids")String ids) |
| | | { |
| | | |
| | | Page<Meditation> page = meditationService |
| | | .lambdaQuery() |
| | | .in(Meditation::getId,Arrays.asList(ids.split(","))) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | | } |
| | | // 查询人数 |
| | | return R.ok(page); |
| | | } |
| | | @GetMapping("/getMeditationById/{id}") |
| | |
| | | MeditationHall byId = meditationHallService.getById(id); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/meditationManagementList") |
| | | @ApiOperation(value = "冥想音频列表-分页", tags = {"管理后台-冥想音频管理"}) |
| | | public R<PageDTO<Meditation>> meditationManagementList(@RequestBody MeditationDTO dto) { |
| | | @ApiOperation(value = "冥想音频列表导出", tags = {"管理后台-冥想音频管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody MeditationDTO dto) |
| | | { |
| | | List<Long> longs = new ArrayList<>(); |
| | | if (!dto.getTagName().isEmpty()){ |
| | | if (dto.getTagName()!=null && !dto.getTagName().isEmpty()){ |
| | | List<Tag> data = remoteAppUserService.queryTag(dto.getTagName()).getData(); |
| | | if (data.isEmpty()){ |
| | | longs.add(-1L); |
| | |
| | | longs.addAll(data.stream().map(Tag::getId).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | List<Long> collect = meditationTagService.lambdaQuery().in(MeditationTag::getTagId) |
| | | if (longs.isEmpty())longs.add(-1L); |
| | | List<Long> collect = meditationTagService.lambdaQuery().in(MeditationTag::getTagId,longs) |
| | | .list().stream().map(MeditationTag::getMeditationId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | LambdaQueryWrapper<Meditation> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(dto.getIds())){ |
| | | courseLambdaQueryWrapper.in(Meditation::getId, Arrays.asList(dto.getIds().split(","))); |
| | | } |
| | | courseLambdaQueryWrapper.eq(dto.getSanskrit()!=null,Meditation::getSanskrit, dto.getSanskrit()); |
| | | courseLambdaQueryWrapper.in(StringUtils.hasLength(dto.getTagName()),Meditation::getId, collect); |
| | | courseLambdaQueryWrapper.eq(dto.getChargeType()!=null,Meditation::getChargeType, dto.getChargeType()); |
| | | courseLambdaQueryWrapper.eq(dto.getCateId()!=null,Meditation::getCateId, dto.getCateId()); |
| | | courseLambdaQueryWrapper.eq(dto.getMeditationTitle()!=null&& !dto.getMeditationTitle().isEmpty(),Meditation::getMeditationTitle, dto.getMeditationTitle()); |
| | | courseLambdaQueryWrapper.orderByDesc(Meditation::getSortNum); |
| | | List<Meditation> page = meditationService.list(courseLambdaQueryWrapper); |
| | | List<MeditationExport> meditations = new ArrayList<>(); |
| | | for (Meditation record : page) { |
| | | MeditationExport meditationExport = new MeditationExport(); |
| | | record.setUid(record.getId()+""); |
| | | MeditationCategory byId = meditationCategoryService.getById(record.getCateId()); |
| | | if (byId!=null){ |
| | | record.setCategoryName(byId.getCategoryName()); |
| | | meditationExport.setCategoryName(byId.getCategoryName()); |
| | | } |
| | | meditationExport.setName(record.getMeditationTitle()); |
| | | meditationExport.setDetailDescription(record.getDetailDescription()); |
| | | if (record.getChargeType()==3){ |
| | | meditationExport.setGeneralPrice("¥"+record.getGeneralPrice()); |
| | | }else{ |
| | | switch (record.getChargeType()){ |
| | | case 1: |
| | | meditationExport.setGeneralPrice("免费"); |
| | | break; |
| | | case 2: |
| | | meditationExport.setGeneralPrice("会员免费"); |
| | | break; |
| | | } |
| | | } |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | meditationExport.setCreateTime(format); |
| | | meditationExport.setListingStatus(record.getListingStatus()+""); |
| | | meditationExport.setRealLearnedNum(record.getRealLearnedNum()+record.getVirtualLearnedNum()+""); |
| | | meditationExport.setCollectCount(record.getFavoriteCount()+""); |
| | | meditations.add(meditationExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), MeditationExport.class, meditations); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("冥想音频管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/meditationManagementList") |
| | | @ApiOperation(value = "冥想音频列表-分页", tags = {"管理后台-冥想音频管理"}) |
| | | public R<PageDTO<Meditation>> meditationManagementList(@RequestBody MeditationDTO dto) { |
| | | List<Long> longs = new ArrayList<>(); |
| | | if (dto.getTagName()!=null && !dto.getTagName().isEmpty()){ |
| | | List<Tag> data = remoteAppUserService.queryTag(dto.getTagName()).getData(); |
| | | if (data.isEmpty()){ |
| | | longs.add(-1L); |
| | | }else{ |
| | | longs.addAll(data.stream().map(Tag::getId).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | if (longs.isEmpty())longs.add(-1L); |
| | | List<Long> collect = meditationTagService.lambdaQuery().in(MeditationTag::getTagId,longs) |
| | | .list().stream().map(MeditationTag::getMeditationId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | |
| | | } |
| | | LambdaQueryWrapper<Meditation> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.eq(dto.getSanskrit()!=null,Meditation::getSanskrit, dto.getSanskrit()); |
| | | courseLambdaQueryWrapper.in(Meditation::getId, collect); |
| | | courseLambdaQueryWrapper.in(StringUtils.hasLength(dto.getTagName()),Meditation::getId, collect); |
| | | courseLambdaQueryWrapper.eq(dto.getChargeType()!=null,Meditation::getChargeType, dto.getChargeType()); |
| | | courseLambdaQueryWrapper.eq(dto.getCateId()!=null,Meditation::getCateId, dto.getCateId()); |
| | | courseLambdaQueryWrapper.eq(dto.getMeditationTitle()!=null&& !dto.getMeditationTitle().isEmpty(),Meditation::getMeditationTitle, dto.getMeditationTitle()); |
| | |
| | | } |
| | | |
| | | @PostMapping("/addMeditation") |
| | | @ApiOperation(value = "新增冥想音频管理", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "新增冥想音频管理", tags = "管理后台-冥想音频管理") |
| | | public R addMeditation(@RequestBody Meditation homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | meditationService.save(homeBackgroundMusic); |
| | | if (homeBackgroundMusic.getIsEveryday()==1){ |
| | | MeditationEveryday meditationEveryday = new MeditationEveryday(); |
| | | meditationEveryday.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationEveryday.setStartPlayTime(homeBackgroundMusic.getStartPlayTime()); |
| | | meditationEveryday.setEndPlayTime(homeBackgroundMusic.getEndPlayTime()); |
| | | meditationEveryday.setImageUrl(homeBackgroundMusic.getImageUrl()); |
| | | meditationEveryday.setCreateTime(LocalDateTime.now()); |
| | | meditationEverydayService.save(meditationEveryday); |
| | | homeBackgroundMusic.setEverydayId(meditationEveryday.getId()); |
| | | meditationService.updateById(homeBackgroundMusic); |
| | | } |
| | | if (!homeBackgroundMusic.getTagIds().isEmpty()){ |
| | | String[] split = homeBackgroundMusic.getTagIds().split(","); |
| | | List<MeditationTag> meditationTags = new ArrayList<>(); |
| | |
| | | } |
| | | if (!homeBackgroundMusic.getMusicUrls().isEmpty()){ |
| | | String[] split = homeBackgroundMusic.getMusicUrls().split(","); |
| | | String[] split1 = homeBackgroundMusic.getName().split(","); |
| | | String[] split2 = homeBackgroundMusic.getMusicSize().split(","); |
| | | List<MeditationMusic> meditationTags = new ArrayList<>(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | MeditationMusic meditationTag = new MeditationMusic(); |
| | | meditationTag.setMusicSize(split2[i]); |
| | | meditationTag.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationTag.setMusicUrl(split[i]); |
| | | meditationTag.setName(split1[i]); |
| | | meditationTag.setMusicSecond(Integer.valueOf(homeBackgroundMusic.getMusicSecond().split(",")[i])); |
| | | meditationTags.add(meditationTag); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detailMeditation") |
| | | @ApiOperation(value = "查看详情冥想音频管理", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频管理", tags = "管理后台-冥想音频管理") |
| | | public R<Meditation> detailMeditation(String uid) { |
| | | Meditation byId = meditationService.getById(uid); |
| | | List<Long> collect = meditationTagService.list(new LambdaQueryWrapper<MeditationTag>() |
| | |
| | | .collect(Collectors.toList()); |
| | | List<String> collect1 = meditationMusicService.list(new LambdaQueryWrapper<MeditationMusic>() |
| | | .eq(MeditationMusic::getMeditationId, uid)) |
| | | .stream().map(MeditationMusic::getMusicUrl) |
| | | .stream().map(MeditationMusic::getName) |
| | | .collect(Collectors.toList()); |
| | | byId.setMusicList(collect1); |
| | | byId.setTagList(collect); |
| | | if (byId.getIsEveryday() == 1){ |
| | | MeditationEveryday byId1 = meditationEverydayService.getById(byId.getEverydayId()); |
| | | byId.setStartPlayTime(byId1.getStartPlayTime()); |
| | | byId.setEndPlayTime(byId1.getEndPlayTime()); |
| | | byId.setImageUrl(byId1.getImageUrl()); |
| | | } |
| | | MeditationCategory byId1 = meditationCategoryService.getById(byId.getCateId()); |
| | | if (byId1!=null){ |
| | | byId.setCategoryName(byId1.getCategoryName()); |
| | | } |
| | | List<MeditationMusic> list = meditationMusicService.lambdaQuery().eq(MeditationMusic::getMeditationId, byId.getId()).list(); |
| | | StringBuilder stringBuilder1 = new StringBuilder(); |
| | | StringBuilder stringBuilder2 = new StringBuilder(); |
| | | StringBuilder stringBuilder3 = new StringBuilder(); |
| | | StringBuilder stringBuilder4 = new StringBuilder(); |
| | | for (MeditationMusic meditationMusic : list) { |
| | | stringBuilder1.append(meditationMusic.getMusicUrl()).append(","); |
| | | stringBuilder2.append(meditationMusic.getMusicSize()).append(","); |
| | | stringBuilder3.append(meditationMusic.getMusicSecond()).append(","); |
| | | stringBuilder4.append(meditationMusic.getName()).append(","); |
| | | } |
| | | // 去除最后以为字符 |
| | | byId.setMusicUrls(stringBuilder1.deleteCharAt(stringBuilder1.length() - 1)+""); |
| | | byId.setMusicSize(stringBuilder2.deleteCharAt(stringBuilder2.length() - 1)+""); |
| | | byId.setMusicSecond(stringBuilder3.deleteCharAt(stringBuilder3.length() - 1)+""); |
| | | byId.setName(stringBuilder4.deleteCharAt(stringBuilder4.length() - 1)+""); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/userAnswer") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-分页", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-分页", tags = "管理后台-冥想音频管理") |
| | | public R<PageDTO<MeditationQuestion>> userAnswer(@RequestBody UserAnswerDTO dto) { |
| | | LambdaQueryWrapper<MeditationQuestion> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(dto.getUserName())){ |
| | |
| | | return R.ok(PageDTO.of(page, MeditationQuestion.class)); |
| | | } |
| | | @GetMapping("/updateUserAnswerState") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-修改显示状态", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-修改显示状态", tags = "管理后台-冥想音频管理") |
| | | public R updateUserAnswerState(String uid) { |
| | | MeditationQuestion byId = meditationQuestionService.getById(uid); |
| | | if (byId.getShowFlag() == 1){ |
| | |
| | | }else { |
| | | byId.setShowFlag(1); |
| | | } |
| | | meditationQuestionService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detailUserAnswer") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问", tags = "管理后台-冥想音频管理") |
| | | public R<MeditationQuestion> detailUserAnswer(String uid) { |
| | | MeditationQuestion byId = meditationQuestionService.getById(uid); |
| | | AppUser data = remoteAppUserService.getAppUserById(byId.getAppUserId().toString()).getData(); |
| | |
| | | return R.ok(byId); |
| | | } |
| | | @GetMapping("/updateUserAnswer") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-编辑", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-编辑", tags = "管理后台-冥想音频管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "uid", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "content", value = "回复内容", dataType = "String", required = false), |
| | |
| | | meditationQuestionLambdaUpdateWrapper.set(MeditationQuestion::getReplyContent, content); |
| | | meditationQuestionLambdaUpdateWrapper.set(StringUtils.hasLength(content),MeditationQuestion::getReplyTime, LocalDateTime.now()); |
| | | meditationQuestionLambdaUpdateWrapper.set(MeditationQuestion::getShowFlag, showFlag); |
| | | meditationQuestionLambdaUpdateWrapper.eq(MeditationQuestion::getId, uid); |
| | | meditationQuestionService.update(meditationQuestionLambdaUpdateWrapper); |
| | | return R.ok(byId); |
| | | } |
| | | @GetMapping("/updateState") |
| | | @ApiOperation(value = "修改冥想音频上下架状态", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "修改冥想音频上下架状态", tags = "管理后台-冥想音频管理") |
| | | public R updateState(String uid) { |
| | | Meditation byId = meditationService.getById(uid); |
| | | if (byId.getListingStatus() == 1){ |
| | |
| | | }else { |
| | | byId.setListingStatus(1); |
| | | } |
| | | meditationService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateMeditation") |
| | | @ApiOperation(value = "修改冥想音频管理", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "修改冥想音频管理", tags = "管理后台-冥想音频管理") |
| | | public R updateMeditation(@RequestBody Meditation homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | |
| | | .eq(MeditationTag::getMeditationId,homeBackgroundMusic.getId())); |
| | | meditationMusicService.remove(new LambdaQueryWrapper<MeditationMusic>() |
| | | .eq(MeditationMusic::getMeditationId,homeBackgroundMusic.getId())); |
| | | if (homeBackgroundMusic.getIsEveryday() == 2){ |
| | | // 将以前的删掉 |
| | | meditationEverydayService.remove(new LambdaQueryWrapper<MeditationEveryday>() |
| | | .eq(MeditationEveryday::getId,homeBackgroundMusic.getEverydayId())); |
| | | }else if (homeBackgroundMusic.getIsEveryday() == 1){ |
| | | meditationEverydayService.remove(new LambdaQueryWrapper<MeditationEveryday>() |
| | | .eq(MeditationEveryday::getId,homeBackgroundMusic.getEverydayId())); |
| | | // 将以前的删掉 再新增一条 |
| | | MeditationEveryday meditationEveryday = new MeditationEveryday(); |
| | | meditationEveryday.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationEveryday.setStartPlayTime(homeBackgroundMusic.getStartPlayTime()); |
| | | meditationEveryday.setEndPlayTime(homeBackgroundMusic.getEndPlayTime()); |
| | | meditationEveryday.setImageUrl(homeBackgroundMusic.getImageUrl()); |
| | | meditationEveryday.setCreateTime(LocalDateTime.now()); |
| | | meditationEverydayService.save(meditationEveryday); |
| | | homeBackgroundMusic.setEverydayId(meditationEveryday.getId()); |
| | | meditationService.updateById(homeBackgroundMusic); |
| | | } |
| | | if (!homeBackgroundMusic.getTagIds().isEmpty()){ |
| | | meditationTagService.remove(new LambdaQueryWrapper<MeditationTag>().eq(MeditationTag::getMeditationId,homeBackgroundMusic.getId())); |
| | | String[] split = homeBackgroundMusic.getTagIds().split(","); |
| | |
| | | if (!homeBackgroundMusic.getMusicUrls().isEmpty()){ |
| | | meditationMusicService.remove(new LambdaQueryWrapper<MeditationMusic>().eq(MeditationMusic::getMeditationId,homeBackgroundMusic.getId())); |
| | | String[] split = homeBackgroundMusic.getMusicUrls().split(","); |
| | | String[] split1 = homeBackgroundMusic.getName().split(","); |
| | | String[] split2 = homeBackgroundMusic.getMusicSize().split(","); |
| | | List<MeditationMusic> meditationTags = new ArrayList<>(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | MeditationMusic meditationTag = new MeditationMusic(); |
| | | meditationTag.setMusicSize(split2[i]); |
| | | meditationTag.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationTag.setMusicUrl(split[i]); |
| | | meditationTag.setName(split1[i]); |
| | | meditationTag.setMusicSecond(Integer.valueOf(homeBackgroundMusic.getMusicSecond().split(",")[i])); |
| | | meditationTags.add(meditationTag); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/deleteMeditation") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-冥想音频管理") |
| | | public R deleteMeditation(String ids) { |
| | | return R.ok(meditationService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |