优化数据仓储
This commit is contained in:
parent
640776181a
commit
67e1343e24
@ -49,7 +49,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Title), m => m.Title.Contains(parm.Title));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status);
|
||||
|
||||
var response = _ArticleService.GetPages(predicate.ToExpression(), parm, f => f.Cid, "Desc");
|
||||
var response = _ArticleService.GetPages(predicate.ToExpression(), parm, f => f.Cid, OrderByType.Desc);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
//从 Dto 映射到 实体
|
||||
var model = parm.Adapt<SysConfig>().ToCreate();
|
||||
|
||||
return SUCCESS(_SysConfigService.Add(model, it => new
|
||||
return SUCCESS(_SysConfigService.Insert(model, it => new
|
||||
{
|
||||
it.ConfigName,
|
||||
it.ConfigKey,
|
||||
|
||||
@ -51,7 +51,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
m.JobGroup.Contains(parm.QueryText) ||
|
||||
m.AssemblyName.Contains(parm.QueryText));
|
||||
|
||||
var response = _tasksQzService.GetPages(predicate.ToExpression(), pager, f => f.IsStart, "Desc");
|
||||
var response = _tasksQzService.GetPages(predicate.ToExpression(), pager, f => f.IsStart, OrderByType.Desc);
|
||||
|
||||
return SUCCESS(response, TIME_FORMAT_FULL);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
predicate = predicate.AndIF(queryDto.Status.IfNotEmpty(), m => m.Status == queryDto.Status);
|
||||
predicate = predicate.AndIF(queryDto.JobId.IfNotEmpty(), m => m.JobId == queryDto.JobId);
|
||||
|
||||
var response = tasksLogService.GetPages(predicate.ToExpression(), pager, m => m.CreateTime, "Desc");
|
||||
var response = tasksLogService.GetPages(predicate.ToExpression(), pager, m => m.CreateTime, OrderByType.Desc);
|
||||
|
||||
return SUCCESS(response, TIME_FORMAT_FULL);
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
//从 Dto 映射到 实体
|
||||
var model = parm.Adapt<Gendemo>().ToCreate(HttpContext);
|
||||
|
||||
return SUCCESS(_GendemoService.Add(model, it => new
|
||||
return SUCCESS(_GendemoService.Insert(model, it => new
|
||||
{
|
||||
it.Name,
|
||||
it.Icon,
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
"profiles": {
|
||||
"ZRAdmin": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchBrowser": false,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": ""
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
"applicationUrl": "http://localhost:8888"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,12 +148,12 @@ namespace ZR.Admin.WebApi
|
||||
|
||||
SugarIocServices.AddSqlSugar(new List<IocConfig>() {
|
||||
new IocConfig() {
|
||||
ConfigId = "0", //主数据库
|
||||
ConfigId = "0",
|
||||
ConnectionString = connStr,
|
||||
DbType = (IocDbType)dbType,
|
||||
IsAutoCloseConnection = true//自动释放
|
||||
}, new IocConfig() {
|
||||
ConfigId = "1", // 多租户用到
|
||||
ConfigId = "1",
|
||||
ConnectionString = connStrBus,
|
||||
DbType = (IocDbType)dbType_bus,
|
||||
IsAutoCloseConnection = true//自动释放
|
||||
@ -161,14 +161,13 @@ namespace ZR.Admin.WebApi
|
||||
});
|
||||
|
||||
//调式代码 用来打印SQL
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnLogExecuting = (sql, pars) =>
|
||||
DbScoped.SugarScope.GetConnection("0").Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("【SQL语句】" + sql.ToLower() + "\r\n"
|
||||
+ DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
};
|
||||
//出错打印日志
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnError = (e) =>
|
||||
DbScoped.SugarScope.GetConnection("0").Aop.OnError = (e) =>
|
||||
{
|
||||
Console.WriteLine($"[执行Sql出错]{e.Message},SQL={e.Sql}");
|
||||
Console.WriteLine();
|
||||
@ -177,7 +176,6 @@ namespace ZR.Admin.WebApi
|
||||
//调式代码 用来打印SQL
|
||||
DbScoped.SugarScope.GetConnection(1).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("【SQL语句Bus】" + sql.ToLower() + "\r\n"
|
||||
+ DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
};
|
||||
|
||||
@ -87,7 +87,7 @@ namespace {ApiControllerNamespace}.Controllers
|
||||
//从 Dto 映射到 实体
|
||||
var model = parm.Adapt<{ModelName}>().ToCreate(HttpContext);
|
||||
|
||||
return SUCCESS(_{ModelName}Service.Add(model, it => new
|
||||
return SUCCESS(_{ModelName}Service.Insert(model, it => new
|
||||
{
|
||||
{InsertColumn}
|
||||
}));
|
||||
|
||||
@ -10,13 +10,14 @@ namespace ZR.Model.Models
|
||||
/// @date 2021-11-24
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("gen_demo")]
|
||||
[SqlSugar.Tenant("0")]
|
||||
public class Gendemo
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 :自增id
|
||||
/// 空值 :False
|
||||
/// </summary>
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = false, IsIdentity = true)]
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :名称
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@ -8,6 +9,7 @@ namespace ZR.Model.System
|
||||
/// 文章表
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("article")]
|
||||
[Tenant("0")]
|
||||
public class Article
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@ -8,7 +9,8 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 文章目录
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("articleCategory")]
|
||||
[SugarTable("articleCategory")]
|
||||
[Tenant("0")]
|
||||
public class ArticleCategory
|
||||
{
|
||||
public int Category_Id { get; set; }
|
||||
@ -16,7 +18,7 @@ namespace ZR.Model.System
|
||||
public int ParentId { get; set; }
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<ArticleCategory> Children { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ namespace ZR.Model.System.Generate
|
||||
/// 代码生成表
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("gen_table")]
|
||||
[SqlSugar.Tenant("0")]
|
||||
public class GenTable: SysBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -9,6 +9,7 @@ namespace ZR.Model.System.Generate
|
||||
/// 代码生成表字段
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("gen_table_column")]
|
||||
[SqlSugar.Tenant("0")]
|
||||
public class GenTableColumn: SysBase
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@ -10,7 +11,8 @@ namespace ZR.Model.System
|
||||
/// @author zhaorui
|
||||
/// @date 2021-09-29
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("sys_config")]
|
||||
[SugarTable("sys_config")]
|
||||
[Tenant("0")]
|
||||
public class SysConfig: SysBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -8,7 +8,8 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 部门表
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("sys_dept")]
|
||||
[SugarTable("sys_dept")]
|
||||
[Tenant("0")]
|
||||
public class SysDept: SysBase
|
||||
{
|
||||
/** 部门ID */
|
||||
|
||||
@ -9,7 +9,7 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 字典数据表
|
||||
/// </summary>
|
||||
//[Table("sys_dict_data")]
|
||||
[Tenant("0")]
|
||||
[SugarTable("sys_dict_data")]
|
||||
public class SysDictData: SysBase
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ namespace ZR.Model.System
|
||||
/// 字典类型表
|
||||
/// </summary>
|
||||
[SugarTable("sys_dict_type")]//当和数据库名称不一样可以设置别名
|
||||
//[Table("sys_dict_type")]
|
||||
[Tenant("0")]
|
||||
public class SysDictType : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SqlSugar.SugarTable("sys_file")]
|
||||
[Tenant("0")]
|
||||
[SugarTable("sys_file")]
|
||||
public class SysFile
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -8,6 +8,7 @@ namespace ZR.Model.System
|
||||
/// sys_logininfor 表
|
||||
/// </summary>
|
||||
[SugarTable("sys_logininfor")]
|
||||
[Tenant("0")]
|
||||
public class SysLogininfor: SysBase
|
||||
{
|
||||
//[Key]
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// Sys_menu表
|
||||
/// </summary>
|
||||
//[Table("sys_menu")]
|
||||
[SqlSugar.SugarTable("sys_menu")]
|
||||
[SugarTable("sys_menu")]
|
||||
[Tenant("0")]
|
||||
public class SysMenu: SysBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -1,25 +1,27 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SqlSugar.SugarTable("sys_oper_log")]
|
||||
[SugarTable("sys_oper_log")]
|
||||
[Tenant("0")]
|
||||
public class SysOperLog
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long OperId { get; set; }
|
||||
/** 操作模块 */
|
||||
//@Excel(name = "操作模块")
|
||||
public String title { get; set; }
|
||||
public string title { get; set; }
|
||||
|
||||
/** 业务类型(0其它 1新增 2修改 3删除) */
|
||||
//@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据")
|
||||
public int businessType { get; set; }
|
||||
|
||||
/** 业务类型数组 */
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int[] businessTypes { get; set; }
|
||||
|
||||
/** 请求方法 */
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
namespace ZR.Model.System
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SqlSugar.SugarTable("sys_post")]
|
||||
[SugarTable("sys_post")]
|
||||
[Tenant("0")]
|
||||
public class SysPost: SysBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@ -8,13 +9,14 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 角色表 sys_role
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("sys_role")]
|
||||
[SugarTable("sys_role")]
|
||||
[Tenant("0")]
|
||||
public class SysRole : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色ID
|
||||
/// </summary>
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -40,18 +42,18 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 删除标志(0代表存在 2代表删除)
|
||||
/// </summary>
|
||||
[SqlSugar.SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)]
|
||||
[SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)]
|
||||
public string DelFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单组
|
||||
/// </summary>
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public long[] MenuIds { get; set; }
|
||||
/// <summary>
|
||||
/// 部门组(数据权限)
|
||||
/// </summary>
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public long[] DeptIds { get; set; }
|
||||
|
||||
public SysRole() { }
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@ -8,14 +9,15 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 角色菜单
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("sys_role_menu")]
|
||||
[SugarTable("sys_role_menu")]
|
||||
[Tenant("0")]
|
||||
public class SysRoleMenu
|
||||
{
|
||||
[JsonProperty("roleId")]
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Role_id { get; set; }
|
||||
[JsonProperty("menuId")]
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Menu_id { get; set; }
|
||||
public DateTime Create_time { get; set; }
|
||||
public string Create_by { get; set; }
|
||||
|
||||
@ -9,6 +9,7 @@ namespace ZR.Model.System
|
||||
/// 角色部门
|
||||
/// </summary>
|
||||
[SugarTable("sys_role_post")]
|
||||
[Tenant("0")]
|
||||
public class SysRolePost
|
||||
{
|
||||
public long RoleId { get; set; }
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@ -7,7 +8,8 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 任务日志
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("sys_Tasks_log")]
|
||||
[SugarTable("sys_Tasks_log")]
|
||||
[Tenant("0")]
|
||||
public class SysTasksLog
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -11,6 +11,7 @@ namespace ZR.Model.System
|
||||
///计划任务
|
||||
///</summary>
|
||||
[SugarTable("Sys_TasksQz")]
|
||||
[Tenant("0")]
|
||||
public class SysTasksQz
|
||||
{
|
||||
public SysTasksQz()
|
||||
|
||||
@ -10,6 +10,7 @@ namespace ZR.Model.System
|
||||
/// 用户表
|
||||
/// </summary>
|
||||
[SugarTable("sys_user")]
|
||||
[Tenant("0")]
|
||||
public class SysUser : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -10,6 +10,7 @@ namespace ZR.Model.System
|
||||
/// 用户岗位
|
||||
/// </summary>
|
||||
[SugarTable("sys_user_post")]
|
||||
[Tenant("0")]
|
||||
public class SysUserPost
|
||||
{
|
||||
public long UserId { get; set; }
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@ -8,6 +9,7 @@ namespace ZR.Model.System
|
||||
/// 用户角色关联表 用户N-1 角色
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("sys_user_role")]
|
||||
[Tenant("0")]
|
||||
public class SysUserRole
|
||||
{
|
||||
[SqlSugar.SugarColumn(ColumnName = "user_id", IsPrimaryKey = true)]
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dto\" />
|
||||
<Folder Include="Enum\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -4,7 +4,9 @@ using SqlSugar.IOC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using ZR.Model;
|
||||
|
||||
namespace ZR.Repository
|
||||
@ -16,54 +18,37 @@ namespace ZR.Repository
|
||||
public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
|
||||
{
|
||||
public ISqlSugarClient Context;
|
||||
public BaseRepository(string configId = "0")
|
||||
|
||||
public BaseRepository(ISqlSugarClient client = null)
|
||||
{
|
||||
Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择
|
||||
var configId = typeof(T).GetCustomAttribute<TenantAttribute>()?.configId;
|
||||
if(configId != null)
|
||||
{
|
||||
Context = DbScoped.SugarScope.GetConnection(configId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context = client ?? DbScoped.SugarScope.GetConnection(1);//根据类传入的ConfigId自动选择
|
||||
}
|
||||
}
|
||||
|
||||
#region add
|
||||
/// <summary>
|
||||
/// 插入指定列使用
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <param name="iClumns"></param>
|
||||
/// <param name="ignoreNull"></param>
|
||||
/// <returns></returns>
|
||||
public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||
{
|
||||
return Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入实体
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <param name="IgnoreNullColumn">默认忽略null列</param>
|
||||
/// <returns></returns>
|
||||
public int Add(T t)
|
||||
{
|
||||
return Context.Insertable(t).ExecuteCommand();
|
||||
return Context.Insertable(t).IgnoreColumns(true).ExecuteCommand();
|
||||
}
|
||||
|
||||
//public int InsertIgnoreNullColumn(T t)
|
||||
//{
|
||||
// return Context.Insertable(t).IgnoreColumns(true).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public int InsertIgnoreNullColumn(T t, params string[] columns)
|
||||
//{
|
||||
// return Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public int Insert(SqlSugarClient client, T t)
|
||||
//{
|
||||
// return client.Insertable(t).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public long InsertBigIdentity(T t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).ExecuteReturnBigIdentity();
|
||||
//}
|
||||
|
||||
public int Insert(List<T> t)
|
||||
{
|
||||
return Context.Insertable(t).ExecuteCommand();
|
||||
@ -82,10 +67,10 @@ namespace ZR.Repository
|
||||
//{
|
||||
// return base.Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand();
|
||||
//}
|
||||
//public int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||
//{
|
||||
// return base.Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
|
||||
//}
|
||||
public int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||
{
|
||||
return Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
|
||||
}
|
||||
//public DbResult<bool> InsertTran(T t)
|
||||
//{
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
@ -128,35 +113,33 @@ namespace ZR.Repository
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
public IInsertable<T> Insertable(T t)
|
||||
{
|
||||
return Context.Insertable<T>(t);
|
||||
}
|
||||
#endregion add
|
||||
|
||||
#region update
|
||||
|
||||
//public bool UpdateEntity(T entity, bool ignoreNullColumns = false)
|
||||
//{
|
||||
// return base.Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0;
|
||||
//}
|
||||
public bool Update(T entity, bool ignoreNullColumns = false)
|
||||
{
|
||||
return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
//public bool Update(T entity, Expression<Func<T, bool>> expression)
|
||||
//{
|
||||
// return base.Context.Updateable(entity).Where(expression).ExecuteCommand() > 0;
|
||||
//}
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
{
|
||||
return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
//public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
//{
|
||||
// return base.Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand() > 0;
|
||||
//}
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
//public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
//{
|
||||
// return base.Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
//}
|
||||
|
||||
//public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
//{
|
||||
// return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
//}
|
||||
public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -175,7 +158,6 @@ namespace ZR.Repository
|
||||
"Create_time"
|
||||
};
|
||||
}
|
||||
//base.Context.Updateable(entity).IgnoreColumns(c => list.Contains(c)).Where(isNull).ExecuteCommand()
|
||||
return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
@ -281,40 +263,40 @@ namespace ZR.Repository
|
||||
// return Context.Queryable<T>(tableName).ToList();
|
||||
//}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
// var list = Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
//}
|
||||
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
||||
{
|
||||
int totalNumber = 0;
|
||||
var list = Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
return (list, totalNumber);
|
||||
}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
//}
|
||||
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10)
|
||||
{
|
||||
int totalNumber = 0;
|
||||
var list = Context.Queryable<T>().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
return (list, totalNumber);
|
||||
}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10)
|
||||
{
|
||||
int totalNumber = 0;
|
||||
|
||||
// if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
// }
|
||||
//}
|
||||
if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
return (list, totalNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
return (list, totalNumber);
|
||||
}
|
||||
}
|
||||
|
||||
//public List<T> SqlQueryToList(string sql, object obj = null)
|
||||
//{
|
||||
// return Context.Ado.SqlQuery<T>(sql, obj);
|
||||
//}
|
||||
public List<T> SqlQueryToList(string sql, object obj = null)
|
||||
{
|
||||
return Context.Ado.SqlQuery<T>(sql, obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
@ -347,9 +329,9 @@ namespace ZR.Repository
|
||||
return source.ToPage(parm);
|
||||
}
|
||||
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc")
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc)
|
||||
{
|
||||
var source = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc);
|
||||
var source = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == OrderByType.Asc, order, OrderByType.Asc).OrderByIF(orderEnum == OrderByType.Desc, order, OrderByType.Desc);
|
||||
|
||||
return source.ToPage(parm);
|
||||
}
|
||||
@ -395,11 +377,6 @@ namespace ZR.Repository
|
||||
var result = (Context.Ado.UseStoredProcedure().GetDataTable(procedureName, parameters), parameters);
|
||||
return result;
|
||||
}
|
||||
|
||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
}
|
||||
|
||||
public static class QueryableExtension
|
||||
|
||||
@ -15,19 +15,12 @@ namespace ZR.Repository
|
||||
public interface IBaseRepository<T> where T : class, new()
|
||||
{
|
||||
#region add
|
||||
int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||
int Add(T t);
|
||||
|
||||
//int InsertIgnoreNullColumn(T t);
|
||||
|
||||
//int InsertIgnoreNullColumn(T t, params string[] columns);
|
||||
|
||||
//int Insert(SqlSugarClient client, T t);
|
||||
|
||||
//long InsertBigIdentity(T t);
|
||||
|
||||
int Insert(List<T> t);
|
||||
//int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||
int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t);
|
||||
|
||||
@ -46,14 +39,12 @@ namespace ZR.Repository
|
||||
//bool ExecuteCommand(string sql, params SugarParameter[] parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, List<SugarParameter> parameters);
|
||||
|
||||
IInsertable<T> Insertable(T t);
|
||||
#endregion add
|
||||
|
||||
#region update
|
||||
|
||||
//bool UpdateEntity(T entity, bool ignoreNullColumns = false);
|
||||
|
||||
//bool Update(T entity, Expression<Func<T, bool>> expression);
|
||||
bool Update(T entity, bool ignoreNullColumns = false);
|
||||
|
||||
/// <summary>
|
||||
/// 只更新表达式的值
|
||||
@ -61,22 +52,12 @@ namespace ZR.Repository
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
//bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
|
||||
//bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
//bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="entity">T</param>
|
||||
/// <param name="list">忽略更新</param>
|
||||
/// <param name="isNull">Null不更新</param>
|
||||
/// <returns></returns>
|
||||
bool Update(T entity, List<string> list = null, bool isNull = true);
|
||||
|
||||
//bool Update(List<T> entity);
|
||||
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
|
||||
#endregion update
|
||||
@ -105,7 +86,7 @@ namespace ZR.Repository
|
||||
/// <returns></returns>
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm);
|
||||
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc");
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
|
||||
|
||||
bool Any(Expression<Func<T, bool>> expression);
|
||||
|
||||
@ -124,15 +105,13 @@ namespace ZR.Repository
|
||||
|
||||
//List<T> QueryableToList(string tableName);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
|
||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
|
||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Bootstrap.BootstrapParams bootstrap);
|
||||
|
||||
//List<T> SqlQueryToList(string sql, object obj = null);
|
||||
List<T> SqlQueryToList(string sql, object obj = null);
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
|
||||
@ -2,6 +2,7 @@ using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Model.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Repository
|
||||
{
|
||||
@ -14,6 +15,10 @@ namespace ZR.Repository
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class GendemoRepository : BaseRepository<Gendemo>
|
||||
{
|
||||
public GendemoRepository()
|
||||
{
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -13,7 +13,16 @@ namespace ZR.Repository.System
|
||||
/// 文章管理
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleRepository
|
||||
public class ArticleRepository : BaseRepository<Article>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文章目录
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleCategoryRepository : BaseRepository<ArticleCategory>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@ -33,13 +33,13 @@ namespace ZR.Repository.System
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysRole> SelectRoleList(SysRole sysRole, PagerInfo pager)
|
||||
{
|
||||
return Context.Queryable<SysRole>()
|
||||
.Where(role => role.DelFlag == "0")
|
||||
.WhereIF(!string.IsNullOrEmpty(sysRole.RoleName), role => role.RoleName.Contains(sysRole.RoleName))
|
||||
.WhereIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status)
|
||||
.WhereIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey)
|
||||
.OrderBy(role => role.RoleSort)
|
||||
.ToPage(pager);
|
||||
var exp = Expressionable.Create<SysRole>();
|
||||
exp.And(role => role.DelFlag == "0");
|
||||
exp.AndIF(!string.IsNullOrEmpty(sysRole.RoleName), role => role.RoleName.Contains(sysRole.RoleName));
|
||||
exp.AndIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status);
|
||||
exp.AndIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey);
|
||||
|
||||
return GetPages(exp.ToExpression(), pager, x => x.RoleSort);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
15
ZR.Repository/System/SysTasksQzRepository.cs
Normal file
15
ZR.Repository/System/SysTasksQzRepository.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Infrastructure.Attribute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
{
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysTasksQzRepository: BaseRepository<SysTasksQz>
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,12 @@
|
||||
using ZR.Repository;
|
||||
using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using SqlSugar.IOC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
using ZR.Model;
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
@ -6,284 +14,367 @@ namespace ZR.Service
|
||||
/// 基础服务定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BaseService<T> : BaseRepository<T>, IBaseService<T> where T : class, new()
|
||||
public class BaseService<T> : IBaseService<T> where T : class, new()
|
||||
{
|
||||
//#region 添加操作
|
||||
public IBaseRepository<T> baseRepository;
|
||||
|
||||
public BaseService(IBaseRepository<T> repository)
|
||||
{
|
||||
this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||
}
|
||||
#region add
|
||||
/// <summary>
|
||||
/// 插入指定列使用
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <param name="iClumns"></param>
|
||||
/// <param name="ignoreNull"></param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||
{
|
||||
return baseRepository.Insert(parm, iClumns, ignoreNull);
|
||||
}
|
||||
/// <summary>
|
||||
/// 插入实体
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public int Add(T t)
|
||||
{
|
||||
return baseRepository.Add(t);
|
||||
}
|
||||
public IInsertable<T> Insertable(T t)
|
||||
{
|
||||
return baseRepository.Insertable(t);
|
||||
}
|
||||
//public int Insert(SqlSugarClient client, T t)
|
||||
//{
|
||||
// return client.Insertable(t).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public long InsertBigIdentity(T t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).ExecuteReturnBigIdentity();
|
||||
//}
|
||||
|
||||
public int Insert(List<T> t)
|
||||
{
|
||||
return baseRepository.Insert(t);
|
||||
}
|
||||
public long InsertReturnBigIdentity(T t)
|
||||
{
|
||||
return baseRepository.InsertReturnBigIdentity(t);
|
||||
}
|
||||
|
||||
//public int InsertIgnoreNullColumn(List<T> t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).IgnoreColumns(true).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public int InsertIgnoreNullColumn(List<T> t, params string[] columns)
|
||||
//{
|
||||
// return base.Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand();
|
||||
//}
|
||||
//public DbResult<bool> InsertTran(T t)
|
||||
//{
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
// {
|
||||
// base.Context.Insertable(t).ExecuteCommand();
|
||||
// });
|
||||
// return result;
|
||||
//}
|
||||
|
||||
//public DbResult<bool> InsertTran(List<T> t)
|
||||
//{
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
// {
|
||||
// base.Context.Insertable(t).ExecuteCommand();
|
||||
// });
|
||||
// return result;
|
||||
//}
|
||||
|
||||
//public T InsertReturnEntity(T t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).ExecuteReturnEntity();
|
||||
//}
|
||||
|
||||
//public T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock)
|
||||
//{
|
||||
// return base.Context.Insertable(t).With(sqlWith).ExecuteReturnEntity();
|
||||
//}
|
||||
|
||||
//public bool ExecuteCommand(string sql, object parameters)
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
//public bool ExecuteCommand(string sql, params SugarParameter[] parameters)
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
//public bool ExecuteCommand(string sql, List<SugarParameter> parameters)
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
#endregion add
|
||||
|
||||
#region update
|
||||
|
||||
public bool Update(T entity, bool ignoreNullColumns = false)
|
||||
{
|
||||
return baseRepository.Update(entity, ignoreNullColumns);
|
||||
}
|
||||
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
{
|
||||
return baseRepository.Update(entity, expression, ignoreAllNull);
|
||||
}
|
||||
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.Update(entity, expression, where);
|
||||
}
|
||||
|
||||
public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 添加一条数据
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="parm">T</param>
|
||||
///// <param name="entity"></param>
|
||||
///// <param name="list"></param>
|
||||
///// <param name="isNull">默认为true</param>
|
||||
///// <returns></returns>
|
||||
//public int Add(T parm)
|
||||
//public bool Update(T entity, List<string> list = null, bool isNull = true)
|
||||
//{
|
||||
// return Add(parm);// Context.Insertable(parm).RemoveDataCache().ExecuteCommand();
|
||||
// if (list == null)
|
||||
// {
|
||||
// list = new List<string>()
|
||||
// {
|
||||
// "Create_By",
|
||||
// "Create_time"
|
||||
// };
|
||||
// }
|
||||
// //base.Context.Updateable(entity).IgnoreColumns(c => list.Contains(c)).Where(isNull).ExecuteCommand()
|
||||
// return baseRepository.Update(entity, list, isNull);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 添加
|
||||
///// </summary>
|
||||
///// <param name="parm"></param>
|
||||
///// <param name="iClumns">插入列</param>
|
||||
///// <param name="ignoreNull">忽略null列</param>
|
||||
///// <returns></returns>
|
||||
//public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||
//public bool Update(List<T> entity)
|
||||
//{
|
||||
// return Add(parm);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 批量添加数据
|
||||
///// </summary>
|
||||
///// <param name="parm">List<T></param>
|
||||
///// <returns></returns>
|
||||
//public int Add(List<T> parm)
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
// {
|
||||
// return 1;// Context.Insertable(parm).RemoveDataCache().ExecuteCommand();
|
||||
// base.Context.Updateable(entity).ExecuteCommand();
|
||||
// });
|
||||
// return result.IsSuccess;
|
||||
//}
|
||||
public bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
{
|
||||
return baseRepository.Update(where, columns);
|
||||
}
|
||||
#endregion update
|
||||
|
||||
///// <summary>
|
||||
///// 添加或更新数据,不推荐使用了
|
||||
///// </summary>
|
||||
///// <param name="parm">List<T></param>
|
||||
///// <returns></returns>
|
||||
//public T Saveable(T parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null)
|
||||
//{
|
||||
// var command = Context.Saveable(parm);
|
||||
public DbResult<bool> UseTran(Action action)
|
||||
{
|
||||
var result = baseRepository.UseTran(action) ;
|
||||
return result;
|
||||
}
|
||||
|
||||
// if (uClumns != null)
|
||||
// {
|
||||
// command = command.UpdateIgnoreColumns(uClumns);
|
||||
// }
|
||||
public DbResult<bool> UseTran(SqlSugarClient client, Action action)
|
||||
{
|
||||
var result = client.Ado.UseTran(() => action());
|
||||
return result;
|
||||
}
|
||||
|
||||
// if (iColumns != null)
|
||||
// {
|
||||
// command = command.InsertIgnoreColumns(iColumns);
|
||||
// }
|
||||
public bool UseTran2(Action action)
|
||||
{
|
||||
var result = baseRepository.UseTran2(action);
|
||||
return result;
|
||||
}
|
||||
|
||||
// return command.ExecuteReturnEntity();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 批量添加或更新数据
|
||||
///// </summary>
|
||||
///// <param name="parm">List<T></param>
|
||||
///// <returns></returns>
|
||||
//public List<T> Saveable(List<T> parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null)
|
||||
//{
|
||||
// var command = Context.Saveable(parm);
|
||||
|
||||
// if (uClumns != null)
|
||||
// {
|
||||
// command = command.UpdateIgnoreColumns(uClumns);
|
||||
// }
|
||||
|
||||
// if (iColumns != null)
|
||||
// {
|
||||
// command = command.InsertIgnoreColumns(iColumns);
|
||||
// }
|
||||
|
||||
// return command.ExecuteReturnList();
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
//#region 查询操作
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件查询数据是否存在
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
//public bool Any(Expression<Func<T, bool>> where)
|
||||
//{
|
||||
// return true;// base.Context.Any(where);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件合计字段
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
//public TResult Sum<TResult>(Expression<Func<T, bool>> where, Expression<Func<T, TResult>> field)
|
||||
//{
|
||||
// return base.Context.Queryable<T>().Where(where).Sum(field);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 根据主值查询单条数据
|
||||
///// </summary>
|
||||
///// <param name="pkValue">主键值</param>
|
||||
///// <returns>泛型实体</returns>
|
||||
////public T GetId(object pkValue)
|
||||
////{
|
||||
//// return base.Context.Queryable<T>().InSingle(pkValue);
|
||||
////}
|
||||
|
||||
///// <summary>
|
||||
///// 根据主键查询多条数据
|
||||
///// </summary>
|
||||
///// <param name="ids"></param>
|
||||
///// <returns></returns>
|
||||
//public List<T> GetIn(object[] ids)
|
||||
//{
|
||||
// return Context.Queryable<T>().In(ids).ToList();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件取条数
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
//public int GetCount(Expression<Func<T, bool>> where)
|
||||
//{
|
||||
// return Context.Queryable<T>().Count(where);
|
||||
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 查询所有数据(无分页,请慎用)
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
|
||||
//{
|
||||
// return Context.Queryable<T>().WithCacheIF(useCache, cacheSecond).ToList();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获得一条数据
|
||||
///// </summary>
|
||||
///// <param name="where">Expression<Func<T, bool>></param>
|
||||
///// <returns></returns>
|
||||
//public T GetFirst2(Expression<Func<T, bool>> where)
|
||||
//{
|
||||
// return base.GetFirst(where);// Context.Queryable<T>().Where(where).First();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获得一条数据
|
||||
///// </summary>
|
||||
///// <param name="parm">string</param>
|
||||
///// <returns></returns>
|
||||
////public T GetFirst(string parm)
|
||||
////{
|
||||
//// return Context.Queryable<T>().Where(parm).First();
|
||||
////}
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件查询分页数据
|
||||
///// </summary>
|
||||
///// <param name="where"></param>
|
||||
///// <param name="parm"></param>
|
||||
///// <returns></returns>
|
||||
//public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm)
|
||||
//{
|
||||
// var source = Context.Queryable<T>().Where(where);
|
||||
|
||||
// return source.ToPage(parm);
|
||||
//}
|
||||
|
||||
//public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc")
|
||||
//{
|
||||
// var source = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc);
|
||||
|
||||
// return source.ToPage(parm);
|
||||
//}
|
||||
#region delete
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询数据
|
||||
/// 删除表达式
|
||||
/// </summary>
|
||||
/// <param name="where">条件表达式树</param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
// public List<T> GetWhere(Expression<Func<T, bool>> where, bool useCache = false, int cacheSecond = 3600)
|
||||
public int Delete(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return baseRepository.Delete(expression);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public int Delete(object[] obj)
|
||||
{
|
||||
return baseRepository.Delete(obj);
|
||||
}
|
||||
public int Delete(object id)
|
||||
{
|
||||
return baseRepository.Delete(id);
|
||||
}
|
||||
public bool DeleteTable()
|
||||
{
|
||||
return baseRepository.DeleteTable();
|
||||
}
|
||||
|
||||
#endregion delete
|
||||
|
||||
#region query
|
||||
|
||||
public bool Any(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return baseRepository.Any(expression);
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> Queryable()
|
||||
{
|
||||
return baseRepository.Queryable();
|
||||
}
|
||||
|
||||
public List<T> GetList(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return baseRepository.GetList(expression);
|
||||
}
|
||||
|
||||
//public Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression)
|
||||
//{
|
||||
// var query = Context.Queryable<T>().Where(where).WithCacheIF(useCache, cacheSecond);
|
||||
// return query.ToList();
|
||||
// return Context.Queryable<T>().Where(expression).ToListAsync();
|
||||
//}
|
||||
|
||||
// /// <summary>
|
||||
///// 根据条件查询数据
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
// public List<T> GetWhere(Expression<Func<T, bool>> where, Expression<Func<T, object>> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600)
|
||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||
//{
|
||||
// var query = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc).WithCacheIF(useCache, cacheSecond);
|
||||
// return query.ToList();
|
||||
// var query = base.Context.Queryable<T>().Select(select).Where(expressionWhere).ToList();
|
||||
// return query.JilToJson();
|
||||
//}
|
||||
|
||||
// #endregion
|
||||
|
||||
//#region 修改操作
|
||||
|
||||
/////// <summary>
|
||||
/////// 修改一条数据
|
||||
/////// </summary>
|
||||
/////// <param name="parm">T</param>
|
||||
/////// <returns></returns>
|
||||
////public int Update(T parm)
|
||||
////{
|
||||
//// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand();
|
||||
////}
|
||||
|
||||
/////// <summary>
|
||||
/////// 批量修改
|
||||
/////// </summary>
|
||||
/////// <param name="parm">T</param>
|
||||
/////// <returns></returns>
|
||||
////public int Update(List<T> parm)
|
||||
////{
|
||||
//// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand();
|
||||
////}
|
||||
|
||||
/////// <summary>
|
||||
/////// 按查询条件更新
|
||||
/////// </summary>
|
||||
/////// <param name="where"></param>
|
||||
/////// <param name="columns"></param>
|
||||
/////// <returns></returns>
|
||||
////public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
////{
|
||||
//// return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand();
|
||||
////}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 删除操作
|
||||
|
||||
/////// <summary>
|
||||
/////// 删除一条或多条数据
|
||||
/////// </summary>
|
||||
/////// <param name="parm">string</param>
|
||||
/////// <returns></returns>
|
||||
////public int Delete(object id)
|
||||
////{
|
||||
//// return Context.Deleteable<T>(id).RemoveDataCache().ExecuteCommand();
|
||||
////}
|
||||
|
||||
/////// <summary>
|
||||
/////// 删除一条或多条数据
|
||||
/////// </summary>
|
||||
/////// <param name="parm">string</param>
|
||||
/////// <returns></returns>
|
||||
////public int Delete(object[] ids)
|
||||
////{
|
||||
//// return Context.Deleteable<T>().In(ids).RemoveDataCache().ExecuteCommand();
|
||||
////}
|
||||
|
||||
/////// <summary>
|
||||
/////// 根据条件删除一条或多条数据
|
||||
/////// </summary>
|
||||
/////// <param name="where">过滤条件</param>
|
||||
/////// <returns></returns>
|
||||
////public int Delete(Expression<Func<T, bool>> where)
|
||||
////{
|
||||
//// return Context.Deleteable<T>().Where(where).RemoveDataCache().ExecuteCommand();
|
||||
////}
|
||||
|
||||
//public int DeleteTable()
|
||||
//public List<T> QueryableToList(string tableName)
|
||||
//{
|
||||
// return Context.Deleteable<T>().RemoveDataCache().ExecuteCommand();
|
||||
// return Context.Queryable<T>(tableName).ToList();
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
// var list = Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
//}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
//}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
|
||||
// if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public List<T> SqlQueryToList(string sql, object obj = null)
|
||||
//{
|
||||
// return Context.Ado.SqlQuery<T>(sql, obj);
|
||||
//}
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="where">Expression<Func<T, bool>></param>
|
||||
/// <returns></returns>
|
||||
public T GetFirst(Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.GetFirst(where);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主值查询单条数据
|
||||
/// </summary>
|
||||
/// <param name="pkValue">主键值</param>
|
||||
/// <returns>泛型实体</returns>
|
||||
public T GetId(object pkValue)
|
||||
{
|
||||
return baseRepository.GetId(pkValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm)
|
||||
{
|
||||
var source = baseRepository.GetPages(where, parm);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc)
|
||||
{
|
||||
return baseRepository.GetPages(where, parm, order, orderEnum);
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询所有数据(无分页,请慎用)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
|
||||
{
|
||||
return baseRepository.GetAll(useCache, cacheSecond);
|
||||
}
|
||||
|
||||
public int Count(Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.Count(where);
|
||||
}
|
||||
#endregion query
|
||||
|
||||
/// <summary>
|
||||
/// 此方法不带output返回值
|
||||
/// var list = new List<SugarParameter>();
|
||||
/// list.Add(new SugarParameter(ParaName, ParaValue)); input
|
||||
/// </summary>
|
||||
/// <param name="procedureName"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters)
|
||||
{
|
||||
return baseRepository.UseStoredProcedureToDataTable(procedureName, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带output返回值
|
||||
/// var list = new List<SugarParameter>();
|
||||
/// list.Add(new SugarParameter(ParaName, ParaValue, true)); output
|
||||
/// list.Add(new SugarParameter(ParaName, ParaValue)); input
|
||||
/// </summary>
|
||||
/// <param name="procedureName"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public (DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters)
|
||||
{
|
||||
return baseRepository.UseStoredProcedureToTuple(procedureName, parameters);
|
||||
}
|
||||
|
||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Repository;
|
||||
|
||||
@ -15,7 +16,7 @@ namespace ZR.Service.Business
|
||||
public class GendemoService : BaseService<Gendemo>, IGendemoService
|
||||
{
|
||||
private readonly GendemoRepository _Gendemorepository;
|
||||
public GendemoService(GendemoRepository repository)
|
||||
public GendemoService(GendemoRepository repository) : base(repository)
|
||||
{
|
||||
_Gendemorepository = repository;
|
||||
}
|
||||
|
||||
@ -2,8 +2,9 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
using ZR.Repository;
|
||||
using ZR.Model;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
@ -11,200 +12,145 @@ namespace ZR.Service
|
||||
/// 基础服务定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IBaseService<T> : IBaseRepository<T> where T : class, new()
|
||||
public interface IBaseService<T> where T : class, new()
|
||||
{
|
||||
#region 添加操作
|
||||
#region add
|
||||
int Add(T t);
|
||||
|
||||
//int Insert(SqlSugarClient client, T t);
|
||||
|
||||
//long InsertBigIdentity(T t);
|
||||
IInsertable<T> Insertable(T t);
|
||||
int Insert(List<T> t);
|
||||
int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t, params string[] columns);
|
||||
|
||||
//DbResult<bool> InsertTran(T t);
|
||||
|
||||
//DbResult<bool> InsertTran(List<T> t);
|
||||
long InsertReturnBigIdentity(T t);
|
||||
//T InsertReturnEntity(T t);
|
||||
|
||||
//T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock);
|
||||
|
||||
//bool ExecuteCommand(string sql, object parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, params SugarParameter[] parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, List<SugarParameter> parameters);
|
||||
|
||||
#endregion add
|
||||
|
||||
#region update
|
||||
|
||||
bool Update(T entity, bool ignoreNullColumns = false);
|
||||
|
||||
/// <summary>
|
||||
/// 添加一条数据
|
||||
/// 只更新表达式的值
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="entity">T</param>
|
||||
/// <param name="list">忽略更新</param>
|
||||
/// <param name="isNull">Null不更新</param>
|
||||
/// <returns></returns>
|
||||
//bool Update(T entity, List<string> list = null, bool isNull = true);
|
||||
|
||||
//bool Update(List<T> entity);
|
||||
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
|
||||
#endregion update
|
||||
|
||||
DbResult<bool> UseTran(Action action);
|
||||
|
||||
DbResult<bool> UseTran(SqlSugarClient client, Action action);
|
||||
|
||||
bool UseTran2(Action action);
|
||||
|
||||
#region delete
|
||||
|
||||
int Delete(Expression<Func<T, bool>> expression);
|
||||
int Delete(object[] obj);
|
||||
int Delete(object id);
|
||||
bool DeleteTable();
|
||||
|
||||
#endregion delete
|
||||
|
||||
#region query
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
//int Add(T parm);
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm);
|
||||
|
||||
//int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = false);
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
|
||||
|
||||
///// <summary>
|
||||
///// 批量添加数据
|
||||
///// </summary>
|
||||
///// <param name="parm">List<T></param>
|
||||
///// <returns></returns>
|
||||
//int Add(List<T> parm);
|
||||
bool Any(Expression<Func<T, bool>> expression);
|
||||
|
||||
///// <summary>
|
||||
///// 添加或更新数据
|
||||
///// </summary>
|
||||
///// <param name="parm"><T></param>
|
||||
///// <returns></returns>
|
||||
//T Saveable(T parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null);
|
||||
ISugarQueryable<T> Queryable();
|
||||
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
||||
|
||||
///// <summary>
|
||||
///// 批量添加或更新数据
|
||||
///// </summary>
|
||||
///// <param name="parm">List<T></param>
|
||||
///// <returns></returns>
|
||||
//List<T> Saveable(List<T> parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null);
|
||||
//ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
|
||||
|
||||
//ISugarQueryable<T, T1, T2> Queryable<T1, T2>() where T1 : class where T2 : new();
|
||||
|
||||
List<T> GetList(Expression<Func<T, bool>> expression);
|
||||
|
||||
//#endregion
|
||||
//Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression);
|
||||
|
||||
//#region 查询操作
|
||||
//string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere);
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件查询数据是否存在
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
//bool Any(Expression<Func<T, bool>> where);
|
||||
//List<T> QueryableToList(string tableName);
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件合计字段
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
//TResult Sum<TResult>(Expression<Func<T, bool>> where, Expression<Func<T, TResult>> field);
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
///// <summary>
|
||||
///// 根据主值查询单条数据
|
||||
///// </summary>
|
||||
///// <param name="pkValue">主键值</param>
|
||||
///// <returns>泛型实体</returns>
|
||||
//T GetId(object pkValue);
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Bootstrap.BootstrapParams bootstrap);
|
||||
|
||||
///// <summary>
|
||||
///// 根据主键查询多条数据
|
||||
///// </summary>
|
||||
///// <param name="ids"></param>
|
||||
///// <returns></returns>
|
||||
//List<T> GetIn(object[] ids);
|
||||
//List<T> SqlQueryToList(string sql, object obj = null);
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="where">Expression<Func<T, bool>></param>
|
||||
/// <returns></returns>
|
||||
T GetFirst(Expression<Func<T, bool>> where);
|
||||
T GetId(object pkValue);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件取条数
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
//int GetCount(Expression<Func<T, bool>> where);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 查询所有数据(无分页,请慎用)
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 获得一条数据
|
||||
///// </summary>
|
||||
///// <param name="where">Expression<Func<T, bool>></param>
|
||||
///// <returns></returns>
|
||||
//T GetFirst(Expression<Func<T, bool>> where);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 获得一条数据
|
||||
///// </summary>
|
||||
///// <param name="parm">string</param>
|
||||
///// <returns></returns>
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="parm">string</param>
|
||||
/// <returns></returns>
|
||||
//T GetFirst(string parm);
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件查询分页数据
|
||||
///// </summary>
|
||||
///// <param name="where"></param>
|
||||
///// <param name="parm"></param>
|
||||
///// <returns></returns>
|
||||
//PagedInfo<T> GetPages(Expression<Func<T, bool>> where, Model.PagerInfo parm);
|
||||
int Count(Expression<Func<T, bool>> where);
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件查询分页
|
||||
///// </summary>
|
||||
///// <param name="where"></param>
|
||||
///// <param name="parm"></param>
|
||||
///// <param name="order"></param>
|
||||
///// <param name="orderEnum"></param>
|
||||
///// <returns></returns>
|
||||
//PagedInfo<T> GetPages(Expression<Func<T, bool>> where, Model.PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc");
|
||||
#endregion query
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件查询数据
|
||||
///// </summary>
|
||||
///// <param name="where">条件表达式树</param>
|
||||
///// <returns></returns>
|
||||
////List<T> GetWhere(Expression<Func<T, bool>> where, bool useCache = false, int cacheSecond = 3600);
|
||||
#region Procedure
|
||||
|
||||
/////// <summary>
|
||||
/////// 根据条件查询数据
|
||||
/////// </summary>
|
||||
/////// <param name="where">条件表达式树</param>
|
||||
/////// <returns></returns>
|
||||
////List<T> GetWhere(Expression<Func<T, bool>> where, Expression<Func<T, object>> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600);
|
||||
DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters);
|
||||
|
||||
(DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 修改操作
|
||||
|
||||
///// <summary>
|
||||
///// 修改一条数据
|
||||
///// </summary>
|
||||
///// <param name="parm">T</param>
|
||||
///// <returns></returns>
|
||||
//int Update(T parm);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 批量修改
|
||||
///// </summary>
|
||||
///// <param name="parm">T</param>
|
||||
///// <returns></returns>
|
||||
//int Update(List<T> parm);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 按查询条件更新
|
||||
///// </summary>
|
||||
///// <param name="where"></param>
|
||||
///// <param name="columns"></param>
|
||||
///// <returns></returns>
|
||||
//int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 删除操作
|
||||
|
||||
///// <summary>
|
||||
///// 删除一条或多条数据
|
||||
///// </summary>
|
||||
///// <param name="parm">string</param>
|
||||
///// <returns></returns>
|
||||
//int Delete(object id);
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 删除一条或多条数据
|
||||
///// </summary>
|
||||
///// <param name="parm">string</param>
|
||||
///// <returns></returns>
|
||||
//int Delete(object[] ids);
|
||||
|
||||
///// <summary>
|
||||
///// 根据条件删除一条或多条数据
|
||||
///// </summary>
|
||||
///// <param name="where">过滤条件</param>
|
||||
///// <returns></returns>
|
||||
//int Delete(Expression<Func<T, bool>> where);
|
||||
|
||||
///// <summary>
|
||||
///// 清空表
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//int DeleteTable();
|
||||
#endregion
|
||||
|
||||
#endregion Procedure
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,10 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using SqlSugar.IOC;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
@ -12,6 +15,9 @@ namespace ZR.Service.System
|
||||
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleCategoryService : BaseService<ArticleCategory>, IArticleCategoryService
|
||||
{
|
||||
public ArticleCategoryService(ArticleCategoryRepository repository) : base(repository)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建前端所需要树结构
|
||||
/// </summary>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
@ -10,6 +12,8 @@ namespace ZR.Service.System
|
||||
[AppService(ServiceType = typeof(IArticleService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleService : BaseService<Article>, IArticleService
|
||||
{
|
||||
|
||||
public ArticleService(ArticleRepository repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,4 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ZR.Common;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository;
|
||||
|
||||
@ -15,15 +6,12 @@ namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数配置Service业务层处理
|
||||
///
|
||||
/// @author zhaorui
|
||||
/// @date 2021-09-29
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysConfigService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysConfigService : BaseService<SysConfig>, ISysConfigService
|
||||
{
|
||||
private readonly SysConfigRepository _SysConfigrepository;
|
||||
public SysConfigService(SysConfigRepository repository)
|
||||
public SysConfigService(SysConfigRepository repository) : base(repository)
|
||||
{
|
||||
_SysConfigrepository = repository;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
public SysDeptRepository DeptRepository;
|
||||
|
||||
public SysDeptService(SysDeptRepository deptRepository)
|
||||
public SysDeptService(SysDeptRepository deptRepository) : base(deptRepository)
|
||||
{
|
||||
DeptRepository = deptRepository;
|
||||
}
|
||||
|
||||
@ -9,12 +9,15 @@ using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典数据类
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysDictDataService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDictDataService: ISysDictDataService
|
||||
public class SysDictDataService : BaseService<SysDictData>, ISysDictDataService
|
||||
{
|
||||
|
||||
private readonly SysDictDataRepository SysDictDataRepository;
|
||||
public SysDictDataService(SysDictDataRepository sysDictDataRepository)
|
||||
public SysDictDataService(SysDictDataRepository sysDictDataRepository) : base(sysDictDataRepository)
|
||||
{
|
||||
SysDictDataRepository = sysDictDataRepository;
|
||||
}
|
||||
@ -32,7 +35,7 @@ namespace ZR.Service.System
|
||||
/// <summary>
|
||||
/// 根据字典类型查询
|
||||
/// </summary>
|
||||
/// <param name="dictData"></param>
|
||||
/// <param name="dictType"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataByType(string dictType)
|
||||
{
|
||||
|
||||
@ -13,12 +13,12 @@ namespace ZR.Service.System
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDictService : ISysDictService
|
||||
public class SysDictService : BaseService<SysDictType>, ISysDictService
|
||||
{
|
||||
private SysDictRepository DictRepository;
|
||||
private SysDictDataRepository DictDataRepository;
|
||||
|
||||
public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository)
|
||||
public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository) : base(sysDictRepository)
|
||||
{
|
||||
this.DictRepository = sysDictRepository;
|
||||
this.DictDataRepository = dictDataRepository;
|
||||
|
||||
@ -19,7 +19,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
private SysLogininfoRepository SysLogininfoRepository;
|
||||
|
||||
public SysLoginService(SysLogininfoRepository sysLogininfo)
|
||||
public SysLoginService(SysLogininfoRepository sysLogininfo): base(sysLogininfo)
|
||||
{
|
||||
SysLogininfoRepository = sysLogininfo;
|
||||
}
|
||||
|
||||
@ -15,14 +15,14 @@ namespace ZR.Service
|
||||
/// 菜单
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysMenuService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysMenuService: ISysMenuService
|
||||
public class SysMenuService : BaseService<SysMenu>, ISysMenuService
|
||||
{
|
||||
public SysMenuRepository MenuRepository;
|
||||
public ISysRoleService SysRoleService;
|
||||
|
||||
public SysMenuService(
|
||||
SysMenuRepository menuRepository,
|
||||
ISysRoleService sysRoleService)
|
||||
ISysRoleService sysRoleService) : base(menuRepository)
|
||||
{
|
||||
MenuRepository = menuRepository;
|
||||
SysRoleService = sysRoleService;
|
||||
|
||||
@ -13,11 +13,11 @@ namespace ZR.Service.System
|
||||
/// 操作日志
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysOperLogService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysOperLogService : ISysOperLogService
|
||||
public class SysOperLogService : BaseService<SysOperLog>, ISysOperLogService
|
||||
{
|
||||
public SysOperLogRepository sysOperLogRepository;
|
||||
|
||||
public SysOperLogService(SysOperLogRepository sysOperLog)
|
||||
public SysOperLogService(SysOperLogRepository sysOperLog) : base(sysOperLog)
|
||||
{
|
||||
sysOperLogRepository = sysOperLog;
|
||||
}
|
||||
|
||||
@ -8,6 +8,9 @@ using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色权限
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysPermissionService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysPermissionService : ISysPermissionService
|
||||
{
|
||||
|
||||
@ -16,7 +16,7 @@ namespace ZR.Service.System
|
||||
public class SysPostService : BaseService<SysPost>, ISysPostService
|
||||
{
|
||||
public SysPostRepository PostRepository;
|
||||
public SysPostService(SysPostRepository postRepository)
|
||||
public SysPostService(SysPostRepository postRepository): base(postRepository)
|
||||
{
|
||||
PostRepository = postRepository;
|
||||
}
|
||||
|
||||
@ -6,6 +6,9 @@ using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务日志
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient, ServiceType = typeof(ISysTasksLogService))]
|
||||
public class SysTasksLogService : BaseRepository<SysTasksLog>, ISysTasksLogService
|
||||
{
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
using Infrastructure.Attribute;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时任务
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysTasksQzService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysTasksQzService : BaseService<SysTasksQz>, ISysTasksQzService
|
||||
{
|
||||
|
||||
public SysTasksQzService(SysTasksQzRepository repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@ using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户角色
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysUserRoleService),ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysUserRoleService: ISysUserRoleService
|
||||
{
|
||||
|
||||
@ -10,6 +10,9 @@ using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统用户
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysUserService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysUserService : BaseService<SysUser>, ISysUserService
|
||||
{
|
||||
@ -22,7 +25,7 @@ namespace ZR.Service
|
||||
SysUserRepository userRepository,
|
||||
ISysRoleService sysRoleService,
|
||||
ISysUserRoleService userRoleService,
|
||||
ISysUserPostService userPostService)
|
||||
ISysUserPostService userPostService) : base(userRepository)
|
||||
{
|
||||
UserRepository = userRepository;
|
||||
RoleService = sysRoleService;
|
||||
|
||||
@ -56,15 +56,6 @@ Vue.component('DictTag', DictTag)
|
||||
|
||||
Vue.use(permission)
|
||||
|
||||
/**
|
||||
* If you don't want to use mock-server
|
||||
* you want to use MockJs for mock api
|
||||
* you can execute: mockXHR()
|
||||
*
|
||||
* Currently MockJs will be used in the production environment,
|
||||
* please remove it before going online! ! !
|
||||
*/
|
||||
|
||||
Vue.use(Element, {
|
||||
size: Cookies.get('size') || 'medium' // set element-ui default size
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user