基于javaweb+mysql的springboot酒店预定管理系统(springboot+mysql+javascript+css+jsp)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot酒店预定管理系统(springboot+mysql+javascript+css+jsp)
管理员
root 123456
用户
123 123456
st1 123456
t1 123456
222 123456
userService.logout(username,password);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/logoff.jsp?msg="+ Status.failure;
}
return "redirect:/login.jsp?msg="+ Status.Success;
}
@RequestMapping("login")
public String login(String username,String password,HttpServletRequest request) throws UnsupportedEncodingException {
try{
User user = userService.login(username, password);
if (user.getIdentity().equals("Admin")){
return "redirect:/user/list";
}
request.getSession().setAttribute("user",user);
}catch (Exception e){
e.printStackTrace();
return "redirect:/login.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/user/stlist";
}
@RequestMapping("restore")
public String restorelist(HttpServletRequest request){
List<User> list = userService.restore();
request.setAttribute("userlist",list);
return "user";
}
@RequestMapping("stlist")
public String signlist(HttpServletRequest request){
List<Student> stlist = userService.stlist();
request.setAttribute("stlists",stlist);
return "sign";
}
@RequestMapping("checklist")
public String checklist(HttpServletRequest request){
List<Student> stlist = userService.stlist();
request.setAttribute("stlists",stlist);
return "check";
}
@RequestMapping("sign")
public String sign(Student student,Long id,HttpServletRequest request){
try {
userService.save(student);
}catch(RuntimeException e){
* @throws UnsupportedEncodingException
*/
@RequestMapping("register")
public String register(User user, String code,HttpServletRequest request) throws UnsupportedEncodingException {
try{
String registercode = request.getSession().getAttribute("code").toString();
if(!registercode.equalsIgnoreCase(code)) throw new RuntimeException("验证码输入错误");
userService.register(user);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/register.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/login.jsp";
}
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("code")
private void code(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
char ch;
int width = 90, height = 30;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(Color.GRAY);
g.fillRect(0, 0, width, height);
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
int jiaodu = random.nextInt(60) - 30;
double hudu = jiaodu * Math.PI / 180;
g.rotate(hudu, x, y);
int index = random.nextInt(data.length());
ch = data.charAt(index);
sb.append(ch);
g.drawString("" + ch, x, y);
g.rotate(-hudu, x, y);
x += 15;
}
request.getSession().setAttribute("code", sb.toString());
g.setColor(Color.PINK);
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
int jiaodu = random.nextInt(60) - 30;
double hudu = jiaodu * Math.PI / 180;
g.rotate(hudu, x, y);
int index = random.nextInt(data.length());
ch = data.charAt(index);
sb.append(ch);
g.drawString("" + ch, x, y);
g.rotate(-hudu, x, y);
x += 15;
}
request.getSession().setAttribute("code", sb.toString());
g.setColor(Color.PINK);
ImageIO.write(img, "jpg", response.getOutputStream());
}
@RequestMapping("list")
public String list(HttpServletRequest request){
List<User> list = userService.userlist();
request.setAttribute("userlist",list);
return "user";
}
@RequestMapping("detail")
public String detail(Long id,HttpServletRequest request){
User user = userService.idByuser(id);
request.setAttribute("userbyid",user);
return "userinfo";
}
@RequestMapping("update")
public String updateUser(User user){
userService.update(user);
return "redirect:/user/list";
}
}
@Controller
@RequestMapping("check")
public class CheckController {
@Autowired
private CheckService checkService;
@RequestMapping("search")
public String search(HttpServletRequest request){
String checkname = request.getParameter("checkname");
List<Records> recordsList = checkService.idbyname(checkname);
request.setAttribute("searchlist",recordsList);
return "search";
}
@RequestMapping("list")
public String signlist(HttpServletRequest request){
List<Records> list = checkService.list();
request.setAttribute("signlist",list);
return "check";
}
@RequestMapping("update")
public String update(Records records){
checkService.update(records);
// checkService.updatestu(records.getCheckstatus());
}
/**
* 注册的逻辑
* @param user
* @param code
* @param request
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping("register")
public String register(User user, String code,HttpServletRequest request) throws UnsupportedEncodingException {
try{
String registercode = request.getSession().getAttribute("code").toString();
if(!registercode.equalsIgnoreCase(code)) throw new RuntimeException("验证码输入错误");
userService.register(user);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/register.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/login.jsp";
}
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("code")
private void code(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
char ch;
int width = 90, height = 30;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(Color.GRAY);
g.fillRect(0, 0, width, height);
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("code")
private void code(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
char ch;
int width = 90, height = 30;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(Color.GRAY);
g.fillRect(0, 0, width, height);
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
int jiaodu = random.nextInt(60) - 30;
double hudu = jiaodu * Math.PI / 180;
g.rotate(hudu, x, y);
int index = random.nextInt(data.length());
ch = data.charAt(index);
sb.append(ch);
g.drawString("" + ch, x, y);
g.rotate(-hudu, x, y);
x += 15;
}
request.getSession().setAttribute("code", sb.toString());
g.setColor(Color.PINK);
ImageIO.write(img, "jpg", response.getOutputStream());
}
@RequestMapping("list")
public String list(HttpServletRequest request){
List<User> list = userService.userlist();
request.setAttribute("userlist",list);
return "user";
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/register.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/login.jsp";
}
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("code")
private void code(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
char ch;
int width = 90, height = 30;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(Color.GRAY);
g.fillRect(0, 0, width, height);
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
int jiaodu = random.nextInt(60) - 30;
double hudu = jiaodu * Math.PI / 180;
g.rotate(hudu, x, y);
int index = random.nextInt(data.length());
ch = data.charAt(index);
sb.append(ch);
g.drawString("" + ch, x, y);
g.rotate(-hudu, x, y);
x += 15;
}
request.getSession().setAttribute("code", sb.toString());
g.setColor(Color.PINK);
ImageIO.write(img, "jpg", response.getOutputStream());
request.setAttribute("stlists",stlist);
return "sign";
}
@RequestMapping("checklist")
public String checklist(HttpServletRequest request){
List<Student> stlist = userService.stlist();
request.setAttribute("stlists",stlist);
return "check";
}
@RequestMapping("sign")
public String sign(Student student,Long id,HttpServletRequest request){
try {
userService.save(student);
}catch(RuntimeException e){
e.printStackTrace();
return "redirect:/user/stlist?msg="+Status.failure;
}
return "redirect:/user/stlist?msg="+Status.Success;
}
/**
* 注册的逻辑
* @param user
* @param code
* @param request
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping("register")
public String register(User user, String code,HttpServletRequest request) throws UnsupportedEncodingException {
try{
String registercode = request.getSession().getAttribute("code").toString();
if(!registercode.equalsIgnoreCase(code)) throw new RuntimeException("验证码输入错误");
userService.register(user);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/register.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/login.jsp";
}
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
public String detail(Long id,HttpServletRequest request){
Records records = checkService.idbysignin(id);
request.setAttribute("records",records);
return "checkinfo";
}
@RequestMapping("delete")
public String delete(Long id){
checkService.delete(id);
return "redirect:/check/list";
}
}
@Controller
@RequestMapping("course")
public class CourseController {
@Autowired
private CourseService courseService;
@RequestMapping("/list")
public String courselist(HttpServletRequest request){
List<Course> courses = courseService.courseList();
request.setAttribute("courses",courses);
return "course";
}
@RequestMapping("update")
public String updatecourse(Long id,Course course){
courseService.update(course);
return "redirect:/course/list";
}
@RequestMapping("/delete")
public String deleteUser(int id){
courseService.delete(id);
@RequestMapping("update")
public String update(Records records){
checkService.update(records);
// checkService.updatestu(records.getCheckstatus());
return "redirect:/check/list";
}
@RequestMapping("detail")
public String detail(Long id,HttpServletRequest request){
Records records = checkService.idbysignin(id);
request.setAttribute("records",records);
return "checkinfo";
}
@RequestMapping("delete")
public String delete(Long id){
checkService.delete(id);
return "redirect:/check/list";
}
}
@Controller
@RequestMapping("course")
public class CourseController {
@Autowired
private CourseService courseService;
@RequestMapping("/list")
public String courselist(HttpServletRequest request){
List<Course> courses = courseService.courseList();
request.setAttribute("courses",courses);
@RequestMapping("login")
public String login(String username,String password,HttpServletRequest request) throws UnsupportedEncodingException {
try{
User user = userService.login(username, password);
if (user.getIdentity().equals("Admin")){
return "redirect:/user/list";
}
request.getSession().setAttribute("user",user);
}catch (Exception e){
e.printStackTrace();
return "redirect:/login.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/user/stlist";
}
@RequestMapping("restore")
public String restorelist(HttpServletRequest request){
List<User> list = userService.restore();
request.setAttribute("userlist",list);
return "user";
}
@RequestMapping("stlist")
public String signlist(HttpServletRequest request){
List<Student> stlist = userService.stlist();
request.setAttribute("stlists",stlist);
return "sign";
}
@RequestMapping("checklist")
public String checklist(HttpServletRequest request){
List<Student> stlist = userService.stlist();
request.setAttribute("stlists",stlist);
return "check";
}
@RequestMapping("sign")
public String sign(Student student,Long id,HttpServletRequest request){
try {
userService.save(student);
}catch(RuntimeException e){
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
int jiaodu = random.nextInt(60) - 30;
double hudu = jiaodu * Math.PI / 180;
g.rotate(hudu, x, y);
int index = random.nextInt(data.length());
ch = data.charAt(index);
sb.append(ch);
g.drawString("" + ch, x, y);
g.rotate(-hudu, x, y);
x += 15;
}
request.getSession().setAttribute("code", sb.toString());
g.setColor(Color.PINK);
ImageIO.write(img, "jpg", response.getOutputStream());
}
@RequestMapping("list")
public String list(HttpServletRequest request){
List<User> list = userService.userlist();
request.setAttribute("userlist",list);
return "user";
}
@RequestMapping("detail")
public String detail(Long id,HttpServletRequest request){
User user = userService.idByuser(id);
request.setAttribute("userbyid",user);
return "userinfo";
}
@RequestMapping("update")
public String updateUser(User user){
userService.update(user);
return "redirect:/user/list";
}
@RequestMapping("/delete")
public String deleteUser(Long id){
userService.delete(id);
return "redirect:/user/list";
}
}
return "redirect:/user/stlist?msg="+Status.Success;
}
/**
* 注册的逻辑
* @param user
* @param code
* @param request
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping("register")
public String register(User user, String code,HttpServletRequest request) throws UnsupportedEncodingException {
try{
String registercode = request.getSession().getAttribute("code").toString();
if(!registercode.equalsIgnoreCase(code)) throw new RuntimeException("验证码输入错误");
userService.register(user);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/register.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/login.jsp";
}
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("code")
private void code(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
char ch;
int width = 90, height = 30;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(Color.GRAY);
g.fillRect(0, 0, width, height);
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
int jiaodu = random.nextInt(60) - 30;
User user = userService.idByuser(id);
request.setAttribute("userbyid",user);
return "userinfo";
}
@RequestMapping("update")
public String updateUser(User user){
userService.update(user);
return "redirect:/user/list";
}
@RequestMapping("/delete")
public String deleteUser(Long id){
userService.delete(id);
return "redirect:/user/list";
}
}
@Controller
@RequestMapping("check")
public class CheckController {
@Autowired
private CheckService checkService;
@RequestMapping("search")
public String search(HttpServletRequest request){
String checkname = request.getParameter("checkname");
List<Records> recordsList = checkService.idbyname(checkname);
request.setAttribute("searchlist",recordsList);
return "search";
}
@RequestMapping("list")
@RequestMapping("course")
public class CourseController {
@Autowired
private CourseService courseService;
@RequestMapping("/list")
public String courselist(HttpServletRequest request){
List<Course> courses = courseService.courseList();
request.setAttribute("courses",courses);
return "course";
}
@RequestMapping("update")
public String updatecourse(Long id,Course course){
courseService.update(course);
return "redirect:/course/list";
}
@RequestMapping("/delete")
public String deleteUser(int id){
courseService.delete(id);
return "redirect:/course/list";
}
}
@Controller
@RequestMapping("/set")
@Controller
@RequestMapping("user")
public class UserController {
@Autowired
private UserService userService;
/**
* 备份数据
*/
@RequestMapping("backup")
public String backup(){
userService.backup();
return "redirect:/user/list";
}
@RequestMapping("logout")
public String cancellation(String username,String password,HttpSession session) throws UnsupportedEncodingException {
try {
userService.logout(username,password);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/logoff.jsp?msg="+ Status.failure;
}
return "redirect:/login.jsp?msg="+ Status.Success;
}
return "redirect:/user/stlist?msg="+Status.Success;
}
/**
* 注册的逻辑
* @param user
* @param code
* @param request
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping("register")
public String register(User user, String code,HttpServletRequest request) throws UnsupportedEncodingException {
try{
String registercode = request.getSession().getAttribute("code").toString();
if(!registercode.equalsIgnoreCase(code)) throw new RuntimeException("验证码输入错误");
userService.register(user);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/register.jsp?msg="+ URLEncoder.encode(e.getMessage(),"UTF-8");
}
return "redirect:/login.jsp";
}
/**
* 验证码的逻辑
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("code")
private void code(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
char ch;
int width = 90, height = 30;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(Color.GRAY);
g.fillRect(0, 0, width, height);
g.setColor(Color.GREEN);
g.drawRect(0, 0, width - 1, height - 1);
Random random = new Random();
g.setFont(new Font("黑体", Font.BOLD, 20));
int x = 20, y = 20;
String data = "QWERTYUIOPASDGHJKLZXCVBNM13456789";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++) {
@Controller
@RequestMapping("user")
public class UserController {
@Autowired
private UserService userService;
/**
* 备份数据
*/
@RequestMapping("backup")
public String backup(){
userService.backup();
return "redirect:/user/list";
}
@RequestMapping("logout")
public String cancellation(String username,String password,HttpSession session) throws UnsupportedEncodingException {
try {
userService.logout(username,password);
}catch (RuntimeException e){
e.printStackTrace();
return "redirect:/logoff.jsp?msg="+ Status.failure;
}
return "redirect:/login.jsp?msg="+ Status.Success;
}
@RequestMapping("login")
public String login(String username,String password,HttpServletRequest request) throws UnsupportedEncodingException {
try{
User user = userService.login(username, password);
if (user.getIdentity().equals("Admin")){
return "redirect:/user/list";
}
request.getSession().setAttribute("user",user);