Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.user;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;

/**
 * One upload of a Meta lead-ads export — the batch header for the {@link MetaLead} rows it produced.
 *
 * <p>Nothing in this codebase records what file was uploaded, when, or by whom; bulk imports write
 * their rows and vanish. That is tolerable for a price list and not for paid leads, where "did that
 * file actually go in, and what happened to the 12 rows nobody can find?" is a question someone will
 * ask weeks later. The counts are stored rather than derived so the batch still reads correctly if
 * a lead is later deleted.
 */
@Entity
@Table(name = "user.meta_lead_import")
public class MetaLeadImport {

    @Id
    @Column(name = "id", unique = true, updatable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(name = "file_name")
    private String fileName;

    /** Who uploaded it — {@code auth.auth_user.id}. */
    @Column(name = "auth_id")
    private int authId;

    @Column(name = "total_rows")
    private int totalRows;

    @Column(name = "created_count")
    private int createdCount;

    @Column(name = "duplicate_count")
    private int duplicateCount;

    @Column(name = "blocked_count")
    private int blockedCount;

    @Column(name = "rejected_count")
    private int rejectedCount;

    @Column(name = "created_timestamp")
    private LocalDateTime createdTimestamp;

    /** Sanity check: every row must land on exactly one outcome. */
    public boolean isBalanced() {
        return totalRows == createdCount + duplicateCount + blockedCount + rejectedCount;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public int getAuthId() {
        return authId;
    }

    public void setAuthId(int authId) {
        this.authId = authId;
    }

    public int getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(int totalRows) {
        this.totalRows = totalRows;
    }

    public int getCreatedCount() {
        return createdCount;
    }

    public void setCreatedCount(int createdCount) {
        this.createdCount = createdCount;
    }

    public int getDuplicateCount() {
        return duplicateCount;
    }

    public void setDuplicateCount(int duplicateCount) {
        this.duplicateCount = duplicateCount;
    }

    public int getBlockedCount() {
        return blockedCount;
    }

    public void setBlockedCount(int blockedCount) {
        this.blockedCount = blockedCount;
    }

    public int getRejectedCount() {
        return rejectedCount;
    }

    public void setRejectedCount(int rejectedCount) {
        this.rejectedCount = rejectedCount;
    }

    public LocalDateTime getCreatedTimestamp() {
        return createdTimestamp;
    }

    public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
        this.createdTimestamp = createdTimestamp;
    }

    @Override
    public String toString() {
        return "MetaLeadImport [id=" + id + ", fileName=" + fileName + ", total=" + totalRows
                + ", created=" + createdCount + ", duplicate=" + duplicateCount
                + ", blocked=" + blockedCount + ", rejected=" + rejectedCount + "]";
    }
}