<!DOCTYPE html>
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
<head>
|
<title>API接口</title>
|
<meta http-equiv="Expires" content="0" />
|
<meta http-equiv="Cache" content="no-cache" />
|
<meta http-equiv="Pragma" content="no-cache" />
|
<meta http-equiv="Cache-control" content="no-cache" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<script src="js/jquery.1.12.4.js"></script>
|
<script src="js/rsa.min.js"></script>
|
<script src="js/rollups.js"></script>
|
<script>
|
var app = {};
|
var path = "20221128010101";
|
var url = "http://127.0.0.1:12316/server/";
|
var token = "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567";
|
|
$(function () {
|
$("#pathSpan").html(path);
|
$("#tokenSpan").html(token);
|
getPublicKey();
|
});
|
|
// Ajax
|
function ajax(url, type, data, dataType, contentType, fn) {
|
$.ajax({
|
url: url,
|
type: type,
|
data: data,
|
dataType: dataType || "json",
|
contentType: contentType || "application/json",
|
success: function (data) {
|
fn(data);
|
},
|
error: function (e) {
|
console.error(e);
|
fn();
|
}
|
});
|
}
|
|
// 获取URL
|
function getUrl(method) {
|
return url + method + "?token=" + token;
|
}
|
</script>
|
<script>
|
// 获取公钥
|
function getPublicKey() {
|
$.get("http://127.0.0.1:12316/server/sign/getPublicKey", function (rs) {
|
if (rs && rs.code == 200) {
|
window.encrypt = new JSEncrypt();
|
encrypt.setPublicKey(rs.result);
|
}
|
});
|
}
|
|
// 登录
|
function login() {
|
var data = {
|
"uid": encrypt.encrypt("admin"), // 用户名,RSA加密
|
"pwd": encrypt.encrypt("Admin@1234_lf") // 密码,RSA加密
|
};
|
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/sign/login",
|
type: "POST",
|
data: JSON.stringify(data),
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
if (!rs || rs.code != 200) {
|
$("登录失败!\n" + rs.msg);
|
return;
|
}
|
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 登出1,令牌放header中
|
function logout1() {
|
$.ajax({
|
headers: {
|
token: "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567"
|
},
|
url: "http://127.0.0.1:12316/server/sign/logout",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 登出1,令牌放url中
|
function logout2() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/sign/logout?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 检查是/否登录
|
function check() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/sign/check?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 是/否为管理员
|
function isAdmin() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectForIsAdmin?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 根据数据库ID获取用户
|
function getUserById() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectUser?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&id=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 根据登录ID获取用户
|
function getUserByUid() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectByUid?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&uid=admin",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 获取用户列表
|
function selectUsers() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectByPageAndCount?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&uname=&pageSize=10&pageIndex=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 是/否为管理员
|
function isAdmin2() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectIsAdmin?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&id=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 获取管理员用户
|
function selectAdminUsers() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectAdminUsers?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&type=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 获取用户的角色信息
|
function selectRoleByUserId() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectRoleByUserId?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&id=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 获取单个角色信息
|
function selectRoleById() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/role/selectRole?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&id=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 获取角色列表
|
function selectRoles() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/role/selectByPageAndCount?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&name=&depid=&pageSize=10&pageIndex=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
|
// 获取角色下的用户信息
|
function selectUserByRoleId() {
|
$.ajax({
|
url: "http://127.0.0.1:12316/server/user/selectUserByRoleId?token=" + "b6d650b7-8eff-41f6-9fc7-8ec1c73cd567" + "&id=1",
|
type: "GET",
|
data: null,
|
dataType: "json",
|
contentType: "application/json",
|
success: function (rs) {
|
console.log(rs);
|
},
|
error: function (e) {
|
console.error(e);
|
}
|
});
|
}
|
</script>
|
</head>
|
<body>
|
上传路径:<span id="pathSpan"></span>,当前令牌:<span id="tokenSpan"></span>
|
</body>
|
</html>
|