基于javaweb+mysql的ssm旅游景点门票管理系统(java+ssm+jsp+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM旅游景点门票管理系统(java+ssm+jsp+mysql)
jsp+ssm(spring+springMVC+mybatis)+MySQL实现的在线旅游景点信息管理系统,系统主要实现的功能有:用户浏览搜索景点游玩路线、用户注册登录、下单预定旅游产品等。后台管理员可对旅游产品进行管理、包括旅游的主题、产品、用户、定制、订单等。
@Controller
@RequestMapping("/manager/theme")
public class ThemeManageController {
@Autowired
private IThemeService themeService;
@ResponseBody
@RequestMapping("/save")
public ServerResponse save(Theme theme){
return ServerResponse.createByResult(theme.insert());
}
@ResponseBody
@RequestMapping("/update/{tId}")
public ServerResponse update(@PathVariable String tId, Theme theme){
theme.setId(tId);
return ServerResponse.createByResult(theme.updateById());
}
@ResponseBody
@RequestMapping("/delete/{tId}")
public ServerResponse delete(@PathVariable String tId){
Theme theme=new Theme();
theme.setId(tId);
return ServerResponse.createByResult(theme.deleteById());
}
@RequestMapping("/detailView/{id}")
public String themeView(@PathVariable String id, Model model){
Theme theme=new Theme();
theme.setId(id);
model.addAttribute("theme",theme.selectById());
return "backend/theme_add";
}
@RequestMapping("/addView")
public String addView(){
return "backend/theme_add";
}
@RequestMapping("/test")
/**
* <p>
* 前端控制器
* </p>
*
*/
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private IUserService userService;
@Autowired
private IEmailValidateService emailValidateService;
/**
* 注册
* @param user
* @return
*/
@PostMapping("/register")
@ResponseBody
public ServerResponse<String> register (User user, String registerCode){
System.out.println(user.toString());
//对传参进行校验
//验证邮箱验证码
EntityWrapper<EmailValidate> entityWrapper=new EntityWrapper<>();
entityWrapper.eq("email",user.getEmail())
.eq("validate_code",registerCode);
if(emailValidateService.selectCount(entityWrapper)<=0){
return ServerResponse.createByErrorMessage("注册码错误");
/**
* <p>
* 地区码表 前端控制器
* </p>
*
*/
@Controller
@RequestMapping("/manager/area")
public class AreaManageController {
@ResponseBody
@RequestMapping("/create")
public ServerResponse create(Area area){
if (StringUtils.isBlank(area.getAreaName())||null==area.getLevel()){
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}else if (null!=area.selectOne(new EntityWrapper().eq("areaName",area.getAreaName()))){
return ServerResponse.createByErrorMessage("城市已存在");
}
return ServerResponse.createByResult(area.insert());
}
}
/**
ServerResponse serverResponse;
try {
serverResponse= productOrderService.createOrder(productOrder,productSell);
} catch (Exception e) {
e.printStackTrace();
return ServerResponse.createByErrorMessage("购买失败");
}
return serverResponse;
}
@ResponseBody
@RequestMapping("/myOrder")
public ServerResponse myOrderList(HttpSession session){
User user = (User)session.getAttribute(Const.CURRENT_USER);
if(user == null){
return ServerResponse.createByErrorMessage("用户未登录");
}
return ServerResponse.createBySuccess(productOrderService.myOrderList(user.getId()));
}
@RequestMapping("/orderView")
public String myOrderListView(HttpSession session, Model model){
User user = (User)session.getAttribute(Const.CURRENT_USER);
if(user == null){
return "index/index";
}
List<OrderList> orderLists=productOrderService.myOrderList(user.getId());
model.addAttribute("user",user);
model.addAttribute("orderLists",orderLists);
return "index/my_order";
}
//根据销量排行
@RequestMapping("/hot")
@ResponseBody
public List<Product> hotProduct(int size){
EntityWrapper entityWrapper=new EntityWrapper();
entityWrapper.groupBy("product_id");
entityWrapper.orderBy("COUNT(*)",false);
// entityWrapper.orderDesc()
return productOrderService.selectList(entityWrapper);
}
@ResponseBody
public ServerResponse<String>checkEmail(@PathVariable String id){
}*/
}
/**
*/
@Controller
public class IndexController {
@Autowired
private IProductService productService;
@Autowired
private IThemeService themeService;
@Autowired
private IThemeProductService ithemeProductService;
@RequestMapping("/register")
public String register(){
return "index/register";
}
@RequestMapping("/customized")
public String customized(){
return "index/customized";
}
/**
* 新增
* @return
*/
@RequestMapping("/save")
@ResponseBody
public ServerResponse save(Product product, ProductDesc productDesc, String[] themeName){
System.out.println(product.getPrice());
ThemeProduct[] themeProducts=new ThemeProduct[themeName.length];
for (int i=0;i<themeName.length;i++){
String themeId=themeService.selectIdByName(themeName[i]);
if (null==themeId){
return ServerResponse.createByErrorMessage("不存在该主题");
}
themeProducts[i]=new ThemeProduct();
themeProducts[i].setThemeId(themeId);
themeProducts[i].setThemeName(themeName[i]);
}
try {
productService.create(product,productDesc,themeProducts);
} catch (Exception e) {
return ServerResponse.createByError();
}
return ServerResponse.createBySuccess();
}
@RequestMapping("/update/{pid}")
@ResponseBody
public ServerResponse update(@PathVariable String pid, Product product, ProductDesc productDesc, String[] themeName){
product.setPid(pid);
ThemeProduct[] themeProducts=new ThemeProduct[themeName.length];
for (int i=0;i<themeName.length;i++){
List<Customization> customizations=customizationService.selectListByUid(user.getId());
model.addAttribute("customizations",customizations);
model.addAttribute("user",user);
return "index/cuslist";
}
@RequestMapping("/detailView/{id}")
public String detailView(@PathVariable String id, Model model){
Customization customization=customizationService.selectById(id);
model.addAttribute("cus",customization);
return "index/cus_detail";
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@Controller
@RequestMapping("/manager/productOrder")
public class ProductManageOrderController {
@Autowired
private IProductOrderService productOrderService;
@RequestMapping("/list")
@ResponseBody
public ServerResponse list(String keyword, @RequestParam(value="current",defaultValue="1") int current, @RequestParam(value="size",defaultValue="10") int size){
EntityWrapper entityWrapper=new EntityWrapper();
*/
@Controller
public class IndexController {
@Autowired
private IProductService productService;
@Autowired
private IThemeService themeService;
@Autowired
private IThemeProductService ithemeProductService;
@RequestMapping("/register")
public String register(){
return "index/register";
}
@RequestMapping("/customized")
public String customized(){
return "index/customized";
}
@RequestMapping("/navigation")
public String navigation(){
return "index/navigation";
}
@RequestMapping("/productlistView")
public String plView(Model model){
List<Theme> themes=themeService.selectList(null);
model.addAttribute("themes",themes);
return "index/product_list";
}
@RequestMapping("/indexView")
public String indexView(Model model){
List<Product> productList=productService.getIndexproduct(6);
List<Product> hotPList=productService.hotProduct(6);
model.addAttribute("hotPList",hotPList);
model.addAttribute("productList",productList);
List<Theme> selectList = themeService.selectList(null);
List<Theme> subList;
if(selectList.size()>=7) {
subList = selectList.subList(0, 7);
model.addAttribute("themeList", subList);
}else {
@ResponseBody
public ServerResponse list(@RequestParam Map map, @RequestParam(value="current",defaultValue="1") int current, @RequestParam(value="size",defaultValue="10") int size){
EntityWrapper entityWrapper=new EntityWrapper();
if (map.get("startAreaname")!=null&&!"".equals(map.get("startAreaname"))){
String startAreaname= (String) map.get("startAreaname");
entityWrapper.eq("start_areaName",startAreaname);
}
if (map.get("endAreaname")!=null&&!"".equals(map.get("endAreaname"))){
String endAreaname= (String) map.get("endAreaname");
entityWrapper.eq("end_areaName",endAreaname);
}
if (map.get("title")!=null&&!"".equals(map.get("title"))){
String title= (String) map.get("title");
entityWrapper.like("title",title);
}
if (map.get("activeDays")!=null&&!"不限".equals(map.get("activeDays"))){
String activeDays= (String) map.get("activeDays");
int day;
if (activeDays.equals("1-2天")){
entityWrapper.le("active_days",2);
}else if (activeDays.equals("3-5天")){
entityWrapper.between("active_days",3,5);
}else{
entityWrapper.gt("active_days",5);
}
}
if (map.get("orderBy")!=null){
String orderBy= (String) map.get("orderBy");
if (orderBy.equals("priceAsc")){
entityWrapper.orderBy("price",true);
}else if (orderBy.equals("priceDesc")){
entityWrapper.orderBy("price",false);
}
}else {
entityWrapper.orderBy("create_time",false);
}
if (map.get("type")!=null&&!"全部".equals(map.get("type"))){
String type= (String) map.get("type");
List<ThemeProduct> tplist=themeProductService.selectList(new EntityWrapper<ThemeProduct>().eq("theme_name",type));
List idlist=new ArrayList();
for (ThemeProduct themeProduct:tplist){
idlist.add(themeProduct.getProductId());
}
entityWrapper.in("pid",idlist);
}
if (map.get("status")!=null){
int status= Integer.parseInt((String) map.get("status"));
entityWrapper.eq("status",status);//上架产品
}
return ServerResponse.createBySuccess(productService.selectPage(new Page<Product>(current,size),entityWrapper));
}
if (current<=0||size<=0){
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}
EntityWrapper entityWrapper=null;
if (status!=null&&!"".equals(status)){
entityWrapper=new EntityWrapper();
entityWrapper.eq("status",Integer.parseInt(status));
}
return ServerResponse.createBySuccess(customizationService.selectMapsPage(new Page(current,size),entityWrapper)) ;
}
}
/**
* <p>
* 前端控制器
* </p>
*
}
}
/**
* <p>
* 地区码表 前端控制器
* </p>
*
*/
@Controller
@RequestMapping("/manager/area")
public class AreaManageController {
@ResponseBody
@RequestMapping("/create")
public ServerResponse create(Area area){
if (StringUtils.isBlank(area.getAreaName())||null==area.getLevel()){
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}else if (null!=area.selectOne(new EntityWrapper().eq("areaName",area.getAreaName()))){
return ServerResponse.createByErrorMessage("城市已存在");
}
return ServerResponse.createByResult(area.insert());
}
}
/**
*/
public class LoginInterceptor implements HandlerInterceptor {
private void isLogin(HttpSession session){
}
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
StringBuffer requestURL = httpServletRequest.getRequestURL();
System.out.println(requestURL);
User user = (User) httpServletRequest.getSession().getAttribute(Const.ADMIN_USER);
if (user==null){
System.out.println("尚未登录,调到登录页面");
httpServletResponse.sendRedirect("${pageContext.request.contextPath}/adminLoginView");
return false;
}
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
System.out.println("postHandle");
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
System.out.println("afterCompletion");
}
}
model.addAttribute("cus",customization);
return "index/cus_detail";
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@Controller
@RequestMapping("/manager/productOrder")
public class ProductManageOrderController {
@Autowired
private IProductOrderService productOrderService;
@RequestMapping("/list")
@ResponseBody
public ServerResponse list(String keyword, @RequestParam(value="current",defaultValue="1") int current, @RequestParam(value="size",defaultValue="10") int size){
EntityWrapper entityWrapper=new EntityWrapper();
if (keyword!=null&!"".equals(keyword)){
entityWrapper.eq("order_no",keyword).or().eq("username",keyword);
entityWrapper.orderBy("create_time",false);
return "backend/fileupload";
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@Controller
@RequestMapping("/theme")
public class ThemeController {
@Autowired
private IThemeService themeService;
//
@ResponseBody
@RequestMapping("/{tid}")
public ServerResponse detail(@PathVariable String tid){
Theme theme=new Theme();
theme.setId(tid);
return ServerResponse.createBySuccess(theme.selectById());
public String addUser(User user) {
return "backend/user_add";
}
/**
* 添加新会员
* @param model
* @param user
* @return
*/
@ResponseBody
@RequestMapping(value="userAdd",method=RequestMethod.POST)
public ServerResponse<String> userAdd(Model model,User user) {
User checkUserByName = userService.checkUserByName(user.getUsername());
if(checkUserByName!=null) {
return ServerResponse.createByErrorCodeMessage(302, "用户名已存在!");
}
if(!StringUtils.isNotEmpty(user.getUsername())) {
return ServerResponse.createByErrorCodeMessage(300, "用户名不能为空!");
}
if(!StringUtils.isNotEmpty(user.getPassword())) {
return ServerResponse.createByErrorCodeMessage(301, "密码不能为空!");
}
user.setRole(10);
user.setCreateTime(new Date());
if (user.insert()){
return ServerResponse.createBySuccessMessage("添加成功");
}else{
return ServerResponse.createByError();
}
}
@RequestMapping("/loginView")
public String loginView(){
return "backedn/login";
}
}
@ResponseBody
public ServerResponse insertBatch(ProductSell productSells, int days){
if (days>30){
return ServerResponse.createByErrorMessage("不能连续设置超过30天的产品销售");
}
ArrayList<ProductSell> productSellArrayList=new ArrayList<>();
for (int i=1;i<=days;i++){
ProductSell productSell=new ProductSell(productSells);
Calendar c = Calendar.getInstance();
c.setTime(productSell.getStartDate());
c.add(Calendar.DAY_OF_MONTH, i);// +i天
productSell.setStartDate(c.getTime());
productSell.setCreateTime(new Date());
productSellArrayList.add(productSell);
}
return ServerResponse.createByResult(productSellService.insertBatch(productSellArrayList));
}
@RequestMapping("/addView")
public String addView(String pid, String title,Double price, Model model) throws UnsupportedEncodingException {
String param = new String(title.getBytes("UTF-8"), "UTF-8");//解决get乱码
model.addAttribute("pid",pid);
model.addAttribute("title",param);
model.addAttribute("price",price);
return "backend/productSell_add";
}
@RequestMapping("/listView/{pid}")
public String listView(@PathVariable String pid,Model model){
model.addAttribute("pid",pid);
return "backend/productSell_list";
}
@RequestMapping("/updateView/{id}")
public String updateView(@PathVariable String id,Model model){
model.addAttribute("productSell", productSellService.selectById(id));
return "backend/productSell_update";
}
}
entityWrapper.eq("order_no",keyword).or().eq("username",keyword);
entityWrapper.orderBy("create_time",false);
}
return ServerResponse.createBySuccess(productOrderService.selectPage(new Page<ProductOrder>(current,size),entityWrapper));
}
@RequestMapping("/detailView/{id}")
public String detailView(@PathVariable String id, Model model){
ProductOrder productOrder=productOrderService.selectById(id);
model.addAttribute("order",productOrder);
return "backend/order_detail";
}
@RequestMapping("/listView")
public String listView(){
return "backend/order_list";
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
*/
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private IUserService userService;
@Autowired
private IEmailValidateService emailValidateService;
/**
* 注册
* @param user
* @return
*/
@PostMapping("/register")
@ResponseBody
public ServerResponse<String> register (User user, String registerCode){
System.out.println(user.toString());
//对传参进行校验
//验证邮箱验证码
EntityWrapper<EmailValidate> entityWrapper=new EntityWrapper<>();
entityWrapper.eq("email",user.getEmail())
.eq("validate_code",registerCode);
if(emailValidateService.selectCount(entityWrapper)<=0){
return ServerResponse.createByErrorMessage("注册码错误");
}
//保存
user.setCreateTime(new Date());
user.setRole(10);
if (user.insert()){
return ServerResponse.createBySuccessMessage("注册成功");
}else{
return ServerResponse.createByError();
}
}
/**
* 用户登录
* @param username
* @param password
* @param session
* @return
*/
@RequestMapping("/login")
@ResponseBody