| | |
| | | package com.xinquan.course.controller.client; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | 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.course.domain.CourseChapter; |
| | | import com.xinquan.course.service.CourseChapterService; |
| | | 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 java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 在线课程章节表 前端控制器 |
| | | * 在线章节章节表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | |
| | | @RestController |
| | | @RequestMapping("/client/course/course-chapter") |
| | | public class ClientCourseChapterController { |
| | | |
| | | @Autowired |
| | | private CourseChapterService courseChapterService; |
| | | @PostMapping("/courseChapterManagementList") |
| | | @ApiOperation(value = "章节列表-分页", tags = {"管理后台-章节管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<CourseChapter>> courseChapterManagementList(@RequestParam(value = "pageCurr")Integer pageCurr, |
| | | @RequestParam(value = "pageSize")Integer pageSize) { |
| | | LambdaQueryWrapper<CourseChapter> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.orderByDesc(CourseChapter::getSortNum); |
| | | Page<CourseChapter> page = courseChapterService.page(new Page<>(pageCurr, pageSize), courseLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (CourseChapter record : page.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | } |
| | | return R.ok(PageDTO.of(page, CourseChapter.class)); |
| | | } |
| | | @PostMapping("/addChapter") |
| | | @ApiOperation(value = "新增章节管理", notes = "管理后台-章节管理") |
| | | public R addCourseChapter(@RequestBody CourseChapter homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(courseChapterService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailCourseChapter") |
| | | @ApiOperation(value = "查看详情章节管理", notes = "管理后台-章节管理") |
| | | public R<CourseChapter> detailCourseChapter(String uid) { |
| | | return R.ok(courseChapterService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateCourseChapter") |
| | | @ApiOperation(value = "修改章节管理", notes = "管理后台-章节管理") |
| | | public R updateCourseChapter(@RequestBody CourseChapter homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(courseChapterService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteCourseChapter") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-章节管理") |
| | | public R deleteCourseChapter(String ids) { |
| | | return R.ok(courseChapterService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | } |
| | | } |
| | | |