Search in sources :

Example 1 with SysVisitLog

use of com.github.qinyou.system.model.SysVisitLog in project my_curd by qinyou.

the class SysVisitLogController method view.

/**
 * 查看按钮
 */
public void view() {
    String id = getPara("id");
    if (StringUtils.notEmpty(id)) {
        SysVisitLog sysVisitLog = SysVisitLog.dao.findById(id);
        setAttr("sysVisitLog", sysVisitLog);
    }
    render("system/sysVisitLog_view.ftl");
}
Also used : SysVisitLog(com.github.qinyou.system.model.SysVisitLog)

Example 2 with SysVisitLog

use of com.github.qinyou.system.model.SysVisitLog in project my_curd by qinyou.

the class SysVisitLogController method exportExcel.

/**
 * 导出excel
 */
@RequirePermission("sysVisitLog:export")
@Before(SearchSql.class)
public void exportExcel() {
    String where = getAttr(Constant.SEARCH_SQL);
    if (SysVisitLog.dao.findCountByWhere(where) > 50000) {
        setAttr("msg", "一次导出数据不可大于 5W 条,请修改查询条件。");
        render("common/card.ftl");
        return;
    }
    // 测试大数据量导出
    List<SysVisitLog> list = SysVisitLog.dao.findByWhere(where);
    Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("访问日志", "访问日志"), SysVisitLog.class, list);
    render(ExcelRender.me(workbook).fileName("访问日志.xls"));
}
Also used : ExportParams(cn.afterturn.easypoi.excel.entity.ExportParams) SysVisitLog(com.github.qinyou.system.model.SysVisitLog) Workbook(org.apache.poi.ss.usermodel.Workbook) Before(com.jfinal.aop.Before) RequirePermission(com.github.qinyou.common.annotation.RequirePermission)

Example 3 with SysVisitLog

use of com.github.qinyou.system.model.SysVisitLog in project my_curd by qinyou.

the class VisitLogInterceptor method intercept.

@Override
public void intercept(Invocation inv) {
    Controller controller = inv.getController();
    SysVisitLog sysVisitLog = new SysVisitLog();
    sysVisitLog.setId(IdUtils.id());
    sysVisitLog.setSysUserIp(WebUtils.getRemoteAddress(controller.getRequest()));
    sysVisitLog.setSysUser(WebUtils.getSessionUsername(controller));
    sysVisitLog.setUrl(inv.getActionKey());
    sysVisitLog.setRequestType(controller.getRequest().getMethod());
    sysVisitLog.setCreateTime(new Date());
    Map<String, String[]> params = controller.getRequest().getParameterMap();
    if (params.keySet().size() > 0) {
        sysVisitLog.setParam(JSON.toJSONString(params));
        if (sysVisitLog.getParam().length() > 500) {
            sysVisitLog.setParam("超长文本参数");
        }
    }
    sysVisitLog.save();
    inv.invoke();
}
Also used : Controller(com.jfinal.core.Controller) SysVisitLog(com.github.qinyou.system.model.SysVisitLog) Date(java.util.Date)

Aggregations

SysVisitLog (com.github.qinyou.system.model.SysVisitLog)3 ExportParams (cn.afterturn.easypoi.excel.entity.ExportParams)1 RequirePermission (com.github.qinyou.common.annotation.RequirePermission)1 Before (com.jfinal.aop.Before)1 Controller (com.jfinal.core.Controller)1 Date (java.util.Date)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1