package com.gzzm.lobster.audit;

import net.cyan.thunwind.annotation.OQL;
import net.cyan.thunwind.dao.GeneralDao;

import java.util.Date;
import java.util.List;

/**
 * AuditLogDao —— 审计日志持久化 / Audit log persistence.
 */
public abstract class AuditLogDao extends GeneralDao {

    @OQL("select a from AuditLog a where a.userId=:1 and a.createTime>=?2 order by a.createTime desc limit :3,:4")
    public abstract List<AuditLog> listByUser(String userId, Date from, int offset, int limit) throws Exception;

    @OQL("select a from AuditLog a where a.threadId=:1 order by a.createTime desc limit 0,:2")
    public abstract List<AuditLog> listByThread(String threadId, int limit) throws Exception;

    @OQL("select count(a.auditId) from AuditLog a where a.userId=:1 and a.actionType=?2 and a.createTime>=?3")
    public abstract Long countUserActionSince(String userId, String actionType, Date since) throws Exception;
}
