FsCourseWatchLogController.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. package com.fs.course.controller;
  2. import com.fs.common.annotation.Log;
  3. import com.fs.common.constant.HttpStatus;
  4. import com.fs.common.core.controller.BaseController;
  5. import com.fs.common.core.domain.AjaxResult;
  6. import com.fs.common.core.page.TableDataInfo;
  7. import com.fs.common.enums.BusinessType;
  8. import com.fs.common.exception.CustomException;
  9. import com.fs.common.utils.ServletUtils;
  10. import com.fs.common.utils.poi.ExcelUtil;
  11. import com.fs.core.security.LoginUser;
  12. import com.fs.core.web.service.TokenService;
  13. import com.fs.course.domain.FsCourseWatchLog;
  14. import com.fs.course.param.FsCourseOverParam;
  15. import com.fs.course.param.FsCourseUserStatisticsListParam;
  16. import com.fs.course.param.FsCourseWatchLogListParam;
  17. import com.fs.course.param.FsCourseWatchLogStatisticsListParam;
  18. import com.fs.course.service.IFsCourseWatchLogService;
  19. import com.fs.course.vo.FsCourseOverVO;
  20. import com.fs.course.vo.FsCourseUserStatisticsListVO;
  21. import com.fs.course.vo.FsCourseWatchLogListVO;
  22. import com.fs.course.vo.FsCourseWatchLogStatisticsListVO;
  23. import com.fs.qw.param.QwWatchLogStatisticsListParam;
  24. import com.fs.qw.service.IQwWatchLogService;
  25. import com.fs.qw.vo.QwWatchLogAllStatisticsListVO;
  26. import com.fs.qw.vo.QwWatchLogStatisticsListVO;
  27. import com.fs.sop.mapper.SopUserLogsMapper;
  28. import com.github.pagehelper.PageInfo;
  29. import org.aspectj.weaver.ast.Var;
  30. import org.springframework.beans.factory.annotation.Autowired;
  31. import org.springframework.security.access.prepost.PreAuthorize;
  32. import org.springframework.web.bind.annotation.*;
  33. import java.util.ArrayList;
  34. import java.util.List;
  35. /**
  36. * 短链课程看课记录Controller
  37. *
  38. * @author fs
  39. * @date 2024-10-24
  40. */
  41. @RestController
  42. @RequestMapping("/course/courseWatchLog")
  43. public class FsCourseWatchLogController extends BaseController
  44. {
  45. @Autowired
  46. private IFsCourseWatchLogService fsCourseWatchLogService;
  47. @Autowired
  48. private TokenService tokenService;
  49. @Autowired
  50. private SopUserLogsMapper sopUserLogsMapper;
  51. @Autowired
  52. private IQwWatchLogService qwWatchLogService;
  53. /**
  54. * 查询短链课程看课记录列表
  55. */
  56. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:list')")
  57. @GetMapping("/list")
  58. public TableDataInfo list(FsCourseWatchLogListParam param)
  59. {
  60. List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVONew(param);
  61. TableDataInfo rspData = new TableDataInfo();
  62. rspData.setCode(HttpStatus.SUCCESS);
  63. rspData.setMsg("查询成功");
  64. rspData.setRows(list);
  65. rspData.setTotal(fsCourseWatchLogService.selectFsCourseWatchLogListVOCount(param));
  66. return rspData;
  67. }
  68. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:statisticsList')")
  69. @GetMapping("/statisticsList")
  70. public TableDataInfo statisticsList(FsCourseWatchLogStatisticsListParam param)
  71. {
  72. // 如果看指定用户就不用设置公司
  73. if(param.getCompanyId() == null){
  74. if(param.getUserId() == null) {
  75. throw new CustomException("查看公司或者用户必填!");
  76. }
  77. }
  78. if (param.getSTime()==null||param.getETime()==null){
  79. throw new CustomException("必须选择开始时间和结束时间!");
  80. }
  81. List<FsCourseWatchLogStatisticsListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogStatisticsListVONew(param);
  82. TableDataInfo rspData = new TableDataInfo();
  83. rspData.setCode(HttpStatus.SUCCESS);
  84. rspData.setMsg("查询成功");
  85. rspData.setRows(list);
  86. rspData.setTotal(fsCourseWatchLogService.selectFsCourseWatchLogStatisticsListVONewCount(param));
  87. return rspData;
  88. }
  89. @GetMapping("/qwWatchLogStatisticsList")
  90. public TableDataInfo qwWatchLogStatisticsList(QwWatchLogStatisticsListParam param)
  91. {
  92. if(param.getPageNum() == null){
  93. param.setPageNum(1L);
  94. }
  95. if(param.getPageSize() == null){
  96. param.setPageSize(10L);
  97. }
  98. if (param.getSTime()==null||param.getETime()==null){
  99. return getDataTable(new ArrayList<>());
  100. }
  101. if(param.getCompanyId() == null){
  102. throw new CustomException("必须选择公司!");
  103. }
  104. return qwWatchLogService.selectQwWatchLogStatisticsListVONew(param);
  105. }
  106. @GetMapping("/myQwWatchLogStatisticsList")
  107. public TableDataInfo myQwWatchLogStatisticsList(QwWatchLogStatisticsListParam param)
  108. {
  109. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  110. param.setCompanyUserId(loginUser.getUser().getUserId());
  111. if (param.getSTime()==null||param.getETime()==null){
  112. return getDataTable(new ArrayList<>());
  113. }
  114. return qwWatchLogService.selectQwWatchLogStatisticsListVONew(param);
  115. }
  116. @GetMapping("/qwWatchLogAllStatisticsList")
  117. public TableDataInfo qwWatchLogAllStatisticsList(QwWatchLogStatisticsListParam param)
  118. {
  119. logger.info("会员课程数据汇总 参数: {}",param);
  120. if(param.getCompanyId() == null){
  121. throw new CustomException("必须选择公司!");
  122. }
  123. if (param.getSTime()==null||param.getETime()==null){
  124. return getDataTable(new ArrayList<>());
  125. }
  126. return qwWatchLogService.selectQwWatchLogAllStatisticsListVONew(param);
  127. }
  128. @GetMapping("/myQwWatchLogAllStatisticsList")
  129. public TableDataInfo myQwWatchLogAllStatisticsList(QwWatchLogStatisticsListParam param)
  130. {
  131. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  132. param.setCompanyUserId(loginUser.getUser().getUserId());
  133. if (param.getSTime()==null||param.getETime()==null){
  134. return getDataTable(new ArrayList<>());
  135. }
  136. return qwWatchLogService.selectQwWatchLogAllStatisticsListVONew(param);
  137. }
  138. @GetMapping("/watchLogStatistics")
  139. public TableDataInfo watchLogStatistics(FsCourseOverParam param)
  140. {
  141. startPage();
  142. if (param.getSTime()==null||param.getETime()==null){
  143. return getDataTable(new ArrayList<>());
  144. }
  145. List<FsCourseOverVO> list = fsCourseWatchLogService.selectFsCourseWatchLogOverStatisticsListVONew(param);
  146. return getDataTable(list);
  147. }
  148. @GetMapping("/watchLogStatisticsExport")
  149. public AjaxResult watchLogStatisticsExport(FsCourseOverParam param)
  150. {
  151. if (param.getSTime()==null||param.getETime()==null){
  152. return AjaxResult.error("请选择时间");
  153. }
  154. List<FsCourseOverVO> list = fsCourseWatchLogService.selectFsCourseWatchLogOverStatisticsListVO(param);
  155. ExcelUtil<FsCourseOverVO> util = new ExcelUtil<FsCourseOverVO>(FsCourseOverVO.class);
  156. return util.exportExcel(list, "完课数据");
  157. }
  158. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:userStatisticsList')")
  159. @GetMapping("/userStatisticsList")
  160. public TableDataInfo userStatisticsList(FsCourseUserStatisticsListParam param)
  161. {
  162. startPage();
  163. if (param.getSTime()==null||param.getETime()==null){
  164. return getDataTable(new ArrayList<>());
  165. }
  166. List<FsCourseUserStatisticsListVO> list = fsCourseWatchLogService.selectFsCourseUserStatisticsListVO(param);
  167. return getDataTable(list);
  168. }
  169. /**
  170. * 查询短链课程看课记录列表
  171. */
  172. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:myList')")
  173. @GetMapping("/myList")
  174. public TableDataInfo myList(FsCourseWatchLogListParam param)
  175. {
  176. List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVONew(param);
  177. TableDataInfo rspData = new TableDataInfo();
  178. rspData.setCode(HttpStatus.SUCCESS);
  179. rspData.setMsg("查询成功");
  180. rspData.setRows(list);
  181. rspData.setTotal(fsCourseWatchLogService.selectFsCourseWatchLogListVOCount(param));
  182. return rspData;
  183. }
  184. /**
  185. * 导出短链课程看课记录列表
  186. */
  187. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:export')")
  188. @Log(title = "短链课程看课记录", businessType = BusinessType.EXPORT)
  189. @GetMapping("/export")
  190. public AjaxResult export(FsCourseWatchLogListParam param)
  191. {
  192. List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
  193. ExcelUtil<FsCourseWatchLogListVO> util = new ExcelUtil<FsCourseWatchLogListVO>(FsCourseWatchLogListVO.class);
  194. return util.exportExcel(list, "短链课程看课记录数据");
  195. }
  196. /**
  197. * 导出短链课程看课记录列表
  198. */
  199. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:myExport')")
  200. @Log(title = "短链课程看课记录", businessType = BusinessType.EXPORT)
  201. @GetMapping("/myExport")
  202. public AjaxResult myExport(FsCourseWatchLogListParam param)
  203. {
  204. List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
  205. ExcelUtil<FsCourseWatchLogListVO> util = new ExcelUtil<FsCourseWatchLogListVO>(FsCourseWatchLogListVO.class);
  206. return util.exportExcel(list, "短链课程看课记录数据");
  207. }
  208. /**
  209. * 获取短链课程看课记录详细信息
  210. */
  211. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:query')")
  212. @GetMapping(value = "/{logId}")
  213. public AjaxResult getInfo(@PathVariable("logId") Long logId)
  214. {
  215. return AjaxResult.success(fsCourseWatchLogService.selectFsCourseWatchLogByLogId(logId));
  216. }
  217. /**
  218. * 新增短链课程看课记录
  219. */
  220. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:add')")
  221. @Log(title = "短链课程看课记录", businessType = BusinessType.INSERT)
  222. @PostMapping
  223. public AjaxResult add(@RequestBody FsCourseWatchLog fsCourseWatchLog)
  224. {
  225. return toAjax(fsCourseWatchLogService.insertFsCourseWatchLog(fsCourseWatchLog));
  226. }
  227. /**
  228. * 修改短链课程看课记录
  229. */
  230. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:edit')")
  231. @Log(title = "短链课程看课记录", businessType = BusinessType.UPDATE)
  232. @PutMapping
  233. public AjaxResult edit(@RequestBody FsCourseWatchLog fsCourseWatchLog)
  234. {
  235. return toAjax(fsCourseWatchLogService.updateFsCourseWatchLog(fsCourseWatchLog));
  236. }
  237. /**
  238. * 删除短链课程看课记录
  239. */
  240. @PreAuthorize("@ss.hasPermi('course:courseWatchLog:remove')")
  241. @Log(title = "短链课程看课记录", businessType = BusinessType.DELETE)
  242. @DeleteMapping("/{logIds}")
  243. public AjaxResult remove(@PathVariable Long[] logIds)
  244. {
  245. return toAjax(fsCourseWatchLogService.deleteFsCourseWatchLogByLogIds(logIds));
  246. }
  247. }