CollectCourseController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package com.zhongzheng.controller.collect;
  2. import java.util.List;
  3. import java.util.Arrays;
  4. import com.zhongzheng.common.utils.ServletUtils;
  5. import com.zhongzheng.framework.web.service.WxTokenService;
  6. import com.zhongzheng.modules.collect.bo.CollectCourseAddBo;
  7. import com.zhongzheng.modules.collect.bo.CollectCourseEditBo;
  8. import com.zhongzheng.modules.collect.bo.CollectCourseQueryBo;
  9. import com.zhongzheng.modules.collect.domain.CollectCourse;
  10. import com.zhongzheng.modules.collect.service.ICollectCourseService;
  11. import com.zhongzheng.modules.collect.vo.CollectCourseVo;
  12. import com.zhongzheng.modules.user.entity.ClientLoginUser;
  13. import lombok.RequiredArgsConstructor;
  14. import org.springframework.security.access.prepost.PreAuthorize;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.GetMapping;
  17. import org.springframework.web.bind.annotation.PostMapping;
  18. import org.springframework.web.bind.annotation.PutMapping;
  19. import org.springframework.web.bind.annotation.DeleteMapping;
  20. import org.springframework.web.bind.annotation.PathVariable;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import com.zhongzheng.common.annotation.Log;
  25. import com.zhongzheng.common.core.controller.BaseController;
  26. import com.zhongzheng.common.core.domain.AjaxResult;
  27. import com.zhongzheng.common.enums.BusinessType;
  28. import com.zhongzheng.common.utils.poi.ExcelUtil;
  29. import com.zhongzheng.common.core.page.TableDataInfo;
  30. import io.swagger.annotations.Api;
  31. import io.swagger.annotations.ApiOperation;
  32. /**
  33. * 收藏课程Controller
  34. *
  35. * @author hjl
  36. * @date 2021-06-22
  37. */
  38. @Api(value = "收藏课程控制器", tags = {"收藏课程管理"})
  39. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  40. @RestController
  41. @RequestMapping("/collect/course")
  42. public class CollectCourseController extends BaseController {
  43. private final ICollectCourseService iCollectCourseService;
  44. private final WxTokenService wxTokenService;
  45. /**
  46. * 获取收藏课程详细信息
  47. */
  48. @ApiOperation("获取是否收藏课程")
  49. @GetMapping("/{courseId}")
  50. public AjaxResult<CollectCourse> getInfo(@PathVariable("courseId" ) Long courseId) {
  51. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  52. return AjaxResult.success(iCollectCourseService.queryByCourseId(loginUser.getUser().getUserId(),courseId));
  53. }
  54. /**
  55. * 新增收藏课程
  56. */
  57. @ApiOperation("新增收藏课程")
  58. @Log(title = "收藏课程", businessType = BusinessType.INSERT)
  59. @PostMapping()
  60. public AjaxResult<Void> add(@RequestBody CollectCourseAddBo bo) {
  61. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  62. bo.setUserId(loginUser.getUser().getUserId());
  63. return toAjax(iCollectCourseService.insertByAddBo(bo) ? 1 : 0);
  64. }
  65. /**
  66. * 删除收藏课程
  67. */
  68. @ApiOperation("删除收藏课程")
  69. @Log(title = "收藏课程" , businessType = BusinessType.DELETE)
  70. @PostMapping("/delete/{collectCourseIds}")
  71. public AjaxResult<Void> remove(@PathVariable Long[] collectCourseIds) {
  72. return toAjax(iCollectCourseService.deleteWithValidByIds(Arrays.asList(collectCourseIds), true) ? 1 : 0);
  73. }
  74. }