| | |
| | | package com.xinquan.system.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.api.domain.CourseDTO; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.service.BannerService; |
| | | 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.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/system/banner") |
| | | public class BannerController { |
| | | |
| | | @Autowired |
| | | private BannerService bannerService; |
| | | @Autowired |
| | | private RemoteCourseService remoteCourseService; |
| | | |
| | | @PostMapping("/bannerList") |
| | | @ApiOperation(value = "获取banner列表-分页",tags = "管理后台banner") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<Banner>> bannerList( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return R.ok(bannerService.bannerList(pageCurr, pageSize)); |
| | | } |
| | | @PostMapping("/cateList") |
| | | @ApiOperation(value = "课程分类下拉选择列表-不分页",tags = "管理后台banner") |
| | | |
| | | public R<List<CourseCategory>> cateList() { |
| | | List<CourseCategory> data = remoteCourseService.cateList().getData(); |
| | | return R.ok(data); |
| | | } |
| | | @GetMapping("/courseList") |
| | | @ApiOperation(value = "选择课程-分页",tags = "管理后台banner") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = false, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = false, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "课程类型1线上2线下", name = "courseType", required = false, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "课程分类id", name = "cateId", required = false, dataType = "Long"), |
| | | @ApiImplicitParam(value = "课程标题", name = "courseTitle", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "导师名称", name = "tutor", required = false, dataType = "String"), |
| | | }) |
| | | public R<PageDTO<Course>> courseList( |
| | | Integer pageCurr, |
| | | Integer pageSize, |
| | | Integer courseType, |
| | | Long cateId, |
| | | String courseTitle, |
| | | |
| | | String tutor |
| | | ) { |
| | | CourseDTO courseDTO = new CourseDTO(); |
| | | courseDTO.setPageCurr(pageCurr); |
| | | courseDTO.setPageSize(pageSize); |
| | | courseDTO.setCourseType(courseType); |
| | | courseDTO.setCateId(cateId); |
| | | courseDTO.setCourseTitle(courseTitle); |
| | | courseDTO.setTutor(tutor); |
| | | PageDTO<Course> data = remoteCourseService.courseList(courseDTO).getData(); |
| | | return R.ok(data); |
| | | } |
| | | @PostMapping("/deleteBatch") |
| | | @ApiOperation(value = "批量删除banner",tags = "管理后台banner") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "ids", name = "ids", required = true, dataType = "String"), |
| | | }) |
| | | public R deleteBatch( |
| | | @RequestParam(value = "ids") String ids) |
| | | { |
| | | List<Long> list = Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()); |
| | | bannerService.removeBatchByIds(list); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/addBanner") |
| | | @ApiOperation(value = "添加banner",tags = "管理后台banner") |
| | | |
| | | public R addBanner(@RequestBody Banner banner) |
| | | { |
| | | bannerService.save(banner); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateBanner") |
| | | @ApiOperation(value = "修改banner",tags = "管理后台banner") |
| | | |
| | | public R updateBanner(@RequestBody Banner banner) |
| | | { |
| | | bannerService.updateById(banner); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/bannerDetail") |
| | | @ApiOperation(value = "查看详情",tags = "管理后台banner") |
| | | |
| | | public R<Banner> bannerDetail(String uid) |
| | | { |
| | | Banner byId = bannerService.getById(uid); |
| | | if (byId.getCourseId()!=null){ |
| | | Course data = remoteCourseService.getCourseById(byId.getCourseId()).getData(); |
| | | if (data!=null){ |
| | | byId.setCourseTitle(data.getCourseTitle()); |
| | | byId.setCoverUrl(data.getCoverUrl()); |
| | | byId.setTutor(data.getTutor()); |
| | | byId.setPrice(data.getGeneralPrice()); |
| | | if (data.getCateId()!=null){ |
| | | CourseCategory data1 = remoteCourseService.getCategoryById(data.getCateId().toString()).getData(); |
| | | byId.setCate(data1.getName()); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | } |
| | | |