package com.utopiaindustries.dao.ctp;

import com.utopiaindustries.model.ctp.PackagingItems;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

public class PackagingItemsRowMapper implements RowMapper<PackagingItems> {
    @Override
    public PackagingItems mapRow(ResultSet rs, int rowNum) throws SQLException {
        PackagingItems item = new PackagingItems();
        item.setId(rs.getLong("id"));
        item.setItemId(rs.getLong("item_id"));
        item.setSku(rs.getString("sku"));
        item.setBarcode(rs.getString("barcode"));
        item.setJobCardId(rs.getLong("job_card_id"));
        item.setCreatedAt(rs.getTimestamp("created_at") != null ? rs.getTimestamp("created_at").toLocalDateTime() : null);
        item.setCreatedBy(rs.getString("created_by"));
        item.setIsQa(rs.getBoolean("is_qa"));
        item.setFinishedItemId(rs.getLong("finish_item_id"));
        item.setIsSegregated(rs.getBoolean("is_segregated"));
        item.setAccountId(rs.getLong("account_id"));
        item.setQaStatus(rs.getString("qa_status"));
        item.setBundleId(rs.getLong("bundle_id"));
        item.setAccountTitle(rs.getString("account_title"));
        return item;
    }
}
