package com.sunxung.factoring.web.sys;

import com.sunxung.factoring.entity.GridPage;
import com.sunxung.factoring.entity.sys.SysOperationLog;
import com.sunxung.factoring.entity.sys.vo.SysOperationLogSearchVo;
import com.sunxung.factoring.service.sys.ISysOperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author liutao
 * @date 2023-08-09
 */
@Controller
@RequestMapping("operationLog")
public class OperationLogController {

    @Autowired
    private ISysOperationLogService sysOperationLogService;

    /**
     * 跳转到查看操作日志的页面
     *
     * @return
     */
    @RequestMapping("logPage")
    public String findOperationLogPage(Long logInId, Model model) {
        model.addAttribute("logInId", logInId);
        return "sys/log/loginLogView";
    }

    /**
     * 根据登录日志的id查询操作信息
     *
     * @param sysOperationLogSearchVo
     * @return
     */
    @RequestMapping("findByLoginId")
    @ResponseBody
    public GridPage findByLoginId(SysOperationLogSearchVo sysOperationLogSearchVo) {
        List<SysOperationLog> operationLogList = sysOperationLogService.findBySearch(sysOperationLogSearchVo);
        return new GridPage(sysOperationLogSearchVo.getRows(), sysOperationLogSearchVo.getPage(), operationLogList.size(), operationLogList);
    }

}
