如何设计一个基于SSM的旅游网站管理系统
作者:互联网
本文介绍一下最近开发的一套旅游网站,有前端页面和后台管理。希望对大家有帮助。本项目是基于Java语言的SSM框架作为后台进行设计,页面采用JSP,前端使用的是JS、CSS、JQUEY、BootStrap来实现并设计页面;数据库采用目前比较流行的MYSQL数据库进行信息存储,应用服务器采用Tomcat8.0。
系统架构图:
数据结构图:
景点库:
景点详情:
旅游线路:
线路详情:
酒店列表:
酒店详情:
前台个人管理:
后台登陆:
后台管理页面:
景点管理:
线路活动管理:
酒店管理:
后台管理员可以对前端的信息进行添加、修改、发布、删除、查看等操作。
主要包括旅游线路管理、景点信息管理、订单管理、留言评论管理、酒店管理、管理员登录退出模块。
酒店管理控制器代码:
@Controller
@RequestMapping("/hotel")
public class HotelController {
@Autowired
private HotelService hotelService ;/**
* 旅游酒店前台:分页查询
*/
@RequestMapping("/pageQuery")
@ResponseBody
public PageBean<Hotel> pageQuery(String currentPage,String pageSize,String cid){int cids = 3;//类别id
//2.处理参数
if(cid != null && cid.length() > 0 && !"null".equals(cid)){
cids = Integer.parseInt(cid);
}
int currentPages = 0;//当前页码,如果不传递,则默认为第一页
if(currentPage != null && currentPage.length() > 0){
currentPages = Integer.parseInt(currentPage);
}else{
currentPages = 1;
}int pageSizes = 0;//每页显示条数,如果不传递,默认每页显示5条记录
if(pageSize != null && pageSize.length() > 0){
pageSizes = Integer.parseInt(pageSize);
}else{
pageSizes = 5;
}//3. 调用service查询PageBean对象
PageBean<Hotel> pb = hotelService.pageQuery(cids, currentPages, pageSizes);//4. 将pageBean对象序列化为json,返回
return pb;
}/**
* 根据id查询一个旅游酒店的详细信息
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/findOne")
@ResponseBody
public Hotel findOne(String tid){
//1.调用service查询hotel对象
Hotel hotel = hotelService.findOne(tid);
//2.转为json写回客户端
return hotel;
}/**
* 首页查询旅游酒店酒店
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/findAll")
@ResponseBody
public ResultInfo findAll(String limit){
int limitNum = 12;
if (limit != null && limit.length() > 0) {
limitNum = Integer.parseInt(limit);
}
List<Hotel> hotels = new ArrayList<>();boolean flag = true;
try {
hotels = hotelService.findAll(limitNum);} catch (Exception ex) {
flag = false;
ex.printStackTrace();
}
ResultInfo info = new ResultInfo();
info.setData(hotels);
info.setFlag(true);return info;
}/**
* 后台管理:旅游酒店酒店
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/findAdminAll")
public ModelAndView findAdminAll(String currentPage,String pageSize,String cid) {int cids = 3;//类别id
//2.处理参数
if(cid != null && cid.length() > 0 && !"null".equals(cid)){
cids = Integer.parseInt(cid);
}
int currentPages = 0;//当前页码,如果不传递,则默认为第一页
if(currentPage != null && currentPage.length() > 0){
currentPages = Integer.parseInt(currentPage);
}else{
currentPages = 1;
}int pageSizes = 0;//每页显示条数,如果不传递,默认每页显示5条记录
if(pageSize != null && pageSize.length() > 0){
pageSizes = Integer.parseInt(pageSize);
}else{
pageSizes = 5;
}
//3. 调用service查询PageBean对象
PageBean<Hotel> pb = hotelService.pageQueryAdmin(cids, currentPages, pageSizes);
ModelAndView mv = new ModelAndView();
mv.addObject("pb", pb);
mv.setViewName("/admin/pages/hotel-list.jsp");
return mv;
}
/**
* 后台管理:旅游酒店酒店添加
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/addHotel")
public String addHotel(HttpServletRequest request,Hotel hotel, MultipartFile myFile) throws ServletException, IOException, ParseException {
String path = request.getServletContext().getRealPath("/img/product/small/");
String newFileName = "";
if(myFile!=null&&!myFile.isEmpty()) {
String fileName = myFile.getOriginalFilename();
String suffix = fileName.substring(fileName.lastIndexOf("."));
newFileName = UUID.randomUUID() + suffix;
File file = new File(path + newFileName);
try{
myFile.transferTo(file);
}catch (Exception ex){
ex.printStackTrace();;
}}
hotel.setTdate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
hotel.setTimg("/img/product/small/"+newFileName);//执行添加功能
boolean result = hotelService.addHotel(hotel);return "redirect:/hotel/findAdminAll";
}/**
* 后台旅游酒店管理:修改查询单个酒店初始化
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/findHotelByRid")
public ModelAndView findHotelByRid(String rid){
Hotel hotel = hotelService.findOne(rid);
ModelAndView mv = new ModelAndView();
mv.addObject("hotel", hotel);
mv.setViewName("/admin/pages/hotel-update.jsp");
return mv;
}/**
* 后台管理:旅游酒店酒店添加
*
* @param request
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/addHotelImages")
public String addHotelImages(HttpServletRequest request,String tid,@RequestParam("myFiles") MultipartFile[] myFiles) throws IOException{HotelImg hotelImg = new HotelImg();
hotelImg.setTid(Integer.parseInt(tid));String path = request.getServletContext().getRealPath("/img/product/size6/");
for (MultipartFile multipartFile:myFiles) {
if(!multipartFile.isEmpty()&&multipartFile.getSize()>0) {
String fileName = multipartFile.getOriginalFilename();
String suffix = fileName.substring(fileName.lastIndexOf("."));
String newFileName = UUID.randomUUID() + suffix;
File file = new File(path + newFileName);
multipartFile.transferTo(file);
hotelImg.setSmallPic("/img/product/size6/" + newFileName);
hotelImg.setBigPic("/img/product/size6/" + newFileName);
//循环插入图片
hotelService.addHotelImgs(hotelImg);
}
}//跳转到
return "redirect:/hotel/findAdminAll";}
/**
* 后台管理:旅游酒店酒店下架---酒店不要删除,因为有关联的订单
* @param request
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/updateHotel")
public String updateHotel(HttpServletRequest request,Hotel hotel,String nowimg,MultipartFile myFile) throws IOException {
String path = request.getServletContext().getRealPath("/img/product/small/");if(myFile!=null&&!myFile.isEmpty()) {
String fileName = myFile.getOriginalFilename();
String suffix = fileName.substring(fileName.lastIndexOf("."));
String newFileName = UUID.randomUUID() + suffix;
File file = new File(path + newFileName);
myFile.transferTo(file);
hotel.setTdate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
hotel.setTimg("img/product/small/"+newFileName);
}else{
hotel.setTimg(nowimg);
}
hotel.setTdate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
//执行修改功能
boolean result = hotelService.updateHotel(hotel);
return "redirect:/hotel/findAdminAll";}
/**
* 后台旅游酒店管理:旅游酒店下线
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/updateFlag")
public String updateFlag(String rid, String rflag){
hotelService.updateFlag(rid,rflag);return "redirect:/hotel/findAdminAll";
}
}
标签:基于,酒店,String,管理系统,hotel,SSM,&&,new,throws 来源: https://blog.csdn.net/BS009/article/details/121307366