【计算机毕业设计】网上书城源码( 二 )


validationQuery=SELECT 1jdbc_url=jdbc:mysql://127.0.0.1:3306/jspm44xq2?useUnicode=true&characterEncoding=UTF-8&tinyInt1isBit=falsejdbc_username=rootjdbc_password=root#jdbc_url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jspm44xq2#jdbc_username=sa#jdbc_password=123456
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)验证*/@Componentpublic class AuthorizationInterceptor implements HandlerInterceptor {public static final String LOGIN_TOKEN_KEY = "Token";@Autowiredprivate TokenService tokenService;@Overridepublic 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中获取tokenString 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;}}
package com.model.enums;import java.io.Serializable;import com.baomidou.mybatisplus.enums.IEnum;/*** 必须现在 IEnum 配置 该包扫描自动注入,查看文件 spring-mybatis.xml 参数 typeEnumsPackage*/public enum TypeEnum implements IEnum {DISABLED(0, "禁用"),NORMAL(1, "正常");private final int value;private final String desc;TypeEnum(final int value, final String desc) {this.value = http://www.kingceram.com/post/value;this.desc = desc;}@Overridepublic Serializable getValue() {return this.value;}// Jackson 注解为 JsonValue 返回中文 json 描述public String getDesc() {return this.desc;}}
package com.service;import com.baomidou.mybatisplus.mapper.Wrapper;import com.baomidou.mybatisplus.service.IService;import com.utils.PageUtils;import com.entity.AddressEntity;import java.util.List;import java.util.Map;import com.entity.vo.AddressVO;import org.apache.ibatis.annotations.Param;import com.entity.view.AddressView;/*** 地址** @author * @email * @date 2022-03-16 22:33:30*/public interface AddressService extends IService