🔥移除仓储不常用方法

This commit is contained in:
不做码农 2023-08-15 09:37:31 +08:00
parent 31cf1a82f1
commit ff4e857128
6 changed files with 10 additions and 62 deletions

View File

@ -61,10 +61,10 @@ namespace ZR.Repository
#endregion add #endregion add
#region update #region update
public IUpdateable<T> Updateable(T entity) //public IUpdateable<T> Updateable(T entity)
{ //{
return Context.Updateable(entity); // return Context.Updateable(entity);
} //}
/// <summary> /// <summary>
/// 实体根据主键更新 /// 实体根据主键更新
@ -103,37 +103,6 @@ namespace ZR.Repository
return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand(); return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
} }
public int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
{
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
}
/// <summary>
///
/// </summary>
/// <param name="entity"></param>
/// <param name="list"></param>
/// <param name="isNull">默认为true</param>
/// <returns></returns>
public int Update(T entity, List<string> list = null, bool isNull = true)
{
list ??= new List<string>()
{
"Create_By",
"Create_time"
};
return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand();
}
//public bool Update(List<T> entity)
//{
// var result = base.Context.Ado.UseTran(() =>
// {
// base.Context.Updateable(entity).ExecuteCommand();
// });
// return result.IsSuccess;
//}
/// <summary> /// <summary>
/// 更新指定列 egUpdate(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" }); /// 更新指定列 egUpdate(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" });
/// </summary> /// </summary>
@ -160,14 +129,6 @@ namespace ZR.Repository
throw; throw;
} }
} }
public IStorageable<T> Storageable(T t)
{
return Context.Storageable<T>(t);
}
public IStorageable<T> Storageable(List<T> t)
{
return Context.Storageable(t);
}
/// <summary> /// <summary>
/// ///

View File

@ -19,7 +19,6 @@ namespace ZR.Repository
#endregion add #endregion add
#region update #region update
IUpdateable<T> Updateable(T entity);
int Update(T entity, bool ignoreNullColumns = false); int Update(T entity, bool ignoreNullColumns = false);
/// <summary> /// <summary>
@ -32,13 +31,9 @@ namespace ZR.Repository
int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where); int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns); int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
#endregion update #endregion update
IStorageable<T> Storageable(T t);
IStorageable<T> Storageable(List<T> t);
DbResult<bool> UseTran(Action action); DbResult<bool> UseTran(Action action);
DbResult<bool> UseTran(SqlSugarClient client, Action action); DbResult<bool> UseTran(SqlSugarClient client, Action action);

View File

@ -8,11 +8,5 @@ namespace ZR.Service
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class BaseService<T> : BaseRepository<T> where T : class, new() public class BaseService<T> : BaseRepository<T> where T : class, new()
{ {
//public IBaseRepository<T> baseRepository;
//public BaseService(IBaseRepository<T> repository)
//{
// this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository));
//}
} }
} }

View File

@ -82,7 +82,7 @@ namespace ZR.Service.System
LangName = item.LangName, LangName = item.LangName,
}); });
} }
var storage = Storageable(langs) var storage = Context.Storageable(langs)
.WhereColumns(it => new { it.LangKey, it.LangCode }) .WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage(); .ToStorage();
@ -110,7 +110,7 @@ namespace ZR.Service.System
/// <returns></returns> /// <returns></returns>
public (string, object, object) ImportCommonLang(List<CommonLang> list) public (string, object, object) ImportCommonLang(List<CommonLang> list)
{ {
var x = Storageable(list) var x = Context.Storageable(list)
.WhereColumns(it => new { it.LangKey, it.LangCode }) .WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage(); .ToStorage();
x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分; x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分;

View File

@ -700,7 +700,7 @@ namespace ZR.Service
} }
//Insert(menuList); //Insert(menuList);
var x = Storageable(menuList) var x = Context.Storageable(menuList)
.SplitInsert(it => !it.Any()) .SplitInsert(it => !it.Any())
.SplitUpdate(it => !it.Any()) .SplitUpdate(it => !it.Any())
.WhereColumns(it => new { it.MenuName, it.ParentId }) .WhereColumns(it => new { it.MenuName, it.ParentId })

View File

@ -1,6 +1,5 @@
using Infrastructure.Attribute; using Infrastructure.Attribute;
using SqlSugar; using SqlSugar;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using ZR.Model.System; using ZR.Model.System;
using ZR.Service.System.IService; using ZR.Service.System.IService;
@ -20,15 +19,14 @@ namespace ZR.Service.System
public void InsertUserPost(SysUser user) public void InsertUserPost(SysUser user)
{ {
// 新增用户与岗位管理 // 新增用户与岗位管理
List<SysUserPost> list = new List<SysUserPost>(); List<SysUserPost> list = new();
foreach (var item in user.PostIds) foreach (var item in user.PostIds)
{ {
list.Add(new SysUserPost() { PostId = item, UserId = user.UserId }); list.Add(new SysUserPost() { PostId = item, UserId = user.UserId });
} }
Insert(list); InsertRange(list);
} }
/// <summary> /// <summary>
/// 查询用户岗位集合 /// 查询用户岗位集合
/// </summary> /// </summary>