From 1e2653e4e8f5e3c7b0370f1e8bf01838b5e3b2d4 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Thu, 13 Sep 2018 21:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9AProc=5FSaveUser?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E8=BF=87=E7=A8=8B=E7=A7=BB=E9=99=A4ApprovedT?= =?UTF-8?q?ime=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=BE=8E=E5=BC=8F?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E6=8F=92=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Controllers/Api/UsersController.cs | 1 - Bootstrap.DataAccess/UserHelper.cs | 3 --- DatabaseScripts/Procedures.sql | 6 ++++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Bootstrap.Admin/Controllers/Api/UsersController.cs b/Bootstrap.Admin/Controllers/Api/UsersController.cs index 367eb3ac..8693cb3c 100644 --- a/Bootstrap.Admin/Controllers/Api/UsersController.cs +++ b/Bootstrap.Admin/Controllers/Api/UsersController.cs @@ -83,7 +83,6 @@ namespace Bootstrap.Admin.Controllers.Api { value.Description = string.Format("管理员{0}创建用户", User.Identity.Name); value.ApprovedBy = User.Identity.Name; - value.ApprovedTime = DateTime.Now; ret = UserHelper.SaveUser(value); } else diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index bc7e779e..e87a19f7 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -116,9 +116,6 @@ namespace Bootstrap.DataAccess cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@passSalt", p.PassSalt)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@displayName", p.DisplayName)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedBy", DBAccessFactory.ToDBValue(p.ApprovedBy))); - object approvedTime = p.ApprovedTime; - if (p.ApprovedTime == DateTime.MinValue) approvedTime = DBNull.Value; - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedTime", approvedTime)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", p.Description)); ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1; if (ret) CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? new List() : new List() { p.Id }); diff --git a/DatabaseScripts/Procedures.sql b/DatabaseScripts/Procedures.sql index c01d9df2..a1157674 100644 --- a/DatabaseScripts/Procedures.sql +++ b/DatabaseScripts/Procedures.sql @@ -178,8 +178,7 @@ CREATE PROCEDURE [dbo].[Proc_SaveUsers] @password varchar(50), @passSalt varchar(50), @displayName nvarchar(50), - @approvedBy nvarchar(50), - @approvedTime datetime, + @approvedBy nvarchar(50) = null, @description nvarchar(500) WITH ENCRYPTION AS @@ -189,6 +188,9 @@ BEGIN SET NOCOUNT ON; SET XACT_ABORT ON; -- Insert statements for procedure here + declare @approvedTime datetime + if @approvedBy is not null set @approvedTime = GETDATE() + begin if(not exists (select 1 from Users Where UserName = @userName)) begin