| | |
| | | package com.xinquan.meditation.controller.client; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.domain.MeditationCategory; |
| | | import com.xinquan.meditation.service.MeditationCategoryService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * 冥想分类表 前端控制器 |
| | | * 冥想冥想分类表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | |
| | | @RestController |
| | | @RequestMapping("/client/meditation/meditation-category") |
| | | public class ClientMeditationCategoryController { |
| | | |
| | | @Autowired |
| | | private MeditationCategoryService meditationCategoryService; |
| | | @PostMapping("/meditationCategoryManagementList") |
| | | @ApiOperation(value = "冥想分类列表-分页", tags = {"管理后台-冥想分类管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<MeditationCategory>> meditationCategoryManagementList(@RequestParam(value = "pageCurr")Integer pageCurr, |
| | | @RequestParam(value = "pageSize")Integer pageSize) { |
| | | LambdaQueryWrapper<MeditationCategory> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.orderByDesc(MeditationCategory::getSortNum); |
| | | Page<MeditationCategory> page = meditationCategoryService.page(new Page<>(pageCurr, pageSize), meditationLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (MeditationCategory record : page.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | } |
| | | return R.ok(PageDTO.of(page, MeditationCategory.class)); |
| | | } |
| | | @PostMapping("/addMeditationCategory") |
| | | @ApiOperation(value = "新增冥想分类管理", notes = "管理后台-冥想分类管理") |
| | | public R addMeditationCategory(@RequestBody MeditationCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(meditationCategoryService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailMeditationCategory") |
| | | @ApiOperation(value = "查看详情冥想分类管理", notes = "管理后台-冥想分类管理") |
| | | public R<MeditationCategory> detailMeditationCategory(String uid) { |
| | | return R.ok(meditationCategoryService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateMeditationCategory") |
| | | @ApiOperation(value = "修改冥想分类管理", notes = "管理后台-冥想分类管理") |
| | | public R updateMeditationCategory(@RequestBody MeditationCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(meditationCategoryService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteMeditationCategory") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-冥想分类管理") |
| | | public R deleteMeditationCategory(String ids) { |
| | | return R.ok(meditationCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | } |
| | | } |
| | | |