package com.ruoyi.web.controller.interview;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.InterviewTable;
import com.ruoyi.system.service.IInterviewTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网页访问记录Controller
 * 
 * @author ruoyi
 * @date 2023-10-16
 */
@RestController
@RequestMapping("/interview/table")
public class InterviewTableController extends BaseController
{
    @Autowired
    private IInterviewTableService interviewTableService;

    /**
     * 查询网页访问记录列表
     */
    @PreAuthorize("@ss.hasPermi('interview:table:list')")
    @GetMapping("/list")
    public TableDataInfo list(InterviewTable interviewTable)
    {
        startPage();
        List<InterviewTable> list = interviewTableService.selectInterviewTableList(interviewTable);
        return getDataTable(list);
    }

    /**
     * 导出网页访问记录列表
     */
    @PreAuthorize("@ss.hasPermi('interview:table:export')")
    @Log(title = "网页访问记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InterviewTable interviewTable)
    {
        List<InterviewTable> list = interviewTableService.selectInterviewTableList(interviewTable);
        ExcelUtil<InterviewTable> util = new ExcelUtil<InterviewTable>(InterviewTable.class);
        util.exportExcel(response, list, "网页访问记录数据");
    }

    /**
     * 获取网页访问记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('interview:table:query')")
    @GetMapping(value = "/{interviewId}")
    public AjaxResult getInfo(@PathVariable("interviewId") Long interviewId)
    {
        return success(interviewTableService.selectInterviewTableByInterviewId(interviewId));
    }

    /**
     * 新增网页访问记录
     */
    @Log(title = "网页访问记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InterviewTable interviewTable)
    {
        return toAjax(interviewTableService.insertInterviewTable(interviewTable));
    }

    /**
     * 修改网页访问记录
     */
    @PreAuthorize("@ss.hasPermi('interview:table:edit')")
    @Log(title = "网页访问记录", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody InterviewTable interviewTable)
    {
        return toAjax(interviewTableService.updateInterviewTable(interviewTable));
    }

    /**
     * 删除网页访问记录
     */
    @PreAuthorize("@ss.hasPermi('interview:table:remove')")
    @Log(title = "网页访问记录", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{interviewIds}")
    public AjaxResult remove(@PathVariable Long[] interviewIds)
    {
        return toAjax(interviewTableService.deleteInterviewTableByInterviewIds(interviewIds));
    }

    /**
     * PC首页浏览统计
     * @param type 查询类型（1：年，2：月）
     * @return
     */
    @PreAuthorize("@ss.hasPermi('interview:table:browse')")
    @GetMapping("/browse")
    public AjaxResult browse(String type)
    {
        return interviewTableService.browse(type);
    }

    /**
     * PC首页人均停留时长统计
     * @return
     */
    @PreAuthorize("@ss.hasPermi('interview:table:stay')")
    @GetMapping("/stay")
    public AjaxResult stay()
    {
        return interviewTableService.stay();
    }


}
