parent
0cdb9f9c65
commit
85e98f1e14
@ -0,0 +1,120 @@ |
||||
<!doctype html> |
||||
<html class="x-admin-sm"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>SOP Admin</title> |
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand"> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
<meta name="viewport" |
||||
content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/> |
||||
<meta http-equiv="Cache-Control" content="no-siteapp"/> |
||||
<link rel="stylesheet" href="../../assets/css/font.css"> |
||||
<link rel="stylesheet" href="../../assets/css/xadmin.css"> |
||||
<script> |
||||
// 是否开启刷新记忆tab功能 |
||||
// var is_remember = false; |
||||
</script> |
||||
<style> |
||||
.sub-menu cite { |
||||
margin-left: 0px; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<!-- 顶部开始 --> |
||||
<div class="container"> |
||||
<div class="logo"><a>SOP Admin</a></div> |
||||
<div class="left_open"> |
||||
<i title="展开左侧栏" class="iconfont"></i> |
||||
</div> |
||||
<ul class="layui-nav right" lay-filter=""> |
||||
<li class="layui-nav-item"> |
||||
<a id="username" href="javascript:;"></a> |
||||
<dl class="layui-nav-child"> <!-- 二级菜单 --> |
||||
<dd><a href="#" onclick="ApiUtil.logout(); return false;">退出</a></dd> |
||||
</dl> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- 顶部结束 --> |
||||
<!-- 中部开始 --> |
||||
<!-- 左侧菜单开始 --> |
||||
<div class="left-nav"> |
||||
<div id="side-nav"> |
||||
<ul id="nav"> |
||||
<li date-refresh="1"> |
||||
<a href="welcome.html"> |
||||
<i class="layui-icon layui-icon-home"></i> |
||||
<cite>首页</cite> |
||||
</a> |
||||
</li> |
||||
<li class="open"> |
||||
<a> |
||||
<i class="layui-icon layui-icon-template-1"></i> |
||||
<cite>配置管理</cite> |
||||
</a> |
||||
<ul class="sub-menu"> |
||||
<li date-refresh="1"> |
||||
<a href="todo.html"> |
||||
<i class="layui-icon layui-icon-table"></i> |
||||
<cite>配置列表</cite> |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
</li> |
||||
<li class="open"> |
||||
<a> |
||||
<i class="layui-icon layui-icon-app"></i> |
||||
<cite>服务管理</cite> |
||||
</a> |
||||
<ul class="sub-menu"> |
||||
<li date-refresh="1"> |
||||
<a href="../service/serviceList.html"> |
||||
<i class="layui-icon layui-icon-table"></i> |
||||
<cite>服务列表</cite> |
||||
</a> |
||||
</li> |
||||
<li date-refresh="1"> |
||||
<a href="../service/routeManager.html"> |
||||
<i class="layui-icon layui-icon-component"></i> |
||||
<cite>路由管理</cite> |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
</li> |
||||
<li class="open"> |
||||
<a> |
||||
<i class="layui-icon layui-icon-layer"></i> |
||||
<cite>ISV管理</cite> |
||||
</a> |
||||
<ul class="sub-menu"> |
||||
<li date-refresh="1"> |
||||
<a href="../isv/isvList.html"> |
||||
<i class="layui-icon layui-icon-table"></i> |
||||
<cite>ISV列表</cite> |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<!-- <div class="x-slide_left"></div> --> |
||||
<!-- 左侧菜单结束 --> |
||||
<!-- 右侧主体开始 --> |
||||
<div class="page-content"> |
||||
<iframe id="pageFrame" src='welcome.html' frameborder="0" scrolling="yes" class="x-iframe" width="100%" height="100%"></iframe> |
||||
</div> |
||||
<div class="page-content-bg"></div> |
||||
<!-- 右侧主体结束 --> |
||||
<!-- 中部结束 --> |
||||
<!-- 底部开始 --> |
||||
<div class="footer"> |
||||
<div class="copyright">Copyright ©2019 SOP All Rights Reserved</div> |
||||
</div> |
||||
<!-- 底部结束 --> |
||||
<script type="text/javascript" src="../../assets/js/lib.js"></script> |
||||
<script type="text/javascript" src="dashboard.js"></script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,38 @@ |
||||
lib.use('element', function () { |
||||
var $ = layui.jquery; |
||||
var $pageFrame = $('#pageFrame'); |
||||
var $selectLi = null; |
||||
$('.left-nav').on('click', 'li', function (event) { |
||||
var $tagLi = $(this); |
||||
var $tagA = $tagLi.find('a').eq(0); |
||||
var href = $tagA.prop('href'); |
||||
if (href) { |
||||
$pageFrame.prop('src', href + '?q=' + new Date().getTime()); |
||||
if ($selectLi) { |
||||
$selectLi.removeClass('active') |
||||
} |
||||
$selectLi = $tagLi.addClass('active'); |
||||
} |
||||
return false; |
||||
}); |
||||
|
||||
$('.container .left_open i').click(function(event) { |
||||
if($('.left-nav').css('left')=='0px'){ |
||||
$('.left-nav').animate({left: '-221px'}, 100); |
||||
$('.page-content').animate({left: '0px'}, 100); |
||||
$('.page-content-bg').hide(); |
||||
}else{ |
||||
$('.left-nav').animate({left: '0px'}, 100); |
||||
$('.page-content').animate({left: '221px'}, 100); |
||||
if($(window).width()<768){ |
||||
$('.page-content-bg').show(); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
ApiUtil.post('admin.userinfo.get', {}, function (resp) { |
||||
var userInfo = resp.data; |
||||
$('#username').text(userInfo.username); |
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,57 @@ |
||||
<!doctype html> |
||||
<html class="x-admin-sm"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>SOP-管理登录</title> |
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand"> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
<meta name="viewport" |
||||
content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
||||
<meta http-equiv="Cache-Control" content="no-siteapp"/> |
||||
<link rel="stylesheet" href="../../assets/css/font.css"> |
||||
<link rel="stylesheet" href="../../assets/css/xadmin.css"> |
||||
</head> |
||||
<body class="login-bg"> |
||||
|
||||
<div class="login layui-anim layui-anim-up"> |
||||
<div class="message">SOP Admin登录</div> |
||||
<div id="darkbannerwrap"></div> |
||||
|
||||
<form method="post" class="layui-form"> |
||||
<input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input"> |
||||
<hr class="hr15"> |
||||
<input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input"> |
||||
<hr class="hr15"> |
||||
<input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit"> |
||||
<hr class="hr20"> |
||||
</form> |
||||
</div> |
||||
<script type="text/javascript" src="../../assets/js/lib.js"></script> |
||||
<script> |
||||
lib.use('form', function () { |
||||
var form = layui.form; |
||||
//监听提交 |
||||
form.on('submit(login)', function (param) { |
||||
var data = param.field; |
||||
var pwd = data.password; |
||||
if(!pwd) { |
||||
alert('密码不能为空'); |
||||
return false; |
||||
} |
||||
pwd = hex_md5(pwd); |
||||
ApiUtil.post('nologin.admin.login',{ |
||||
username:data.username, |
||||
password:pwd |
||||
},function(resp){ |
||||
ApiUtil.setAccessToken(resp.data); |
||||
window.location = '../../index.html'; |
||||
}); |
||||
return false; |
||||
}); |
||||
}); |
||||
|
||||
|
||||
</script> |
||||
<!-- 底部结束 --> |
||||
</body> |
||||
</html> |
@ -0,0 +1,9 @@ |
||||
package com.gitee.sop.adminserver.api.system.param; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class LoginForm { |
||||
private String username; |
||||
private String password; |
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.gitee.sop.adminserver.api.system.result; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author tanghc |
||||
*/ |
||||
@Data |
||||
public class AdminUserInfoVO { |
||||
/** |
||||
* 数据库字段:id |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 用户名, 数据库字段:username |
||||
*/ |
||||
private String username; |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.gitee.sop.adminserver.common; |
||||
|
||||
import com.gitee.easyopen.message.ErrorMeta; |
||||
|
||||
/** |
||||
* 定义错误的地方 |
||||
* @author tanghc |
||||
*/ |
||||
public class AdminErrors { |
||||
private AdminErrors(){} |
||||
|
||||
static String isvModule = "isv.error_"; // error_zh_CN2.properties内容前缀
|
||||
|
||||
|
||||
public static final ErrorMeta NO_LOGIN = new ErrorMeta(isvModule, "-100", "用户未登录"); |
||||
|
||||
public static final ErrorMeta ERROR_USERNAME_PWD = new ErrorMeta(isvModule, "1", "用户名密码错误"); |
||||
public static final ErrorMeta DUPLICATE_USERNAME = new ErrorMeta(isvModule, "2", "该用户名已被注册"); |
||||
|
||||
public static final ErrorMeta NO_RECORD = new ErrorMeta(isvModule, "1000", "无操作记录"); |
||||
public static final ErrorMeta ERROR_VALIDATE = new ErrorMeta(isvModule, "1001", "验证失败"); |
||||
public static final ErrorMeta NULL_OBJECT = new ErrorMeta(isvModule, "1002", "null对象"); |
||||
public static final ErrorMeta ERROR_SERACH = new ErrorMeta(isvModule, "1004", "查询错误"); |
||||
public static final ErrorMeta ERROR_EXPORT = new ErrorMeta(isvModule, "1005", "导出错误"); |
||||
public static final ErrorMeta CLASS_NEW_ERROR = new ErrorMeta(isvModule, "1007", "系统错误"); |
||||
|
||||
public static final ErrorMeta ERROR_SAVE = new ErrorMeta(isvModule, "10010", "保存失败"); |
||||
public static final ErrorMeta ERROR_UPDATE = new ErrorMeta(isvModule, "10011", "修改失败"); |
||||
public static final ErrorMeta DELETE_UPDATE = new ErrorMeta(isvModule, "10012", "删除失败"); |
||||
public static final ErrorMeta RECORD_EXSIT = new ErrorMeta(isvModule, "10013", "记录已存在"); |
||||
public static final ErrorMeta ERROR_OPT = new ErrorMeta(isvModule, "10014", "非法操作"); |
||||
|
||||
public static final ErrorMeta NO_USER = new ErrorMeta(isvModule, "10015", "用户不存在"); |
||||
|
||||
} |
@ -0,0 +1,40 @@ |
||||
package com.gitee.sop.adminserver.common; |
||||
|
||||
import com.gitee.easyopen.ApiContext; |
||||
import com.gitee.sop.adminserver.entity.AdminUserInfo; |
||||
|
||||
import javax.servlet.http.HttpSession; |
||||
|
||||
public class WebContext { |
||||
private static WebContext INSTANCE = new WebContext(); |
||||
|
||||
private static final String S_USER = "s_user"; |
||||
|
||||
private WebContext() { |
||||
} |
||||
|
||||
public static WebContext getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前登录用户 |
||||
* |
||||
* @return |
||||
*/ |
||||
public AdminUserInfo getLoginUser() { |
||||
HttpSession session = ApiContext.getManagedSession(); |
||||
if (session == null) { |
||||
return null; |
||||
} |
||||
return (AdminUserInfo) session.getAttribute(S_USER); |
||||
} |
||||
|
||||
public void setLoginUser(HttpSession session, AdminUserInfo user) { |
||||
if (session != null) { |
||||
session.setAttribute(S_USER, user); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.gitee.sop.adminserver.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import javax.persistence.Column; |
||||
import javax.persistence.GeneratedValue; |
||||
import javax.persistence.GenerationType; |
||||
import javax.persistence.Id; |
||||
import javax.persistence.Table; |
||||
|
||||
|
||||
/** |
||||
* 表名:admin_user_info |
||||
* 备注:后台用户表 |
||||
* |
||||
* @author tanghc |
||||
*/ |
||||
@Table(name = "admin_user_info") |
||||
@Data |
||||
public class AdminUserInfo { |
||||
@Id |
||||
@Column(name = "id") |
||||
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
/** 数据库字段:id */ |
||||
private Long id; |
||||
|
||||
/** 用户名, 数据库字段:username */ |
||||
private String username; |
||||
|
||||
/** 密码, 数据库字段:password */ |
||||
private String password; |
||||
|
||||
/** 状态,1:启用,2:禁用, 数据库字段:status */ |
||||
private Byte status; |
||||
|
||||
/** 数据库字段:gmt_create */ |
||||
private Date gmtCreate; |
||||
|
||||
/** 数据库字段:gmt_modified */ |
||||
private Date gmtModified; |
||||
} |
@ -0,0 +1,47 @@ |
||||
package com.gitee.sop.adminserver.interceptor; |
||||
|
||||
import com.gitee.easyopen.ApiContext; |
||||
import com.gitee.easyopen.ApiMeta; |
||||
import com.gitee.easyopen.ParamNames; |
||||
import com.gitee.easyopen.interceptor.ApiInterceptorAdapter; |
||||
import com.gitee.sop.adminserver.common.AdminErrors; |
||||
import com.gitee.sop.adminserver.common.WebContext; |
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* 登录拦截器,验证用户是否登录 |
||||
* |
||||
* @author tanghc |
||||
*/ |
||||
public class LoginInterceptor extends ApiInterceptorAdapter { |
||||
|
||||
public static final String HEADER_TOKEN_NAME = ParamNames.ACCESS_TOKEN_NAME; |
||||
|
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object serviceObj, Object argu) |
||||
throws Exception { |
||||
String accessToken = request.getHeader(HEADER_TOKEN_NAME); |
||||
if (StringUtils.isNotBlank(accessToken)) { |
||||
ApiContext.getApiParam().put(ParamNames.ACCESS_TOKEN_NAME, accessToken); |
||||
} |
||||
if (WebContext.getInstance().getLoginUser() != null) { |
||||
return true; |
||||
} else { |
||||
throw AdminErrors.NO_LOGIN.getException(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean match(ApiMeta apiMeta) { |
||||
String name = apiMeta.getName(); |
||||
if (name.startsWith("nologin.")) { // 以‘nologin.’开头的接口不拦截
|
||||
return false; |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
package com.gitee.sop.adminserver.mapper; |
||||
|
||||
import com.gitee.fastmybatis.core.mapper.CrudMapper; |
||||
|
||||
import com.gitee.sop.adminserver.entity.AdminUserInfo; |
||||
|
||||
|
||||
/** |
||||
* @author tanghc |
||||
*/ |
||||
public interface AdminUserInfoMapper extends CrudMapper<AdminUserInfo, Long> { |
||||
} |
Loading…
Reference in new issue