完善用户接口
This commit is contained in:
parent
0abe977f45
commit
80200e60fa
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>单元测试网页</title>
|
||||
<title>接口文档</title>
|
||||
<!-- 新 Bootstrap 核心 CSS 文件 -->
|
||||
<link href="../css/bootstrap.css" rel="stylesheet">
|
||||
<link href="../css/bootstrap-theme.css" rel="stylesheet">
|
||||
|
@ -12,16 +12,25 @@
|
|||
<link href="../Content/css/IE8.css" rel="stylesheet" />
|
||||
<![endif]-->
|
||||
<style type="text/css">
|
||||
.btn {
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
button {
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
section {
|
||||
padding: 0 15px;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
section > div > div {
|
||||
display: inline-block;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.control-label {
|
||||
|
@ -41,6 +50,16 @@
|
|||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
|
||||
</div>
|
||||
<![endif]-->
|
||||
<section>
|
||||
<div><h3>接口返回值定义</h3></div>
|
||||
<div><label class="control-label">布尔值:</label><div>成功返回True,失败返回False</div></div>
|
||||
<div><label class="control-label">对象:</label><div>Json字符串</div></div>
|
||||
</section>
|
||||
<section>
|
||||
<div><h3>接口请求定义</h3></div>
|
||||
<div><label class="control-label">内容类型</label><div>Content-Type:application/json; charset=utf-8</div></div>
|
||||
<div><label class="control-label">授权Token</label><div>Token:362a4733-341a-464d-ab12-e01554338839</div></div>
|
||||
</section>
|
||||
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
|
||||
<script src="../js/jquery-1.10.2.js"></script>
|
||||
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
$section.append($.format('<div><label class="control-label">传递参数</label><div>{0}</div></div>', JSON.stringify(options.data)));
|
||||
$section.append($.format('<div><label class="control-label">返回值</label><div>{0}</div></div>', JSON.stringify(result)));
|
||||
$section.append('<div><label class="control-label">试一试</label></div>');
|
||||
$section.append($.format('<div class="input-group"><input type="text" class="form-control" value=\'{1}\' data-val=\'{0}\' /><span class="input-group-btn"><button class="btn btn-default" type="button">试一试</button></span></div>', JSON.stringify(options), JSON.stringify(options.data)));
|
||||
$section.append($.format('<div class="input-group"><input type="text" class="form-control" value=\'{1}\' data-val=\'{0}\' /><span class="input-group-btn"><button class="btn btn-default btn-success" type="button">试一试</button></span></div>', JSON.stringify(options), JSON.stringify(options.data)));
|
||||
$section.append('<div class="test"></div>')
|
||||
options.success(result);
|
||||
}
|
||||
|
@ -82,11 +82,44 @@
|
|||
ajax(options);
|
||||
});
|
||||
|
||||
// 接口调用
|
||||
ajax({
|
||||
title: '用户登陆调用接口',
|
||||
anonymous: true,
|
||||
url: 'api/login', method: 'POST', data: { userName: 'Test', password: '1' }, success: function (result) {
|
||||
ajax({ title: '用户登陆信息接口', url: 'api/login', method: 'GET', headers: { Token: result.Token } });
|
||||
var token = result.Token;
|
||||
ajax({
|
||||
title: '用户登陆信息接口', url: 'api/login', headers: { Token: token },
|
||||
method: 'GET'
|
||||
});
|
||||
ajax({
|
||||
title: '指定用户信息接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'GET', data: { userName: "Test" }
|
||||
});
|
||||
ajax({
|
||||
title: '检查当前用户名是否可用接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'PUT', data: { UserName: "101", UserStatus: 9 }
|
||||
});
|
||||
ajax({
|
||||
title: '更改用户显示名称接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'PUT', data: { UserName: "101", UserStatus: 1, DisplayName: "1010" }
|
||||
});
|
||||
ajax({
|
||||
title: '更改用户密码接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'PUT', data: { UserName: "101", UserStatus: 2, Password: "1", NewPassword: "2" }
|
||||
});
|
||||
ajax({
|
||||
title: '新建用户接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'POST', data: { ID: 0, UserName: "102", Password: "1", DisplayName: "102" }
|
||||
});
|
||||
ajax({
|
||||
title: '更新用户接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'POST', data: { ID: 21, UserName: "102", Password: "1", DisplayName: "102" }
|
||||
});
|
||||
ajax({
|
||||
title: '删除用户接口', url: 'api/Users', headers: { Token: token },
|
||||
method: 'DELETE', data: { "": "50,51" }
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue