程序优化

main
tamguo 7 years ago
parent 3a0f46a143
commit 6cfc5bfab7

@ -80,10 +80,14 @@ public class ShiroConfiguration {
filterChainDefinitionMap.put("/my97/**", "anon");
filterChainDefinitionMap.put("/select2/**", "anon");
filterChainDefinitionMap.put("/sysLogin/**", "anon");
filterChainDefinitionMap.put("/images/**", "anon");
filterChainDefinitionMap.put("/validCode", "anon");
filterChainDefinitionMap.put("/checkCode", "anon");
filterChainDefinitionMap.put("/wdScrollTab/**", "anon");
filterChainDefinitionMap.put("/jquery-timeago/**", "anon");
filterChainDefinitionMap.put("/favicon.ico", "anon");
filterChainDefinitionMap.put("/global.min.js", "anon");
filterChainDefinitionMap.put("/**", "authc");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);

@ -42,7 +42,7 @@ public class ShiroUtils {
public static String getKaptcha(String key) {
String kaptcha = getSessionAttribute(key).toString();
getSession().removeAttribute(key);
// getSession().removeAttribute(key);
return kaptcha;
}

@ -9,7 +9,7 @@ public class IndexController {
@RequestMapping(path="sysIndex")
public String sysLogin(ModelAndView model) {
return "sysIndex.html";
return "sysIndex";
}
}

@ -26,19 +26,21 @@ public class LoginController {
@RequestMapping(path="sysLogin")
public String sysLogin(ModelAndView model) {
return "sysLogin.html";
if(ShiroUtils.isLogin()) {
return "sysIndex";
}
return "sysLogin";
}
@ResponseBody
@RequestMapping(value = "sysLogin", method = RequestMethod.POST)
public Result toLogin(HttpServletRequest request, String username, String password, String captcha)
public Result toLogin(HttpServletRequest request, String username, String password, String validCode)
throws IOException {
try {
String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
if (!captcha.equalsIgnoreCase(kaptcha)) {
if (!validCode.equalsIgnoreCase(kaptcha)) {
return Result.failResult("验证码错误");
}
Subject subject = ShiroUtils.getSubject();
// sha256加密
password = new Sha256Hash(password).toHex();

@ -43,7 +43,7 @@ public class ValidCodeController {
public Boolean checkCode(String validCode) throws ServletException, IOException {
try {
String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
if (!validCode.equalsIgnoreCase(kaptcha)) {
if (validCode.equalsIgnoreCase(kaptcha)) {
return true;
}
} catch (Exception e) {

@ -0,0 +1,37 @@
<?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.tamguo.modules.sys.dao.SysMenuMapper">
<resultMap id="BaseResultMap" type="com.tamguo.modules.sys.model.SysMenuEntity" >
<id column="uid" property="uid" jdbcType="VARCHAR" />
<result column="parent_id" property="parentId" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="url" property="url" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="perms" property="perms" jdbcType="INTEGER" />
<result column="order_num" property="orderNum" jdbcType="INTEGER" />
<result column="parentName" property="parentName" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
uid, parent_id, name, url, type, perms , order_num
</sql>
<select id="queryList" resultMap="BaseResultMap">
select m.*,(select p.name from sys_menu p where p.uid = m.parent_id) as parentName
from sys_menu m order by m.order_num asc
</select>
<select id="queryNotButtonList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from sys_menu where type != 2 order by order_num asc
</select>
<select id="queryByUid" resultMap="BaseResultMap">
select m.*,(select p.name from sys_menu p where p.uid = m.parent_id) as parentName
from sys_menu m where m.uid = #{uid}
</select>
</mapper>

@ -0,0 +1,17 @@
<?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.tamguo.modules.sys.dao.SysRoleMapper">
<select id="selectPageByName" resultType="SysRoleEntity">
SELECT
r.uid , r.name , r.perms
FROM
sys_role r
<where>
<if test="name!=null and name !=''">
t.name like #{name}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,44 @@
<?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.tamguo.modules.sys.dao.SysUserMapper">
<select id="queryByUserName" resultType="SysUserEntity">
SELECT
u.uid,
u.user_name,
u.role_ids,
u.password,
u.status,
u.nick_name,
u.mobile,
u.email,
u.course_id
FROM
sys_user u
WHERE
u.user_name = #{username}
</select>
<select id="queryPage" resultType="SysUserEntity">
SELECT
u.uid,
u.user_name,
u.role_ids,
r.name as role_name,
u.password,
u.status,
u.nick_name,
u.mobile,
u.email,
u.course_id
FROM
sys_user u
LEFT JOIN sys_role r ON r.uid = u.role_ids
<where>
<if test="userName != null and userName != ''">
u.user_name like #{userName}
</if>
</where>
</select>
</mapper>

@ -1 +1 @@
lang='zh_CN',ctx='/js',ctxPath='/js',ctxAdmin='/js/a',ctxFront='/js/f',ctxStatic='/js/static',Global={SHOW:'1',HIDE:'0',OP_AUTH:'auth',OP_ADD:'add',FALSE:'false',USERFILES_BASE_URL:'/userfiles/',YES:'1',TRUE:'true',NO:'0',OP_EDIT:'edit',STATUS_DELETE:'1',STATUS_NORMAL:'0',STATUS_DRAFT:'9',STATUS_AUDIT_BACK:'5',STATUS_DISABLE:'2',STATUS_FREEZE:'3',STATUS_AUDIT:'4'}
lang='zh_CN',ctx='http://localhost/',ctxPath='/',ctxAdmin='/',ctxFront='/f',ctxStatic='static',Global={SHOW:'1',HIDE:'0',OP_AUTH:'auth',OP_ADD:'add',FALSE:'false',USERFILES_BASE_URL:'/userfiles/',YES:'1',TRUE:'true',NO:'0',OP_EDIT:'edit',STATUS_DELETE:'1',STATUS_NORMAL:'0',STATUS_DRAFT:'9',STATUS_AUDIT_BACK:'5',STATUS_DISABLE:'2',STATUS_FREEZE:'3',STATUS_AUDIT:'4'}

@ -13,11 +13,11 @@ $("#loginForm").validate({
, a = $("#password").val()
, b = $("#validCode").val();
js.ajaxSubmitForm($(c), function(f, e, g) {
if (f.result != 0) {
js.showMessage(f.message)
} else {
if (f.result.code != 0) {
js.loading($("#btnSubmit").data("loading"));
location = ctx + "/index"
location = ctx + "sysIndex"
} else {
js.showMessage(f.message)
}
}, "json", true, $("#btnSubmit").data("loginValid"));
$("#username").val(d);

@ -11,6 +11,7 @@
<meta http-equiv="Expires" content="0" />
<meta content="width=device-width, initial-scale=1, user-scalable=1" name="viewport" />
<title>登录 - Tamguo OMS</title>
<script src="global.min.js?ctx=/js/a"></script>
<script th:src="${setting.staticDomain + 'jquery/jquery-1.12.4.min.js'}"></script>
<script th:src="${setting.staticDomain + 'jquery/jquery-migrate-1.4.1.min.js'}"></script>
<!--[if lt IE 9]><script src="common/h5fix.min.js"></script><![endif]-->
@ -48,7 +49,7 @@
class="form-control required" data-msg-required="请填写登录密码."
placeholder="登录密码" autocomplete="off" />
</div>
<!-- <div class="form-group has-feedback" id="isValidCodeLogin">
<div class="form-group has-feedback" id="isValidCodeLogin">
<div class="input-group">
<span class="input-group-addon">验证码:</span> <input type="text"
id="validCode" name="validCode" class="form-control"
@ -79,7 +80,7 @@
validCodeImgRefresh();
}, 1000);
</script>
</div> -->
</div>
<div class="form-group">
<div class="mt5 icheck">
<label title="公共场所慎用,下次不需要再填写帐号"><input type="checkbox"

Loading…
Cancel
Save