You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xian/IndexController

39 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.power.travel.controller;
import com.power.travel.model.TravelRoute;
import com.power.travel.service.ReserveService;
import com.power.travel.service.RouteService;
import com.power.travel.service.StrategyService;
import com.power.travel.model.Attractions;
import com.power.travel.model.Hotel;
import com.power.travel.model.TravelStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
//@Controller这是一个Spring MVC的注解它表示这个类是一个控制器类用于处理用户的请求
@Controller
public class IndexController {
@Autowired
private ReserveService reserveService;
@Autowired
private RouteService routeService;
@Autowired
private StrategyService strategyService;
// index(Model model)这是IndexController类的一个方法它用于处理用户访问首页的请求
@RequestMapping("/")
public String index(Model model) {
List<Hotel> top10Hotel = reserveService.getTop10Hotel();
List<Attractions> top10Attractions = reserveService.getTop10Attractions();
List<TravelRoute> top10Route = routeService.findTop10Route();
List<TravelStrategy> top10Strategy = strategyService.findTop10Strategy();
model.addAttribute("top10Strategy",top10Strategy);
model.addAttribute("top10Route", top10Route);
model.addAttribute("top10Hotel", top10Hotel);
model.addAttribute("top10Attractions", top10Attractions);
return "index";
}
}