运行环境: java jdk 1.8
IDE环境: IDEA
tomcat环境: Tomcat 7.x,8.x,9.x版本均可
主要功能说明:
管理员角色包含以下功能:管理员登录,用户管理,旅游路线管理,旅游景点管理,酒店管理,旅游攻略管理,车票管理,订单管理,数据分析等功能。
用户角色包含以下功能:用户注册,用户登录,旅游路线预定,旅游景区预定,餐饮住宿,车票预定,旅游保险预定,旅游攻略,我的订单查看,个人资料管理等功能。
用了技术框架: HTML+CSS+JavaScript+jsp+mysql+Spring+Springboot+mybatis+maven+layui
所用的数据库: Mysql数据库
主要功能截图:
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
@RequestMapping("/search_attrs")
public String search_attrs(Model model,@RequestParam(value = "start" ,defaultValue = "0")Integer start,
@RequestParam(value = "limit" ,defaultValue = "6")Integer limit,
@RequestParam String search_key){
start=start<0?0:start;
Sort sort=new Sort(Sort.Direction.DESC,"id");
Pageable pageable=PageRequest.of(start,limit,sort);
Specification specification=new Specification() {
@Override
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> scenics=new ArrayList<>();
if (StringUtils.isNotBlank(search_key)){
scenics.add( criteriaBuilder.like(root.get("name"),"%"+search_key+"%"));
}
return criteriaBuilder.and(scenics.toArray(new Predicate[scenics.size()]));
}
};
Page<Scenic> page=scenicDao.findAll(specification,pageable);
model.addAttribute("name",search_key);
model.addAttribute("attrs",page);
model.addAttribute("number",page.getNumber());
model.addAttribute("numberOfElements",page.getNumberOfElements());
model.addAttribute("size",page.getSize());
Hotel newHotel = hotelService.findById(id);
if(newHotel==null){
return new Result(false,StatusCode.ERROR,"未找到该酒店!");
}
Integer currentStar = hotel.getStar();
Integer totalStar = newHotel.getStar();
if(currentStar<0){
return new Result(false,StatusCode.ERROR,"请选择评分!");
}
Integer commentCount = newHotel.getCommentCount();
commentCount=commentCount+1;
totalStar=currentStar+totalStar;
int avgStar = totalStar / commentCount;
hotel.setCommentCount(commentCount);
hotel.setStar(avgStar);
Integer hotel1 = hotelService.updateStar(hotel);
hotel_ordersService.updateStarStatus(orderId);
if(hotel1==null){
return new Result(false,StatusCode.ERROR,"评分更新失败!");
}
return new Result(true,StatusCode.OK,"评价成功!");
}
/**
* 景点评分
* @param scenic
* @return
*/
@Controller
@CrossOrigin
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;
@Autowired
private HotelOrdersService hotel_ordersService;
@Autowired
private HotelService hotelService;
@Autowired
private ScenicService scenicService;
/**
* 查询全部数据
* @return
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List<Orders> all = ordersService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
}
/**
* 查询全部订单
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",hotelService.findSearch(searchMap));
}
/**
* 修改
* @param hotel
*/
@ResponseBody
@RequestMapping(value="/edit",method= RequestMethod.PUT)
public Result update(Hotel hotel){
Hotel hotelById = hotelService.findById(hotel.getId());
if(hotelById==null){
return new Result(false,StatusCode.ERROR,"该酒店信息不存在");
}
if(StringUtils.isEmpty(hotel.getName())){
}else {
System.out.println("数据为空!");
return new Result(false,0,"","");
}
}
/**
*查询星级
* @return
*/
@ResponseBody
@RequestMapping(value = "/hotel",method = RequestMethod.POST)
public Result judgeHotelStar(Long id,String start){
Hotel scenic = hotelService.findById(id);
if (scenic!=null){
int valuestar = (Integer.valueOf(start)+Integer.valueOf(scenic.getStar()))/2;
return new Result(false,StatusCode.ERROR,"请选择评分!");
}
Integer commentCount = newHotel.getCommentCount();
commentCount=commentCount+1;
totalStar=currentStar+totalStar;
int avgStar = totalStar / commentCount;
hotel.setCommentCount(commentCount);
hotel.setStar(avgStar);
Integer hotel1 = hotelService.updateStar(hotel);
hotel_ordersService.updateStarStatus(orderId);
if(hotel1==null){
return new Result(false,StatusCode.ERROR,"评分更新失败!");
}
@CrossOrigin
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;
@Autowired
private HotelOrdersService hotel_ordersService;
@Autowired
private HotelService hotelService;
@Autowired
private ScenicService scenicService;
/**
* 查询全部数据
* @return
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List<Orders> all = ordersService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
}
/**
* 查询全部订单
* 修改
* @param
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
public Result update(@PathVariable Long id){
ordersService.updateStatus(id);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 删除
* @param id
* @param searchMap
* @return
*/
@ResponseBody
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",ordersService.findSearch(searchMap));
}
/**
* 订单添加操作
* @param orders
*/
@ResponseBody
@RequestMapping(value ="/add",method=RequestMethod.POST)
public Result add(Orders orders, HttpSession session){
//获取数量
User user = (User) session.getAttribute("user");
if (user == null){
return new Result(false,StatusCode.ACCESSERROR,"请登录");
}
return ordersService.add(orders,user.getId(),orders.getId(),orders.getQty());
}
* 订单添加操作
* @param orders
*/
@ResponseBody
@RequestMapping(value ="/add",method=RequestMethod.POST)
public Result add(Orders orders, HttpSession session){
//获取数量
User user = (User) session.getAttribute("user");
if (user == null){
return new Result(false,StatusCode.ACCESSERROR,"请登录");
}
return ordersService.add(orders,user.getId(),orders.getId(),orders.getQty());
}
public String localRefresh(Model model,Long id) {
Scenic scenic=scenicService.findById(id);
System.out.println(scenic.toString());
List<Hotel> hotels=hotelService.findByCountryLike(scenic.getContry());
Collections.sort(hotels, new Comparator<Hotel>() {
@Override
public int compare(Hotel o1, Hotel o2) {
if (o1.getStar()<o2.getStar()){
return 2;
}
if (o1.getStar().equals(o2.getStar()) ){
return 1;
}
return -1;
}
});
if (hotels.size()>=4){
List newList=hotels.subList(0,3);
model.addAttribute("scenics",newList);
System.out.println("个数:"+newList.size());
}else {
model.addAttribute("scenics",hotels);
System.out.println("个数2:"+hotels.size());
}
return "page/product::table_refresh";