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