增加Frombody
This commit is contained in:
parent
c0cb4b77fd
commit
a5505987fe
|
@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
[HttpPost]
|
||||
public bool Post(Group value)
|
||||
public bool Post([FromBody]Group value)
|
||||
{
|
||||
return GroupHelper.SaveGroup(value);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<Group> Post(int id, JObject value)
|
||||
public IEnumerable<Group> Post(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = new List<Group>();
|
||||
dynamic json = value;
|
||||
|
@ -83,7 +83,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, JObject value)
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public object Post(JObject value)
|
||||
public object Post([FromBody]JObject value)
|
||||
{
|
||||
dynamic user = value;
|
||||
string userName = user.userName;
|
||||
|
|
|
@ -34,11 +34,10 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool Post(Log value)
|
||||
public bool Post([FromBody]Log value)
|
||||
{
|
||||
var request = Request;
|
||||
//value.ClientAgent = request.UserAgent;
|
||||
//value.ClientIp = request.UserHostAddress;
|
||||
value.ClientAgent = Request.Headers["User-Agent"];
|
||||
value.ClientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
value.UserName = User.Identity.Name;
|
||||
return LogHelper.SaveLog(value);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
[HttpPost]
|
||||
public bool Post(BootstrapMenu value)
|
||||
public bool Post([FromBody]BootstrapMenu value)
|
||||
{
|
||||
return MenuHelper.SaveMenu(value);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<BootstrapMenu> Post(int id, JObject value)
|
||||
public IEnumerable<BootstrapMenu> Post(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = new List<BootstrapMenu>();
|
||||
dynamic json = value;
|
||||
|
@ -74,7 +74,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, JObject value)
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<Role> Post(int id, JObject value)
|
||||
public IEnumerable<Role> Post(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = new List<Role>();
|
||||
dynamic json = value;
|
||||
|
@ -59,7 +59,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, JObject value)
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
|
@ -85,7 +85,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
[HttpPost]
|
||||
public bool Post(Role value)
|
||||
public bool Post([FromBody]Role value)
|
||||
{
|
||||
return RoleHelper.SaveRole(value);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<User> Post(int id, JObject value)
|
||||
public IEnumerable<User> Post(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = new List<User>();
|
||||
dynamic json = value;
|
||||
|
@ -94,7 +94,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, JObject value)
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
|
|
|
@ -45,24 +45,24 @@
|
|||
<h4 class="modal-title" id="myModalLabel">用户编辑窗口</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-inline" id="dataForm" name="dataForm" role="form">
|
||||
<form class="form-inline" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label" for="userName">登陆名称</label>
|
||||
<input type="text" class="form-control" id="userName" name="userName" placeholder="不可为空,50字以内" maxlength="50" />
|
||||
<input type="text" class="form-control" id="userName" placeholder="不可为空,50字以内" maxlength="50" data-valid="true" />
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<input type="text" class="form-control hidden" id="userID" name="userID" />
|
||||
<label class="control-label" for="userName">显示名称</label>
|
||||
<input type="text" class="form-control" id="displayName" name="displayName" placeholder="不可为空,50字以内" maxlength="50" />
|
||||
<input type="text" class="form-control" id="displayName" placeholder="不可为空,50字以内" maxlength="50" data-valid="true" />
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label" for="password">登录密码</label>
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="不可为空,50字以内" maxlength="50" />
|
||||
<input type="password" class="form-control" id="password" placeholder="不可为空,50字以内" maxlength="50" data-valid="true" />
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label" for="confirm">确认密码</label>
|
||||
<input type="password" class="form-control" id="confirm" name="confirm" placeholder="与登陆密码一致,50字以内" maxlength="50" />
|
||||
<input type="password" class="form-control" id="confirm" placeholder="与登陆密码一致,50字以内" maxlength="50" equalTo="#password" data-valid="true" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
@section modal {
|
||||
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="#btnSubmit">
|
||||
@RenderSection("modal", false)
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
id: 'btn_assignRole',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: Role.url, data: { type: "group" }, swal: false,
|
||||
id: row.Id, url: Role.url, data: { type: "group" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -38,7 +38,7 @@
|
|||
id: 'btn_assignUser',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: User.url, data: { type: "group" }, swal: false,
|
||||
id: row.Id, url: User.url, data: { type: "group" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -59,7 +59,7 @@
|
|||
var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ Id: groupId, url: Role.url, method: "PUT", data: { type: "group", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
||||
$.bc({ id: groupId, url: Role.url, method: "PUT", data: { type: "group", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
||||
}
|
||||
}, {
|
||||
id: 'btnSubmitUser',
|
||||
|
@ -68,7 +68,7 @@
|
|||
var userIds = $dialogUser.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ Id: groupId, url: User.url, method: "PUT", data: { type: "group", userIds: userIds }, title: User.title, modal: 'dialogUser' });
|
||||
$.bc({ id: groupId, url: User.url, method: "PUT", data: { type: "group", userIds: userIds }, title: User.title, modal: 'dialogUser' });
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -115,13 +115,13 @@
|
|||
options = $.extend({
|
||||
remote: true,
|
||||
id: "",
|
||||
url: this.url,
|
||||
url: "",
|
||||
data: {},
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
method: "post",
|
||||
htmlTemplate: '<div class="form-group checkbox col-md-3 col-sm-4 col-xs-6"><label role="tooltip" title="{3}"><input type="checkbox" value="{0}" {2}/>{1}</label></div>',
|
||||
title: this.title,
|
||||
title: "",
|
||||
swal: true,
|
||||
modal: null,
|
||||
loading: false,
|
||||
|
@ -170,7 +170,7 @@
|
|||
function success(result) {
|
||||
var interval = 10;
|
||||
if ($.isFunction(options.callback)) {
|
||||
options.callback.call(options.$element == null ? this : options.$element, result);
|
||||
options.callback.call(options.$element == null ? options : options.$element, result);
|
||||
}
|
||||
if (options.modal !== null && (result || options.loading)) {
|
||||
$(options.modal).modal('hide');
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
id: 'btn_assignRole',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: Role.url, data: { type: "menu" }, swal: false,
|
||||
id: row.Id, url: Role.url, data: { type: "menu" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -64,7 +64,7 @@
|
|||
var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ Id: menuId, url: Role.url, method: "PUT", data: { type: "menu", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
||||
$.bc({ id: menuId, url: Role.url, method: "PUT", data: { type: "menu", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
||||
}
|
||||
}]
|
||||
},
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
id: 'btn_assignUser',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: User.url, data: { type: "role" }, swal: false,
|
||||
id: row.Id, url: User.url, data: { type: "role" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -44,7 +44,7 @@
|
|||
id: 'btn_assignGroup',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: Group.url, data: { type: "role" }, swal: false,
|
||||
id: row.Id, url: Group.url, data: { type: "role" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -62,7 +62,7 @@
|
|||
id: 'btn_assignMenu',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: Menu.url, data: { type: "role" }, swal: false,
|
||||
id: row.Id, url: Menu.url, data: { type: "role" }, swal: false,
|
||||
callback: function (result) {
|
||||
$dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName));
|
||||
$btnSubmitMenu.data('type', 'menu');
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
id: 'btn_assignRole',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: Role.url, data: { type: "user" }, swal: false,
|
||||
id: row.Id, url: Role.url, data: { type: "user" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -40,7 +40,7 @@
|
|||
id: 'btn_assignGroup',
|
||||
click: function (row) {
|
||||
$.bc({
|
||||
Id: row.Id, url: Group.url, data: { type: "user" }, swal: false,
|
||||
id: row.Id, url: Group.url, data: { type: "user" }, swal: false,
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -61,7 +61,7 @@
|
|||
var roleIds = $dialogRole.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ Id: userId, url: Role.url, method: 'PUT', data: { type: "user", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
||||
$.bc({ id: userId, url: Role.url, method: 'PUT', data: { type: "user", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
||||
}
|
||||
}, {
|
||||
id: 'btnSubmitGroup',
|
||||
|
@ -75,7 +75,7 @@
|
|||
}]
|
||||
},
|
||||
callback: function (data) {
|
||||
if (data && data.success && data.oper === 'save' && data.UserName == $('#userDisplayName').attr('data-userName')) {
|
||||
if (data && data.success && data.oper === 'save' && data.data.UserName == $('#userDisplayName').attr('data-userName')) {
|
||||
$('#userDisplayName').text(data.data.DisplayName);
|
||||
}
|
||||
if (data && data.oper === 'create') {
|
||||
|
@ -103,35 +103,4 @@
|
|||
{ title: "说明", field: "Description", sortable: false }
|
||||
]
|
||||
});
|
||||
|
||||
// validate
|
||||
$('#dataForm').autoValidate({
|
||||
userName: {
|
||||
required: true,
|
||||
maxlength: 50,
|
||||
remote: {
|
||||
url: $.formatUrl("/api/Users/"),
|
||||
type: "PUT",
|
||||
data: {
|
||||
UserStatus: 9
|
||||
}
|
||||
}
|
||||
},
|
||||
password: {
|
||||
required: true,
|
||||
maxlength: 50
|
||||
},
|
||||
confirm: {
|
||||
required: true,
|
||||
equalTo: "#password"
|
||||
},
|
||||
displayName: {
|
||||
required: true,
|
||||
maxlength: 50
|
||||
}
|
||||
}, {
|
||||
userName: {
|
||||
remote: "此登陆名称已存在"
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue