🔥移除仓储不常用方法

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,11 +61,11 @@ namespace ZR.Repository
#endregion add
#region update
public IUpdateable<T> Updateable(T entity)
{
return Context.Updateable(entity);
}
//public IUpdateable<T> Updateable(T entity)
//{
// return Context.Updateable(entity);
//}
/// <summary>
/// 实体根据主键更新
/// </summary>
@ -103,37 +103,6 @@ namespace ZR.Repository
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>
/// 更新指定列 egUpdate(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" });
/// </summary>
@ -160,14 +129,6 @@ namespace ZR.Repository
throw;
}
}
public IStorageable<T> Storageable(T t)
{
return Context.Storageable<T>(t);
}
public IStorageable<T> Storageable(List<T> t)
{
return Context.Storageable(t);
}
/// <summary>
///

View File

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

View File

@ -8,11 +8,5 @@ namespace ZR.Service
/// <typeparam name="T"></typeparam>
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,
});
}
var storage = Storageable(langs)
var storage = Context.Storageable(langs)
.WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage();
@ -110,7 +110,7 @@ namespace ZR.Service.System
/// <returns></returns>
public (string, object, object) ImportCommonLang(List<CommonLang> list)
{
var x = Storageable(list)
var x = Context.Storageable(list)
.WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage();
x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分;

View File

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

View File

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