提交 0ab00ba8 编写于 作者: N Nicky

Merge remote-tracking branch 'origin/dev'

......@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@EnableTransactionManagement//开启对事务管理配置的支持
@EnableCaching
@EnableAsync//开启对异步方法的支持
@EnableAutoConfiguration //TODO 修改该注解可以实现自动部署
@EnableAutoConfiguration
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,
MybatisAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class})
......
......@@ -37,14 +37,14 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/upload/**", "anon");
filterChainDefinitionMap.put("/plugins/**", "anon");
filterChainDefinitionMap.put("/templates/**", "anon");
filterChainDefinitionMap.put("/admin/code/generate", "anon");
filterChainDefinitionMap.put("/admin/toLogin", "anon");
filterChainDefinitionMap.put("/admin/loginCheck", "anon");
filterChainDefinitionMap.put("/admin/code/api/generate", "anon");
filterChainDefinitionMap.put("/admin/login/api/toLogin", "anon");
filterChainDefinitionMap.put("/admin/login/api/loginCheck", "anon");
filterChainDefinitionMap.put("/**", "authc");
shiroFilterFactoryBean.setLoginUrl("/admin/toLogin");
shiroFilterFactoryBean.setSuccessUrl("/admin/toIndex");
shiroFilterFactoryBean.setUnauthorizedUrl("/admin/toIndex");
shiroFilterFactoryBean.setLoginUrl("/admin/login/api/toLogin");
shiroFilterFactoryBean.setSuccessUrl("/admin/login/api/toIndex");
shiroFilterFactoryBean.setUnauthorizedUrl("/admin/login/api/toIndex");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
......@@ -80,7 +80,7 @@ public class ShiroConfig {
//同一个用户最大的会话数,默认1;比如2的意思是同一个用户允许最多同时两个人登录;
filter.setMaxSession(1);
//被踢出后重定向到的地址;
filter.setUrl("/login");
filter.setUrl("/admin/login/api/toLogin");
return filter;
}
......
......@@ -20,7 +20,7 @@ import java.util.Random;
@Controller
@RequestMapping("/code")
@RequestMapping("/admin/code/api")
public class CodeController {
@RequestMapping("/generate")
......
......@@ -51,7 +51,7 @@ import java.util.List;
* </pre>
*/
@Controller
@RequestMapping("/admin")
@RequestMapping("/admin/login/api")
public class LoginController extends BaseController {
@Autowired
......@@ -176,86 +176,6 @@ public class LoginController extends BaseController {
}
@RequestMapping("/code/generate")
public void generate(HttpServletResponse response){
ByteArrayOutputStream output = new ByteArrayOutputStream();
String code = drawImg(output);
Subject currentUser = SecurityUtils.getSubject();
Session session = currentUser.getSession();
session.setAttribute(Constants.SESSION_SECURITY_CODE, code);
try {
ServletOutputStream out = response.getOutputStream();
output.writeTo(out);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 绘画验证码
* @param output
* @return
*/
private String drawImg(ByteArrayOutputStream output){
String code = "";
//随机产生4个字符
for(int i=0; i<4; i++){
code += randomChar();
}
int width = 70;
int height = 25;
BufferedImage bi = new BufferedImage(width,height,BufferedImage.TYPE_3BYTE_BGR);
Font font = new Font("Times New Roman",Font.PLAIN,20);
//调用Graphics2D绘画验证码
Graphics2D g = bi.createGraphics();
g.setFont(font);
Color color = new Color(66,2,82);
g.setColor(color);
g.setBackground(new Color(226,226,240));
g.clearRect(0, 0, width, height);
FontRenderContext context = g.getFontRenderContext();
Rectangle2D bounds = font.getStringBounds(code, context);
double x = (width - bounds.getWidth()) / 2;
double y = (height - bounds.getHeight()) / 2;
double ascent = bounds.getY();
double baseY = y - ascent;
g.drawString(code, (int)x, (int)baseY);
g.dispose();
try {
ImageIO.write(bi, "jpg", output);
} catch (IOException e) {
e.printStackTrace();
}
return code;
}
/**
* 随机参数一个字符
* @return
*/
private char randomChar(){
Random r = new Random();
String s = "ABCDEFGHJKLMNPRSTUVWXYZ0123456789";
return s.charAt(r.nextInt(s.length()));
}
/**
* 获取随机颜色值
* @param fc
* @param bc
* @return
*/
Color getRandColor(int fc,int bc){
Random random=new Random();
if(fc>255) fc=255;
if(bc>255) bc=255;
int r=fc+random.nextInt(bc-fc);
int g=fc+random.nextInt(bc-fc);
int b=fc+random.nextInt(bc-fc);
return new Color(r,g,b);
}
}
......@@ -4,12 +4,12 @@
<head th:fragment="header">
<meta charset="utf-8" />
<title>电商运营平台</title>
<link th:href="@{../static/css/style.css}" rel="stylesheet" />
<link th:href="@{../static/css/backend.css}" rel="stylesheet" />
<link th:href="@{../static/css/page/backend/account_center.css}" rel="stylesheet" />
<link th:href="@{../plugins/datepicker/css/bootstrap.css}" rel="stylesheet" />
<link th:href="@{../plugins/select2/css/select2.min.css}" rel="stylesheet" />
<script type="text/javascript" th:src="@{../static/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{../static/js/common.js}"></script>
<link th:href="@{/static/css/style.css}" rel="stylesheet" />
<link th:href="@{/static/css/backend.css}" rel="stylesheet" />
<link th:href="@{/static/css/page/backend/account_center.css}" rel="stylesheet" />
<link th:href="@{/plugins/datepicker/css/bootstrap.css}" rel="stylesheet" />
<link th:href="@{/plugins/select2/css/select2.min.css}" rel="stylesheet" />
<script type="text/javascript" th:src="@{/static/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/static/js/common.js}"></script>
</head>
</html>
\ No newline at end of file
......@@ -4,7 +4,7 @@
<div class="navigation-inner">
<div class="logo">
<h1>
<a th:href="@{/admin/toIndex}" class="logo-img">电商运营平台</a>
<a th:href="@{/admin/login/api/toIndex}" class="logo-img">电商运营平台</a>
</h1>
</div>
<div class="header-categories" id="nav-con">
......@@ -37,7 +37,7 @@
</a>
</li>
<li>
<a href="order.html">
<a th:href="@{/admin/order/api/toOrder}">
<i class="iconfont">&#xe60c;</i>
<span class="pf-opt-name">订单信息</span>
</a>
......@@ -55,7 +55,7 @@
</a>
</li>
<li class="div-line">
<a href="login.html">
<a th:href="@{/admin/login/api/toLogout}">
<i class="iconfont">&#xe60b;</i>
<span class="pf-opt-name">退出</span>
</a>
......
......@@ -3,18 +3,18 @@
xmlns:th="http://www.thymeleaf.org">
<!-- 引入公共页面的一些样式和脚本-->
<head >
<link th:href="@{../static/css/style.css}" rel="stylesheet" />
<link th:href="@{../static/css/backend.css}" rel="stylesheet" />
<link th:href="@{../static/css/page/backend/order_manage.css}" rel="stylesheet" />
<link th:href="@{../plugins/datepicker/css/bootstrap.css}" rel="stylesheet" />
<link th:href="@{../plugins/datepicker/css/bootstrap-datepicker.css}" rel="stylesheet" />
<link th:href="@{../plugins/select2/css/select2.min.css}" rel="stylesheet" />
<script type="text/javascript" th:src="@{../static/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{../static/js/common.js}"></script>
<script type="text/javascript" th:src="@{../plugins/datepicker/js/bootstrap-datepicker.js}"></script>
<script type="text/javascript" th:src="@{../plugins/datepicker/locales/bootstrap-datepicker.zh-CN.min.js}"></script>
<script type="text/javascript" th:src="@{../static/js/jquery.pagination.js}"></script>
<script type="text/javascript" th:src="@{../plugins/select2/js/select2.min.js}"></script>
<link th:href="@{/static/css/style.css}" rel="stylesheet" />
<link th:href="@{/static/css/backend.css}" rel="stylesheet" />
<link th:href="@{/static/css/page/backend/order_manage.css}" rel="stylesheet" />
<link th:href="@{/plugins/datepicker/css/bootstrap.css}" rel="stylesheet" />
<link th:href="@{/plugins/datepicker/css/bootstrap-datepicker.css}" rel="stylesheet" />
<link th:href="@{/plugins/select2/css/select2.min.css}" rel="stylesheet" />
<script type="text/javascript" th:src="@{/static/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/static/js/common.js}"></script>
<script type="text/javascript" th:src="@{/plugins/datepicker/js/bootstrap-datepicker.js}"></script>
<script type="text/javascript" th:src="@{/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/jquery.pagination.js}"></script>
<script type="text/javascript" th:src="@{/plugins/select2/js/select2.min.js}"></script>
</head>
<body>
......
......@@ -3,13 +3,13 @@
xmlns:th="http://www.thymeleaf.org">
<!-- 引入公共页面的一些样式和脚本-->
<head>
<link th:href="@{../static/css/page/backend/account_center.css}" rel="stylesheet" />
<link th:href="@{../static/css/style.css}" rel="stylesheet" />
<link th:href="@{../static/css/backend.css}" rel="stylesheet" />
<link th:href="@{../plugins/datepicker/css/bootstrap.css}" rel="stylesheet" />
<link th:href="@{../plugins/select2/css/select2.min.css}" rel="stylesheet" />
<script type="text/javascript" th:src="@{../static/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{../static/js/common.js}"></script>
<link th:href="@{/static/css/page/backend/account_center.css}" rel="stylesheet" />
<link th:href="@{/static/css/style.css}" rel="stylesheet" />
<link th:href="@{/static/css/backend.css}" rel="stylesheet" />
<link th:href="@{/plugins/datepicker/css/bootstrap.css}" rel="stylesheet" />
<link th:href="@{/plugins/select2/css/select2.min.css}" rel="stylesheet" />
<script type="text/javascript" th:src="@{/static/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/static/js/common.js}"></script>
</head>
<body>
<!-- 顶部导航栏 -->
......
......@@ -90,7 +90,7 @@
}
/**刷新验证码的脚本处理**/
function changeCode() {
$("#codeImg").attr("src", "code/generate?t=" + genTimestamp());
$("#codeImg").attr("src", "/admin/code/api/generate?t=" + genTimestamp());
}
/**客户端校验**/
function checkValidity() {
......
......@@ -13,5 +13,13 @@ package com.muses.taoshop.base;
* </pre>
*/
public class SessionConsts {
/**
* 用户信息会话
*/
public static final String PORTAL_SESSION_USER = "potalSessionUser";
/**
* 验证码信息会话
*/
public static final String SESSION_SECURITY_CODE = "sessionSecurityCode";
}
package com.muses.taoshop.web.controller;
import com.muses.taoshop.common.core.base.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,6 +17,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random;
import static com.muses.taoshop.base.SessionConsts.SESSION_SECURITY_CODE;
@Controller
@RequestMapping("/code")
......@@ -31,7 +32,7 @@ public class CodeController {
// Subject currentUser = SecurityUtils.getSubject();
// Session session = currentUser.getSession();
HttpSession session = request.getSession();
session.setAttribute(Constants.SESSION_SECURITY_CODE, code);
session.setAttribute(SESSION_SECURITY_CODE, code);
try {
ServletOutputStream out = response.getOutputStream();
......
package com.muses.taoshop.web.controller;
import com.muses.taoshop.base.SessionConsts;
import com.muses.taoshop.user.entity.User;
import com.muses.taoshop.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,6 +12,9 @@ import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
import static com.muses.taoshop.base.SessionConsts.PORTAL_SESSION_USER;
import static com.muses.taoshop.base.SessionConsts.SESSION_SECURITY_CODE;
/**
* <pre>
* 登录控制类
......@@ -55,7 +57,7 @@ public class LoginController extends BaseController{
String logindata[] = request.getParameter("LOGINDATA").split(",");
HttpSession session = request.getSession();
if(logindata != null && logindata.length == 3) {
String codeSession = (String)session.getAttribute(SessionConsts.PORTAL_SESSION_USER);
String codeSession = (String)session.getAttribute(SESSION_SECURITY_CODE);
String username = logindata[0];
String password = logindata[1];
String code = logindata[2];
......@@ -65,7 +67,7 @@ public class LoginController extends BaseController{
//}else{ //账号密码校验
User user = userService.loginCheck(username, password);
if(user != null){//校验成功
session.setAttribute(SessionConsts.PORTAL_SESSION_USER,username);
session.setAttribute(PORTAL_SESSION_USER,username);
flag = "success";
}else{//账号或者密码错误
flag = "faild";
......
......@@ -29,10 +29,10 @@
<dt> <span class="shop-amount">0</span> <em class="icon-cart"></em> <a href="#">去购物车结算</a> <span class="angle"></span> </dt>
<dd style="display:none;">
<!--购物车为空-->
<div class="nogoods" style="display:none;"> 购物车中还没有商品,赶紧选购吧! </div>
<div class="nogoods" th:if="${session.potalSessionUser == null}" style="display:none;"> 购物车中还没有商品,赶紧选购吧! </div>
<!--//购物车为空-->
<!--有商品-->
<div class="cart-table">
<div class="cart-table" th:if="${session.potalSessionUser != null}">
<div class="cart-table-body">
<ul class="cart-item clearfix">
<li class="item-img"><a href="#"><img th:src="@{/static/picture/img_small_350x350.jpg}" /></a></li>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册