修复查询bug

Wangyanyixiang_branch
RichardWang 4 months ago
parent 668c076cd0
commit b77b3ebca3

@ -35,9 +35,9 @@ public class search_fly extends HttpServlet {
String departure = req.getParameter("departure");
String destination = req.getParameter("destination");
String departureYear = req.getParameter("departureYear");
String departureMonth = req.getParameter("departureMonth");
String departureDay = req.getParameter("departureDay");
//String departureYear = req.getParameter("departureYear");
//String departureMonth = req.getParameter("departureMonth");
//String departureDay = req.getParameter("departureDay");
String date=req.getParameter("date");
String sql = null;
/*
@ -47,12 +47,7 @@ public class search_fly extends HttpServlet {
} else {
sql = "SELECT * FROM flight WHERE 1=1";
if (!departure.isEmpty()) {
sql += " AND f_s_p='" + departure + "'";
}
if (!destination.isEmpty()) {
sql += " AND f_a_p='" + destination + "'";
}
if (!departureYear.isEmpty() && !departureMonth.isEmpty() && !departureDay.isEmpty()) {
// 楠岃瘉鏃ユ湡鏍煎紡
try {
@ -76,8 +71,15 @@ public class search_fly extends HttpServlet {
} else {
// 构建SQL查询语句
sql = "SELECT * FROM flight WHERE 1=1";
sql += " AND DATE(f_Date)='" + date + "'";
if(!date.isEmpty()) {
sql += " AND DATE(f_Date)='" + date + "'";
}
if (!departure.isEmpty()) {
sql += " AND f_s_p='" + departure + "'";
}
if (!destination.isEmpty()) {
sql += " AND f_a_p='" + destination + "'";
}
db_conn conn = new db_conn();
ArrayList<flight> flightlist = new ArrayList<flight>();

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Sun Oct 20 16:16:16 CST 2024
#Tue Oct 22 14:56:12 CST 2024
artifactId=air_ticket_book
groupId=air_ticket_book
m2e.projectLocation=C\:\\Users\\RichardWang\\Desktop\\ai_agent

Loading…
Cancel
Save