package com.utopiaindustries.dao.ctp;

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

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

public class StoreItemRowMapper implements RowMapper<StoreItem> {
    @Override
    public StoreItem mapRow(ResultSet rs, int rowNum) throws SQLException {
        StoreItem item = new StoreItem();
        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.setFinishedItemId(rs.getLong("finish_item_id"));
        item.setAccountId(rs.getLong("account_id"));
        item.setBundleId(rs.getLong("bundle_id"));
        item.setRejectedReason(rs.getString("reject_reason"));
        return item;
    }
}