package com.fs.company.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.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.company.domain.CompanyOperLog;
import com.fs.company.service.ICompanyOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作日志记录Controller
 *
 * @author fs
 * @date 2021-10-04
 */
@RestController
@RequestMapping("/company/companyOperLog")
public class CompanyOperLogController extends BaseController
{
    @Autowired
    private ICompanyOperLogService companyOperLogService;

    /**
     * 查询操作日志记录列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyOperLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyOperLog companyOperLog)
    {
        startPage();
        List<CompanyOperLog> list = companyOperLogService.selectCompanyOperLogList(companyOperLog);
        return getDataTable(list);
    }

    /**
     * 导出操作日志记录列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyOperLog:export')")
    @Log(title = "操作日志记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyOperLog companyOperLog)
    {
        List<CompanyOperLog> list = companyOperLogService.selectCompanyOperLogList(companyOperLog);
        ExcelUtil<CompanyOperLog> util = new ExcelUtil<CompanyOperLog>(CompanyOperLog.class);
        return util.exportExcel(list, "companyOperLog");
    }

    /**
     * 获取操作日志记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyOperLog:query')")
    @GetMapping(value = "/{operId}")
    public AjaxResult getInfo(@PathVariable("operId") Long operId)
    {
        return AjaxResult.success(companyOperLogService.selectCompanyOperLogById(operId));
    }

    /**
     * 新增操作日志记录
     */
    @PreAuthorize("@ss.hasPermi('company:companyOperLog:add')")
    @Log(title = "操作日志记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyOperLog companyOperLog)
    {
        return toAjax(companyOperLogService.insertCompanyOperLog(companyOperLog));
    }

    /**
     * 修改操作日志记录
     */
    @PreAuthorize("@ss.hasPermi('company:companyOperLog:edit')")
    @Log(title = "操作日志记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyOperLog companyOperLog)
    {
        return toAjax(companyOperLogService.updateCompanyOperLog(companyOperLog));
    }

    /**
     * 删除操作日志记录
     */
    @PreAuthorize("@ss.hasPermi('company:companyOperLog:remove')")
    @Log(title = "操作日志记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operIds}")
    public AjaxResult remove(@PathVariable Long[] operIds)
    {
        return toAjax(companyOperLogService.deleteCompanyOperLogByIds(operIds));
    }
}
