package com.fs.hisStore.controller;

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.hisStore.param.StoreOperMainQueryParam;
import com.fs.hisStore.service.ISysOperLogScrmService;
import com.fs.hisStore.domain.SysOperLogScrm;
import com.fs.hisStore.vo.StoreOperMainVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作日志记录
 *

 */
@RestController
@RequestMapping("/store/operlogScrm")
public class SysOperlogScrmController extends BaseController
{
    private final ISysOperLogScrmService operLogService;

    public SysOperlogScrmController(ISysOperLogScrmService operLogService) {
        this.operLogService = operLogService;
    }

    @PreAuthorize("@ss.hasPermi('his:storeLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysOperLogScrm operLog)
    {
        startPage();
        List<SysOperLogScrm> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('his:storeLog:list')")
    @GetMapping("/getMains")
    public R getMains(StoreOperMainQueryParam operLog)
    {
        List<StoreOperMainVO> list = operLogService.getMains(operLog);
        return R.ok().put("data", list);
    }

    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('his:storeLog:export')")
    @GetMapping("/export")
    public AjaxResult export(SysOperLogScrm operLog)
    {
        List<SysOperLogScrm> list = operLogService.selectOperLogList(operLog);
        ExcelUtil<SysOperLogScrm> util = new ExcelUtil<>(SysOperLogScrm.class);
        return util.exportExcel(list, "操作日志");
    }

}
