增加功能:重置密码弹出框增加重置原因信息 #IS7V2

This commit is contained in:
Argo Zhang 2019-03-05 14:53:34 +08:00
parent 45cfc54c15
commit 642b74edfc
9 changed files with 59 additions and 5 deletions

View File

@ -45,7 +45,7 @@ namespace Bootstrap.Admin.Controllers.Api
}
/// <summary>
///
/// 重置密码调用
/// </summary>
/// <param name="userName"></param>
/// <param name="user"></param>

View File

@ -75,6 +75,9 @@ namespace Bootstrap.Admin.Controllers.Api
case "group":
ret = UserHelper.RetrievesByGroupId(id);
break;
case "reset":
ret = UserHelper.RetrieveResetReasonsByUserName(id).Select(u => new { u.Key, u.Value });
break;
}
return ret;
}

View File

@ -162,7 +162,7 @@
<span class="fa fa-user-plus"></span>
</div>
</div>
<input type="text" id="f_userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" minlength="4" maxlength="50" remote="api/Register" data-remote-msg="此用户已存在" data-valid="true" />
<input type="text" id="f_userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" minlength="4" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
@ -178,7 +178,7 @@
</div>
<div class="form-group">
<label for="f_desc">申请理由:</label>
<textarea id="f_desc" class="form-control" placeholder="申请理由500字以内" rows="3" maxlength="500" data-valid="true"></textarea>
<textarea id="f_desc" class="form-control" placeholder="申请理由500字以内" rows="3" maxlength="500" data-valid="true">我是用户XXX我的手机号是XXXXXX由于密码忘记请将密码重置为123登录后我自行更改谢谢管理员</textarea>
</div>
</div>
<div class="modal-footer">

View File

@ -80,7 +80,7 @@
</div>
<div class="modal-body">
<form class="form-inline">
<div class="row" id="resetForm">
<div class="form-row" id="resetForm">
<div class="form-group col-sm-6">
<label class="control-label" for="password">登录密码</label>
<input type="password" class="form-control" id="resetPassword" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
@ -89,6 +89,10 @@
<label class="control-label" for="confirm">确认密码</label>
<input type="password" class="form-control" id="resetConfirm" placeholder="与登陆密码一致50字以内" maxlength="50" equalTo="#resetPassword" data-valid="true" />
</div>
<div class="form-group col-sm-12">
<label class="control-label" for="resetReason">重置原因</label>
<textarea class="form-control flex-sm-fill" id="resetReason" rows="3" readonly="readonly"></textarea>
</div>
</div>
</form>
</div>

View File

@ -7,6 +7,7 @@
var $dialogGroupForm = $('#groupForm');
var $dialogReset = $('#dialogReset');
var $dialogResetHeader = $('#myResetModalLabel');
var $resetReason = $('#resetReason');
var $table = $('table');
$table.lgbTable({
@ -102,9 +103,19 @@
$table.bootstrapTable('uncheckAll');
$table.bootstrapTable('check', index);
$dialogResetHeader.text($.format("{0} - 重置密码窗口", row.UserName));
$.bc({
id: row.UserName, url: User.url, method: 'post', query: { type: "reset" }, callback: function (result) {
if ($.isArray(result)) {
var reason = result.map(function (v, index) {
return $.format("{0}: {1}", v.Key, v.Value);
}).join('\n');
$resetReason.text(reason);
$dialogReset.modal('show');
}
}
});
}
}
}
]
}

View File

@ -247,5 +247,12 @@ namespace Bootstrap.DataAccess
/// <param name="userName"></param>
/// <returns></returns>
public static ResetUser RetrieveResetUserByUserName(string userName) => DbContextManager.Create<ResetUser>().RetrieveUserByUserName(userName);
/// <summary>
/// 通过登录账户获得重置密码原因
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public static IEnumerable<KeyValuePair<DateTime, string>> RetrieveResetReasonsByUserName(string userName) => DbContextManager.Create<ResetUser>().RetrieveResetReasonsByUserName(userName);
}
}

View File

@ -1,5 +1,7 @@
using PetaPoco;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.DataAccess
{
@ -58,5 +60,12 @@ namespace Bootstrap.DataAccess
/// <param name="userName"></param>
/// <returns></returns>
public virtual void DeleteByUserName(string userName) => DbManager.Create().Delete<ResetUser>("where UserName = @0", userName);
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public virtual IEnumerable<KeyValuePair<DateTime, string>> RetrieveResetReasonsByUserName(string userName) => DbManager.Create().Fetch<ResetUser>("where UserName = @0 order by ResetTime desc", userName).Select(user => new KeyValuePair<DateTime, string>(user.ResetTime, user.Reason));
}
}

View File

@ -59,6 +59,9 @@ namespace Bootstrap.Admin.Api
var gid = new Group().Retrieves().Where(r => r.GroupName == "Admin").First().Id;
ret = await Client.PostAsJsonAsync<string, IEnumerable<object>>($"{gid}?type=group", string.Empty);
Assert.NotNull(ret);
ret = await Client.PostAsJsonAsync<string, IEnumerable<object>>("UnitTest?type=reset", string.Empty);
Assert.NotNull(ret);
}
[Fact]

View File

@ -57,5 +57,22 @@ namespace Bootstrap.DataAccess
var count = db.ExecuteScalar<int>("select count(Id) from ResetUsers");
Assert.Equal(0, count);
}
[Fact]
public void RetrieveResetReasonsByUserName_Ok()
{
var resetUser = new ResetUser()
{
UserName = "UnitTest",
Reason = "UnitTest",
DisplayName = "UnitTest",
ResetTime = DateTime.Now
};
var db = DbManager.Create();
db.Save(resetUser);
var reasons = resetUser.RetrieveResetReasonsByUserName(resetUser.UserName);
Assert.NotEmpty(reasons);
}
}
}