5.订单详情提交
6.房间查询
7.退换房间
三、部分代码
======
ClientDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.sqc.model.Client;
public class ClientDao {
/**
-
客户信息增加
-
@param con
-
@param client
-
@return
-
@throws Exception
*/
public int add(Connection con, Client client) throws Exception {
// TODO Auto-generated method stub
String sql = “insert into tb_client values(?,?,?,?,?)”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, client.getCid());
pstmt.setString(2, client.getCname());
pstmt.setString(3, client.getCsex());
pstmt.setInt(4, client.getCage());
pstmt.setString(5, client.getCtel());
return pstmt.executeUpdate();
}
}
ExRoomDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.ExRoom;
import com.sqc.util.StringUtil;
public class ExRoomDao {
/**
-
订单信息查询
-
@param con
-
@param exRoom
-
@return
*/
public ResultSet list(Connection con, ExRoom exRoom) throws Exception {
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer(“select oid,cid,rid,ocomedate,odays,oleavedate from tb_order”);
if (StringUtil.isNotEmpty(exRoom.getCid())) {
sb.append(" and tb_order.cid like’%" + exRoom.getCid() + “%'”);
}
if (StringUtil.isNotEmpty(exRoom.getRid())) {
sb.append(" and tb_order.rid like’%" + exRoom.getRid() + “%'”);
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));
return pstmt.executeQuery();
}
/**
-
订单修改
-
@param con
-
@param exRoom
-
@return
*/
public int update(Connection con, ExRoom exRoom) throws Exception {
// TODO Auto-generated method stub
String sql = “update tb_order set Cid=?,Rid=?,Ocomedate=?,Odays=?,Oleavedate=?”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, exRoom.getCid());
pstmt.setString(2, exRoom.getRid());
pstmt.setString(3, exRoom.getOcomedate());
pstmt.setInt(4, exRoom.getOdays());
pstmt.setString(5, exRoom.getOleavedate());
return pstmt.executeUpdate();
}
/**
-
退房事件处理
-
@param con
-
@param cid
-
@return
*/
public int delete(Connection con, String cid) throws Exception {
// TODO Auto-generated method stub
String sql = “delete from tb_order where cid=?”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, cid);
return pstmt.executeUpdate();
}
}
OrderDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.sqc.model.Client;
import com.sqc.model.Order;
public class OrderDao {
public int add(Connection con, Order order) throws Exception {
// TODO Auto-generated method stub
String sql = “insert into tb_order values(null,?,?,?,?,?)”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, order.getCid());
pstmt.setString(2, order.getRid());
pstmt.setString(3, order.getOcomedate());
pstmt.setInt(4, order.getOdays());
pstmt.setString(5, order.getOleavedate());
return pstmt.executeUpdate();
}
}
RoomDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.Room;
import com.sqc.util.StringUtil;
public class RoomDao {
public ResultSet list(Connection con, Room room) throws Exception {
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer(“select *from tb_room”);
if (StringUtil.isNotEmpty(room.getRid())) {
sb.append(" and tb_room.rid like ‘%" + room.getRid() + "%’");
}
if (StringUtil.isNotEmpty(room.getRtype())) {
sb.append(" and tb_room.rtype like ‘%" + room.getRtype() + "%’");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));
return pstmt.executeQuery();
}
}
StaffDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.Staff;
import com.sqc.util.StringUtil;
public class StaffDao {
/**
-
员工信息添加
-
@param con
-
@param staff
-
@return
-
@throws Exception
*/
public int add(Connection con, Staff staff) throws Exception {
// TODO Auto-generated method stub
String sql = “insert into tb_staff values(?,?,?,?,?)”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, staff.getSid());
pstmt.setString(2, staff.getSname());
pstmt.setString(3, staff.getSsex());
pstmt.setString(4, staff.getStel());
pstmt.setString(5, staff.getSjob());
return pstmt.executeUpdate();
}
/**
-
员工信息查询
-
@param con
-
@param staff
-
@return
*/
public ResultSet list(Connection con, Staff staff) throws Exception {
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer(“select * from tb_staff”);
if (StringUtil.isNotEmpty(staff.getSid())) {
sb.append(" and tb_staff.sid like ‘%" + staff.getSid() + "%’");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));
return pstmt.executeQuery();
}
/**
-
员工信息修改
-
@param con
-
@param staff
-
@return
-
@throws Exception
*/
public int update(Connection con, Staff staff) throws Exception {
// TODO Auto-generated method stub
String sql = “update tb_staff set sid=?,sname=?,ssex=?,stel=?,sjob=? where sid=” + staff.getSid();
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, staff.getSid());
pstmt.setString(2, staff.getSname());
pstmt.setString(3, staff.getSsex());
pstmt.setString(4, staff.getStel());
pstmt.setString(5, staff.getSjob());
return pstmt.executeUpdate();
}
/**
-
员工信息删除
-
@param con
-
@param sid
-
@return
*/
public int delete(Connection con, String sid) throws Exception {
// TODO Auto-generated method stub
String sql = “delete from tb_staff where sid=?”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, sid);
return pstmt.executeUpdate();
}
}
最后总结
搞定算法,面试字节再不怕,有需要文章中分享的这些二叉树、链表、字符串、栈和队列等等各大面试高频知识点及解析
最后再分享一份终极手撕架构的大礼包(学习笔记):分布式+微服务+开源框架+性能优化
pstmt.executeUpdate();
}
/**
-
员工信息删除
-
@param con
-
@param sid
-
@return
*/
public int delete(Connection con, String sid) throws Exception {
// TODO Auto-generated method stub
String sql = “delete from tb_staff where sid=?”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, sid);
return pstmt.executeUpdate();
}
}
最后总结
搞定算法,面试字节再不怕,有需要文章中分享的这些二叉树、链表、字符串、栈和队列等等各大面试高频知识点及解析
最后再分享一份终极手撕架构的大礼包(学习笔记):分布式+微服务+开源框架+性能优化
[外链图片转存中…(img-Aw30DOsQ-1714288301421)]