From cf3fade696d96c31463c23cf4388dac77eeb5711 Mon Sep 17 00:00:00 2001 From: ndbs Date: Tue, 13 Dec 2022 09:53:24 +0800 Subject: [PATCH] =?UTF-8?q?app2.0=20=E6=88=91=E7=9A=84=E5=BA=94=E7=94=A8?= =?UTF-8?q?=20=E7=A9=BA=E5=BA=94=E7=94=A8=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyFunction/MyFunctionService.cs | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.AppMagager/MyFunction/MyFunctionService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.AppMagager/MyFunction/MyFunctionService.cs index 668b7a939..046cbf0dd 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.AppMagager/MyFunction/MyFunctionService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.AppMagager/MyFunction/MyFunctionService.cs @@ -13,7 +13,7 @@ namespace Learun.Application.AppMagager /// 日 期:2018-06-26 10:32 /// 描 述:我的常用移动应用 /// - public class MyFunctionService: RepositoryFactory + public class MyFunctionService : RepositoryFactory { #region 构造函数和属性 @@ -44,7 +44,7 @@ namespace Learun.Application.AppMagager strSql.Append("SELECT "); strSql.Append(fieldSql); strSql.Append(" FROM LR_App_MyFunction t where t.F_UserId = @userId Order by t.F_Sort "); - return this.BaseRepository().FindList(strSql.ToString(),new { userId }); + return this.BaseRepository().FindList(strSql.ToString(), new { userId }); } catch (Exception ex) { @@ -66,22 +66,30 @@ namespace Learun.Application.AppMagager /// 主键 /// /// - public void SaveEntity(string userId,string strFunctionId) + public void SaveEntity(string userId, string strFunctionId) { var db = this.BaseRepository().BeginTrans(); try { - string[] functionIds = strFunctionId.Split(','); - db.Delete(t=>t.F_UserId.Equals(userId)); - int num = 0; - foreach (var functionId in functionIds) { - MyFunctionEntity entity = new MyFunctionEntity(); - entity.Create(); - entity.F_UserId = userId; - entity.F_FunctionId = functionId; - entity.F_Sort = num; - db.Insert(entity); - num++; + if (!string.IsNullOrEmpty(strFunctionId)) + { + string[] functionIds = strFunctionId.Split(','); + db.Delete(t => t.F_UserId.Equals(userId)); + int num = 0; + foreach (var functionId in functionIds) + { + MyFunctionEntity entity = new MyFunctionEntity(); + entity.Create(); + entity.F_UserId = userId; + entity.F_FunctionId = functionId; + entity.F_Sort = num; + db.Insert(entity); + num++; + } + } + else + { + db.Delete(t => t.F_UserId.Equals(userId)); } db.Commit(); }