package com.sqx.modules.sys.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.sys.entity.SysLogEntity;
import com.sqx.modules.sys.service.SysLogService;
import com.sqx.modules.utils.ParamPageUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;


/**
 * 系统日志
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    /**
     * 列表
     */
    @ResponseBody
    @GetMapping("/list")
    @RequiresPermissions("sys:log:list")
    public Result list(@RequestParam Map<String, Object> params) {
        PageHelper.startPage(ParamPageUtils.getPageNum(params), ParamPageUtils.getPageSize(params));
        List<SysLogEntity> entities = sysLogService.list();
        PageInfo<SysLogEntity> pageInfo = new PageInfo<>(entities);

        return Result.success().put("page", PageUtils.page(pageInfo));
    }

}
