| | |
| | | package com.dsh.course.controller; |
| | | |
| | | |
| | | import cn.mb.cloud.common.data.controller.BaseController; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.entity.TCourse; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.entity.TCoursePackageType; |
| | | import com.dsh.course.feignclient.model.ExerciseVideo; |
| | | import com.dsh.course.model.*; |
| | | import com.dsh.course.model.dto.CourseChangeStateDTO; |
| | | import com.dsh.course.model.dto.TQueryBenefitsVideosDTO; |
| | | import com.dsh.course.model.vo.TQueryBenefitsVideosVO; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.service.TCoursePackageTypeService; |
| | | import com.dsh.course.service.TCourseService; |
| | | import com.dsh.course.util.PageFactory; |
| | | import com.dsh.course.util.PayMoneyUtil; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.TokenUtil; |
| | |
| | | @CrossOrigin |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class CourseController { |
| | | public class CourseController extends BaseController { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger("business-log"); |
| | | |
| | |
| | | @Autowired |
| | | private TCoursePackagePaymentService coursePackagePaymentService; |
| | | |
| | | /** |
| | | * 上/下架 1为上架 2为下架 3为删除 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/course/changeState") |
| | | @ResponseBody |
| | | public Object changeState(@RequestBody CourseChangeStateDTO dto){ |
| | | |
| | | return courseService.changeState(dto); |
| | | } |
| | | |
| | | /** |
| | | * 通过课程ids获取课程 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/course/getCourseByCourseIds") |
| | | public List<TQueryBenefitsVideosVO> getCourseByCourseIds(@RequestBody TQueryBenefitsVideosDTO query){ |
| | | |
| | | return courseService.getCourseByCourseIds(query); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/course/queryList") |
| | | @PostMapping("/base/course/queryList") |
| | | public List<ExerciseVideo> queryStuCourseAfterVideos(@RequestBody List<Integer> courseIds){ |
| | | List<ExerciseVideo> videos = new ArrayList<>(); |
| | | List<TCourse> list = courseService.list(new QueryWrapper<TCourse>() |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/queryCourseList") |
| | | @ApiOperation(value = "获取课程列表", tags = {"APP-课程列表"}) |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/course/queryCourseListOne") |
| | | @ApiOperation(value = "获取课程列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CoursePackageListVo>> queryCourseListOne(CoursePackageList coursePackageList){ |
| | | try { |
| | | List<CoursePackageListVo> coursePackageListVos = coursePackageService.queryCourseListOne( coursePackageList); |
| | | return ResultUtil.success(coursePackageListVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/paymentCourse") |
| | | @ApiOperation(value = "支付课程", tags = {"APP-课程列表"}) |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Long couponId = paymentCourseVo.getCouponId(); |
| | | if(couponId==null || couponId==0){ |
| | | paymentCourseVo.setCouponId(null); |
| | | } |
| | | return coursePackageService.paymentCourse(uid, paymentCourseVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | // 2.0 |
| | | @ResponseBody |
| | | @PostMapping("/api/course/paymentCourseCouponList") |
| | | @ApiOperation(value = "支付课程--完成后优惠券列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil paymentCourseCouponList(Integer coursePackagePaymentConfigId){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return coursePackageService.paymentCourseCouponList(uid, coursePackagePaymentConfigId); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 购买课程微信支付回调 |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id获取课程数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/queryCourseById") |
| | | public TCourse queryCourseById(@RequestBody Integer id){ |
| | | try { |
| | | return courseService.getById(id); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据名称获取数据 |
| | | * @param name |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/queryCourseByName") |
| | | public List<TCourse> queryCourseByName(@RequestBody String name){ |
| | | try { |
| | | return courseService.list(new QueryWrapper<TCourse>().like("name", name).eq("state", 1)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课程管理列表数据 |
| | | * @param queryCourseList |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/queryCourseLists") |
| | | public Page<Map<String, Object>> queryCourseLists(@RequestBody QueryCourseList queryCourseList){ |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(queryCourseList.getLimit(), queryCourseList.getOffset(), queryCourseList.getSort(), queryCourseList.getOrder()); |
| | | Page<Map<String, Object>> mapPage = page.setRecords(courseService.queryCourseList(page, queryCourseList)); |
| | | return mapPage; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加课程 |
| | | * @param course |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/addCourse") |
| | | public void addCourse(@RequestBody TCourse course){ |
| | | courseService.save(course); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑数据 |
| | | * @param course |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/editCourse") |
| | | public void editCourse(@RequestBody TCourse course){ |
| | | courseService.updateById(course); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除数据 |
| | | * @param id |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/delCourseById") |
| | | public void delCourseById(@RequestBody Integer id){ |
| | | TCourse course = courseService.getById(id); |
| | | if(null != course){ |
| | | course.setState(3); |
| | | courseService.updateById(course); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑数据状态 |
| | | * @param editCourseState |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/editCourseState") |
| | | public void editCourseState(@RequestBody EditCourseState editCourseState){ |
| | | TCourse course = courseService.getById(editCourseState.getId()); |
| | | if(null != course){ |
| | | course.setState(editCourseState.getState()); |
| | | courseService.updateById(course); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据类型获取数据 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/course/queryCourseByType") |
| | | public List<TCourse> queryCourseByType(@RequestBody Integer type){ |
| | | return courseService.list(new QueryWrapper<TCourse>().eq("type", type).eq("state", 1)); |
| | | } |
| | | } |