瀏覽代碼

feat: 看课流量统计

xdd 2 周之前
父節點
當前提交
1a7e161b34

+ 140 - 0
fs-company/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -0,0 +1,140 @@
+package com.fs.course.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.course.domain.FsCourseTrafficLog;
+import com.fs.course.param.FsCourseTrafficLogParam;
+import com.fs.course.service.IFsCourseTrafficLogService;
+import com.fs.course.service.IFsUserCourseService;
+import com.fs.course.vo.FsCourseTrafficLogListVO;
+import com.fs.his.vo.OptionsVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+
+/**
+ * 短链课程流量记录Controller
+ *
+ * @author fs
+ * @date 2024-10-31
+ */
+@RestController
+@RequestMapping("/course/courseTrafficLog")
+public class FsCourseTrafficLogController extends BaseController
+{
+    @Autowired
+    private IFsCourseTrafficLogService fsCourseTrafficLogService;
+
+    @Autowired
+    private IFsUserCourseService fsUserCourseMapper;
+    /**
+     * 查询短链课程流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(FsCourseTrafficLogParam param)
+    {
+        startPage();
+        if(ObjectUtils.isNotNull(param.getTime())){
+
+            YearMonth yearMonth = param.getTime();
+            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
+
+            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
+                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+            param.setStartDate(startOfMonth.format(formatter));
+            param.setEndDate(startOfNextMonth.format(formatter));
+        }
+        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出短链课程流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:export')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsCourseTrafficLogParam param)
+    {
+        if (param.getTime() != null) {
+            YearMonth yearMonth = param.getTime();
+            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
+
+            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
+                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+            param.setStartDate(startOfMonth.format(formatter));
+            param.setEndDate(startOfNextMonth.format(formatter));
+        }
+        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficByCompany(param);
+        ExcelUtil<FsCourseTrafficLogListVO> util = new ExcelUtil<FsCourseTrafficLogListVO>(FsCourseTrafficLogListVO.class);
+        return util.exportExcel(list, "短链课程流量记录数据");
+    }
+
+    /**
+     * 获取短链课程流量记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:query')")
+    @GetMapping(value = "/{logId}")
+    public AjaxResult getInfo(@PathVariable("logId") Long logId)
+    {
+        return AjaxResult.success(fsCourseTrafficLogService.selectFsCourseTrafficLogByLogId(logId));
+    }
+
+    /**
+     * 新增短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:add')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsCourseTrafficLog fsCourseTrafficLog)
+    {
+        return toAjax(fsCourseTrafficLogService.insertFsCourseTrafficLog(fsCourseTrafficLog));
+    }
+
+    /**
+     * 修改短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:edit')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsCourseTrafficLog fsCourseTrafficLog)
+    {
+        return toAjax(fsCourseTrafficLogService.updateFsCourseTrafficLog(fsCourseTrafficLog));
+    }
+
+    /**
+     * 删除短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:remove')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{logIds}")
+    public AjaxResult remove(@PathVariable Long[] logIds)
+    {
+        return toAjax(fsCourseTrafficLogService.deleteFsCourseTrafficLogByLogIds(logIds));
+    }
+
+    @GetMapping("/courseList")
+    public R courseList()
+    {
+        List<OptionsVO> optionsVOS = fsUserCourseMapper.selectFsUserCourseAllList();
+        return R.ok().put("list", optionsVOS);
+    }
+}

+ 11 - 0
fs-service-system/src/main/java/com/fs/course/param/FsCourseTrafficLogParam.java

@@ -10,9 +10,20 @@ public class FsCourseTrafficLogParam {
 
     @DateTimeFormat(pattern = "yyyy-MM")
     private YearMonth time;
+    /**
+     * 公司id
+     */
     private Long companyId;
     private Integer year;
     private Integer month;
+    /**
+     * 项目id
+     */
+    private Long project;
+    /**
+     * 课程id
+     */
+    private Long courseId;
 
     private String startDate;
     private String endDate;

+ 6 - 0
fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -67,6 +67,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test='companyId !=null'>
                 and company_id = #{companyId}
             </if>
+            <if test="courseId != null">
+                and course_id = ${courseId}
+            </if>
+            <if test="project">
+                and project = ${project}
+            </if>
         </where>
         group by company_id,`month`,project,course_id
     </select>