| | |
| | | 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.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.service.CourseCategoryService; |
| | | import com.xinquan.course.service.CourseCategoryService; |
| | | import com.xinquan.course.service.CourseService; |
| | | 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.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | public class ClientCourseCategoryController { |
| | | @Autowired |
| | | private CourseCategoryService courseCategoryService; |
| | | @Autowired |
| | | private CourseService courseService; |
| | | @PostMapping("/courseCategoryManagementList") |
| | | @ApiOperation(value = "分类列表-分页", tags = {"管理后台-分类管理"}) |
| | | @ApiImplicitParams({ |
| | |
| | | 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("/courseCategoryManagementList1") |
| | | @ApiOperation(value = "分类列表-分页", tags = {"管理后台-分类管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<CourseCategory>> courseCategoryManagementList1(@RequestParam(value = "pageCurr")Integer pageCurr, |
| | | @RequestParam(value = "pageSize")Integer pageSize) { |
| | | LambdaQueryWrapper<CourseCategory> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.ne(CourseCategory::getName,"线下课程"); |
| | | courseLambdaQueryWrapper.orderByDesc(CourseCategory::getSortNum); |
| | | Page<CourseCategory> page = courseCategoryService.page(new Page<>(pageCurr, pageSize), courseLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | |
| | | @PostMapping("/deleteCourseCategory") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-分类管理") |
| | | public R deleteCourseCategory(String ids) { |
| | | // 全部修改为Long类型 |
| | | List<Long> collect = Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList()); |
| | | for (Long l : collect) { |
| | | List<Course> list = courseService.lambdaQuery().eq(Course::getCateId, l).list(); |
| | | if (!list.isEmpty()){ |
| | | CourseCategory byId = courseCategoryService.getById(l); |
| | | return R.fail("分类名称:"+byId.getName()+"下存在关联课程,不可删除"); |
| | | } |
| | | } |
| | | return R.ok(courseCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |