SSM SpringBoot vue旅游攻略系统
  5JI5mkgBF7ox 2023年11月15日 35 0

SSM SpringBoot vue旅游攻略系统

SSM旅游攻略系统功能介绍

首页功能: 首页 餐厅信息 酒店信息 景点信息 自由行游记 登录注册 个人中心 我的收藏

后台管理功能: 登录注册 个人中心 酒店预定管理 用户信息管理 餐厅预定管理 景点预定管理 自由行游记管理 系统管理 餐厅信息管理 酒店信息管理 景点信息管理

使用技术

  • SSM(Spring + SpringMVC + Mybaits)或SpringBoot框架

  • Mysql数据库

  • html+layui首页

  • vue后台管理

功能展示

在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述

项目结构

在这里插入图片描述

权限验证

package com.interceptor;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import com.annotation.IgnoreAuth;
import com.entity.EIException;
import com.entity.TokenEntity;
import com.service.TokenService;
import com.utils.R;

/**
 * 权限(Token)验证
 */
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {

    public static final String LOGIN_TOKEN_KEY = "Token";

    @Autowired
    private TokenService tokenService;
    
	@Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        //支持跨域请求
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));

        IgnoreAuth annotation;
        if (handler instanceof HandlerMethod) {
            annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);
        } else {
            return true;
        }

        //从header中获取token
        String token = request.getHeader(LOGIN_TOKEN_KEY);
        
        /**
         * 不需要验证权限的方法直接放过
         */
        if(annotation!=null) {
        	return true;
        }
        
        TokenEntity tokenEntity = null;
        if(StringUtils.isNotBlank(token)) {
        	tokenEntity = tokenService.getTokenEntity(token);
        }
        
        if(tokenEntity != null) {
        	request.getSession().setAttribute("userId", tokenEntity.getUserid());
        	request.getSession().setAttribute("role", tokenEntity.getRole());
        	request.getSession().setAttribute("tableName", tokenEntity.getTablename());
        	request.getSession().setAttribute("username", tokenEntity.getUsername());
        	return true;
        }
        
		PrintWriter writer = null;
		response.setCharacterEncoding("UTF-8");
		response.setContentType("application/json; charset=utf-8");
		try {
		    writer = response.getWriter();
		    writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));
		} finally {
		    if(writer != null){
		        writer.close();
		    }
		}
//				throw new EIException("请先登录", 401);
		return false;
    }
}

mapper配置文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.dao.YonghuxinxiDao">

	<!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.entity.YonghuxinxiEntity" id="yonghuxinxiMap">
        <result property="yonghuming" column="yonghuming"/>
        <result property="mima" column="mima"/>
        <result property="xingming" column="xingming"/>
        <result property="xingbie" column="xingbie"/>
        <result property="nianling" column="nianling"/>
        <result property="shenfenzheng" column="shenfenzheng"/>
        <result property="dianhuahaoma" column="dianhuahaoma"/>
        <result property="youxiang" column="youxiang"/>
    </resultMap>

	<select id="selectListVO"
		resultType="com.entity.vo.YonghuxinxiVO" >
		SELECT * FROM yonghuxinxi  yonghuxinxi         
        <where> 1=1 ${ew.sqlSegment}</where>
	</select>
	
	<select id="selectVO"
		resultType="com.entity.vo.YonghuxinxiVO" >
		SELECT  yonghuxinxi.* FROM yonghuxinxi  yonghuxinxi
 		<where> 1=1 ${ew.sqlSegment}</where>
	</select>

    <select id="selectListView"
		resultType="com.entity.view.YonghuxinxiView" >

		SELECT  yonghuxinxi.* FROM yonghuxinxi  yonghuxinxi 	        
        <where> 1=1 ${ew.sqlSegment}</where>
	</select>
	
	<select id="selectView"
		resultType="com.entity.view.YonghuxinxiView" >
		SELECT * FROM yonghuxinxi  yonghuxinxi <where> 1=1 ${ew.sqlSegment}</where>
	</select>
</mapper>

运行

创建数据库, 然后修改数据库连接相关信息。

配置tomcat运行

前台访问地址: http://localhost:8080/ssmm/front/index.html

后台访问地址:http://localhost:8080/ssmm/admin/dist/index.html

管理员账号:liang 密码:liang

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月15日 0

暂无评论

推荐阅读
  2Vtxr3XfwhHq   2024年05月17日   55   0   0 Java
  Tnh5bgG19sRf   2024年05月20日   110   0   0 Java
  8s1LUHPryisj   2024年05月17日   46   0   0 Java
  aRSRdgycpgWt   2024年05月17日   47   0   0 Java
5JI5mkgBF7ox