package cn.novalon.gym.manage.db.entity.query;

import cn.novalon.gym.manage.sys.core.query.OperationLogQuery;
import cn.novalon.gym.manage.db.dao.QueryField;

import java.time.LocalDateTime;

/**
 * 操作日志查询条件对象
 * 
 * @author 张翔
 * @date 2026-03-13
 */
public class OperationLogQueryCriteria {

    @QueryField(propName = "username", type = QueryField.Type.INNER_LIKE)
    private String username;

    @QueryField(propName = "operation", type = QueryField.Type.INNER_LIKE)
    private String operation;

    @QueryField(propName = "status", type = QueryField.Type.EQUAL)
    private String status;

    @QueryField(blurry = "username,operation,ip", type = QueryField.Type.INNER_LIKE)
    private String keyword;

    @QueryField(propName = "createdAt", type = QueryField.Type.GREATER_THAN)
    private LocalDateTime startTime;

    @QueryField(propName = "createdAt", type = QueryField.Type.LESS_THAN)
    private LocalDateTime endTime;

    @QueryField(propName = "ip", type = QueryField.Type.INNER_LIKE)
    private String ip;

    @QueryField(propName = "method", type = QueryField.Type.INNER_LIKE)
    private String method;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getOperation() {
        return operation;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    /**
     * 从领域查询对象转换
     * 
     * @param query 领域查询对象
     */
    public void convert(OperationLogQuery query) {
        if (query == null) {
            return;
        }
        this.username = query.getUsername();
        this.operation = query.getOperation();
        this.status = query.getStatus();
        this.keyword = query.getKeyword();
        this.startTime = query.getStartTime();
        this.endTime = query.getEndTime();
        this.ip = query.getIp();
        this.method = query.getMethod();
    }
}
