| | |
| | | package com.xinquan.course.controller.client; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | 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.api.domain.CourseCategory; |
| | | import com.xinquan.course.service.CourseCategoryService; |
| | | import com.xinquan.course.service.CourseCategoryService; |
| | | 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.Arrays; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/client/course/course-category") |
| | | public class ClientCourseCategoryController { |
| | | |
| | | @Autowired |
| | | private CourseCategoryService courseCategoryService; |
| | | @PostMapping("/courseCategoryManagementList") |
| | | @ApiOperation(value = "分类列表-分页", tags = {"管理后台-分类管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<CourseCategory>> courseCategoryManagementList(@RequestParam(value = "pageCurr")Integer pageCurr, |
| | | @RequestParam(value = "pageSize")Integer pageSize) { |
| | | LambdaQueryWrapper<CourseCategory> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.orderByDesc(CourseCategory::getSortNum); |
| | | Page<CourseCategory> page = courseCategoryService.page(new Page<>(pageCurr, pageSize), courseLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (CourseCategory record : page.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | } |
| | | return R.ok(PageDTO.of(page, CourseCategory.class)); |
| | | } |
| | | @PostMapping("/addCourseCategory") |
| | | @ApiOperation(value = "新增分类管理", tags = "管理后台-分类管理") |
| | | public R addCourseCategory(@RequestBody CourseCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(courseCategoryService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailCourseCategory") |
| | | @ApiOperation(value = "查看详情分类管理", tags = "管理后台-分类管理") |
| | | public R<CourseCategory> detailCourseCategory(String uid) { |
| | | return R.ok(courseCategoryService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateCourseCategory") |
| | | @ApiOperation(value = "修改分类管理", tags = "管理后台-分类管理") |
| | | public R updateCourseCategory(@RequestBody CourseCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(courseCategoryService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteCourseCategory") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-分类管理") |
| | | public R deleteCourseCategory(String ids) { |
| | | return R.ok(courseCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |