增加功能:增加用户选择皮肤功能
This commit is contained in:
parent
9f34d5ab73
commit
e97db1a077
|
@ -32,6 +32,10 @@ namespace Bootstrap.Admin.Controllers
|
|||
[HttpPut]
|
||||
public bool Put([FromBody]User value)
|
||||
{
|
||||
if(value.UserStatus == 3)
|
||||
{
|
||||
return UserHelper.SaveUserCssByName(value.UserName, value.Css);
|
||||
}
|
||||
if (value.UserStatus == 9)
|
||||
{
|
||||
// vlaidate userName
|
||||
|
|
|
@ -15,12 +15,13 @@ namespace Bootstrap.Admin.Models
|
|||
Icon = user.Icon;
|
||||
DisplayName = user.DisplayName;
|
||||
UserName = user.UserName;
|
||||
Css = user.Css;
|
||||
}
|
||||
public string UserName { get; private set; }
|
||||
public string UserName { get; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DisplayName { get; private set; }
|
||||
public string DisplayName { get; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -28,6 +29,10 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
/// 获得/设置 用户头像地址
|
||||
/// </summary>
|
||||
public string Icon { get; private set; }
|
||||
public string Icon { get; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Css { get; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
using System.IO;
|
||||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
|
||||
namespace Bootstrap.Admin.Models
|
||||
|
@ -11,7 +14,11 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
/// 获得/设置 头像文件大小
|
||||
/// </summary>
|
||||
public long Size { get; private set; }
|
||||
public long Size { get; }
|
||||
/// <summary>
|
||||
/// 获得 系统配置的所有样式表
|
||||
/// </summary>
|
||||
public IEnumerable<BootstrapDict> Csss { get; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -23,6 +30,8 @@ namespace Bootstrap.Admin.Models
|
|||
{
|
||||
Size = new FileInfo(fileName).Length;
|
||||
}
|
||||
|
||||
Csss = DictHelper.RetrieveWebCss();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,8 +26,8 @@
|
|||
maxlength: 50
|
||||
}
|
||||
}, {
|
||||
button: ['btnSaveDisplayName']
|
||||
});
|
||||
button: ['btnSaveDisplayName']
|
||||
});
|
||||
$('#passwordDataForm').autoValidate({
|
||||
currentPassword: {
|
||||
required: true,
|
||||
|
@ -43,8 +43,8 @@
|
|||
maxlength: 50
|
||||
}
|
||||
}, {
|
||||
button: ['btnSavePassword']
|
||||
});
|
||||
button: ['btnSavePassword']
|
||||
});
|
||||
|
||||
var bsa = new BootstrapAdmin({
|
||||
url: Profiles.url,
|
||||
|
@ -54,7 +54,8 @@
|
|||
Password: "currentPassword",
|
||||
NewPassword: "newPassword",
|
||||
DisplayName: "displayName",
|
||||
UserName: "userName"
|
||||
UserName: "userName",
|
||||
Css: "css"
|
||||
}
|
||||
}),
|
||||
click: {
|
||||
|
@ -81,6 +82,12 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
id: 'btnSaveCss',
|
||||
click: function (row, data) {
|
||||
data.UserStatus = 3;
|
||||
$.bc({ url: User.url, method: "PUT", data: data, title: "保存样式" });
|
||||
}
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -40,15 +40,17 @@
|
|||
<div class="panel-body">
|
||||
<form id="passwordDataForm" name="passwordDataForm" class="form-inline" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-4 col-xs-12">
|
||||
<div class="form-group col-xs-12">
|
||||
<label class="control-label" for="currentPassword">原密码: </label>
|
||||
<input type="password" class="form-control" id="currentPassword" name="currentPassword" placeholder="原密码,50字以内" maxlength="50" />
|
||||
</div>
|
||||
<div class="form-group col-md-4 col-sm-6 col-xs-12">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="newPassword">新密码: </label>
|
||||
<input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="新密码,50字以内" maxlength="50" />
|
||||
</div>
|
||||
<div class="form-group col-md-4 col-sm-6 col-xs-12">
|
||||
<div class="form-group col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="confirmPassword">确认密码: </label>
|
||||
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="与新密码一致,50字以内" maxlength="50" />
|
||||
</div>
|
||||
|
@ -59,6 +61,35 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">网站皮肤</div>
|
||||
<div class="panel-body">
|
||||
<form id="infoDataForm" name="cssDataForm" class="form-inline" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-xs-12">
|
||||
<label class="control-label" for="userName">样式</label>
|
||||
<select id="css" class="select form-control">
|
||||
<option value="">未设置</option>
|
||||
@foreach (var css in Model.Csss)
|
||||
{
|
||||
if (css.Code == Model.Css)
|
||||
{
|
||||
<option selected value="@css.Code">@css.Name</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@css.Code">@css.Name</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="modal-footer">
|
||||
<button id="btnSaveCss" class="btn btn-default" type="button" disabled data-admin="@LgbPrincipal.IsWebAdmin(User.Identity.Name)"><i class="fa fa-save"></i><span>保存</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">修改头像</div>
|
||||
<div class="panel-body">
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
<cacheManagerList>
|
||||
<add key="bd" url="http://localhost:53233/CacheList.axd?cacheKey={0}" desc="系统缓存模块" />
|
||||
<add key="bccs" url="http://localhost:3609/CacheList.axd?cacheKey={0}" desc="集控系统缓存模块" />
|
||||
<add key="bccs" url="http://localhost:49823/CacheList.axd?cacheKey={0}" desc="集控系统缓存模块" />
|
||||
<add key="cps" url="http://localhost:43112/CacheList.axd?cacheKey={0}" desc="云心理后台缓存" />
|
||||
</cacheManagerList>
|
||||
|
||||
|
|
|
@ -83,8 +83,25 @@ namespace Bootstrap.DataAccess
|
|||
cacheKeys.Add(ExceptionHelper.RetrieveExceptionsDataKey + "*");
|
||||
}
|
||||
|
||||
CacheManager.Clear(k => cacheKeys.Any(key => key.EndsWith("*") ? k.Contains(key.TrimEnd('*')) : key == k));
|
||||
CacheListSection.ClearCache(cacheKeys);
|
||||
ClearCache(cacheKeys);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
internal static void ClearCache(string key)
|
||||
{
|
||||
CacheManager.Clear(k => key.EndsWith("*") ? k.Contains(key.TrimEnd('*')) : key == k);
|
||||
CacheListSection.ClearCache(key);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
internal static void ClearCache(IEnumerable<string> keys)
|
||||
{
|
||||
CacheManager.Clear(k => keys.Any(key => key.EndsWith("*") ? k.Contains(key.TrimEnd('*')) : key == k));
|
||||
CacheListSection.ClearCache(keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复 9 表示前台remote validate
|
||||
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复 3 表示更改个人皮肤 9 表示前台remote validate
|
||||
/// </summary>
|
||||
public int UserStatus { get; set; }
|
||||
/// <summary>
|
||||
|
@ -65,6 +65,10 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public string NewPassword { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 使用的样式
|
||||
/// </summary>
|
||||
public string Css { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
|
|
@ -327,7 +327,35 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", userName));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName);
|
||||
CacheManager.Clear(k => key == k);
|
||||
CacheCleanUtility.ClearCache(key);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionManager.Publish(ex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据用户名更改用户皮肤
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="cssName"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveUserCssByName(string userName, string cssName)
|
||||
{
|
||||
bool ret = false;
|
||||
try
|
||||
{
|
||||
string sql = "Update Users set Css = @cssName where UserName = @userName";
|
||||
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
|
||||
{
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@cssName", DBAccess.ToDBValue(cssName)));
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", userName));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName);
|
||||
CacheCleanUtility.ClearCache(key);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ CREATE TABLE [dbo].[Users](
|
|||
[RejectedTime] [datetime] NULL,
|
||||
[RejectedReason] [nvarchar](50) NULL,
|
||||
[Icon] [varchar](50) NOT NULL,
|
||||
[Css] [varchar](50) NULL,
|
||||
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
|
Loading…
Reference in New Issue