71 lines
1.8 KiB
Java
71 lines
1.8 KiB
Java
package com.rsscripting.rswarehouse.dao;
|
|
|
|
import com.rsscripting.rswarehouse.database.DatabaseManager;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.PreparedStatement;
|
|
import java.time.LocalDate;
|
|
|
|
public class DiscoveryDAO {
|
|
|
|
public static void assignDiscovererIfNull(
|
|
int inventoryId,
|
|
String discovererUuid,
|
|
String discovererName
|
|
) {
|
|
|
|
try (
|
|
|
|
Connection connection =
|
|
DatabaseManager.getConnection()
|
|
|
|
) {
|
|
|
|
PreparedStatement statement =
|
|
connection.prepareStatement(
|
|
"""
|
|
UPDATE warehouse_inventory
|
|
SET
|
|
discoverer_uuid = ?,
|
|
discoverer_name = ?,
|
|
discovered_date = ?
|
|
WHERE
|
|
id = ?
|
|
AND
|
|
discoverer_uuid IS NULL
|
|
"""
|
|
);
|
|
|
|
statement.setString(
|
|
1,
|
|
discovererUuid
|
|
);
|
|
|
|
statement.setString(
|
|
2,
|
|
discovererName
|
|
);
|
|
|
|
statement.setString(
|
|
3,
|
|
LocalDate.now().toString()
|
|
);
|
|
|
|
statement.setInt(
|
|
4,
|
|
inventoryId
|
|
);
|
|
|
|
int updated =
|
|
statement.executeUpdate();
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|