diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs index 0466f31..6c993d3 100644 --- a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs +++ b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs @@ -49,7 +49,7 @@ namespace ZR.Admin.WebApi.Controllers predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Title), m => m.Title.Contains(parm.Title)); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status); - var response = _ArticleService.GetPages(predicate.ToExpression(), parm, f => f.Cid, "Desc"); + var response = _ArticleService.GetPages(predicate.ToExpression(), parm, f => f.Cid, OrderByType.Desc); return SUCCESS(response); } diff --git a/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs b/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs index 55425f6..6a48e29 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs @@ -107,7 +107,7 @@ namespace ZR.Admin.WebApi.Controllers //从 Dto 映射到 实体 var model = parm.Adapt().ToCreate(); - return SUCCESS(_SysConfigService.Add(model, it => new + return SUCCESS(_SysConfigService.Insert(model, it => new { it.ConfigName, it.ConfigKey, diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs index 4ec1e09..b869435 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs @@ -51,7 +51,7 @@ namespace ZR.Admin.WebApi.Controllers m.JobGroup.Contains(parm.QueryText) || m.AssemblyName.Contains(parm.QueryText)); - var response = _tasksQzService.GetPages(predicate.ToExpression(), pager, f => f.IsStart, "Desc"); + var response = _tasksQzService.GetPages(predicate.ToExpression(), pager, f => f.IsStart, OrderByType.Desc); return SUCCESS(response, TIME_FORMAT_FULL); } diff --git a/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs b/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs index 3ce61dd..8a670e5 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs @@ -42,7 +42,7 @@ namespace ZR.Admin.WebApi.Controllers.System predicate = predicate.AndIF(queryDto.Status.IfNotEmpty(), m => m.Status == queryDto.Status); predicate = predicate.AndIF(queryDto.JobId.IfNotEmpty(), m => m.JobId == queryDto.JobId); - var response = tasksLogService.GetPages(predicate.ToExpression(), pager, m => m.CreateTime, "Desc"); + var response = tasksLogService.GetPages(predicate.ToExpression(), pager, m => m.CreateTime, OrderByType.Desc); return SUCCESS(response, TIME_FORMAT_FULL); } diff --git a/ZR.Admin.WebApi/Controllers/business/GendemoController.cs b/ZR.Admin.WebApi/Controllers/business/GendemoController.cs index 0fdfee2..2201819 100644 --- a/ZR.Admin.WebApi/Controllers/business/GendemoController.cs +++ b/ZR.Admin.WebApi/Controllers/business/GendemoController.cs @@ -87,7 +87,7 @@ namespace ZR.Admin.WebApi.Controllers //从 Dto 映射到 实体 var model = parm.Adapt().ToCreate(HttpContext); - return SUCCESS(_GendemoService.Add(model, it => new + return SUCCESS(_GendemoService.Insert(model, it => new { it.Name, it.Icon, diff --git a/ZR.Admin.WebApi/Properties/launchSettings.json b/ZR.Admin.WebApi/Properties/launchSettings.json index d3473a5..7f6746e 100644 --- a/ZR.Admin.WebApi/Properties/launchSettings.json +++ b/ZR.Admin.WebApi/Properties/launchSettings.json @@ -2,11 +2,11 @@ "profiles": { "ZRAdmin": { "commandName": "Project", - "launchBrowser": true, + "launchBrowser": false, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "" }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "http://localhost:8888" } } } \ No newline at end of file diff --git a/ZR.Admin.WebApi/Startup.cs b/ZR.Admin.WebApi/Startup.cs index aa0e1ce..1d1340f 100644 --- a/ZR.Admin.WebApi/Startup.cs +++ b/ZR.Admin.WebApi/Startup.cs @@ -148,12 +148,12 @@ namespace ZR.Admin.WebApi SugarIocServices.AddSqlSugar(new List() { new IocConfig() { - ConfigId = "0", //ݿ + ConfigId = "0", ConnectionString = connStr, DbType = (IocDbType)dbType, IsAutoCloseConnection = true//Զͷ }, new IocConfig() { - ConfigId = "1", // ⻧õ + ConfigId = "1", ConnectionString = connStrBus, DbType = (IocDbType)dbType_bus, IsAutoCloseConnection = true//Զͷ @@ -161,14 +161,13 @@ namespace ZR.Admin.WebApi }); //ʽ ӡSQL - DbScoped.SugarScope.GetConnection(0).Aop.OnLogExecuting = (sql, pars) => + DbScoped.SugarScope.GetConnection("0").Aop.OnLogExecuting = (sql, pars) => { - Console.BackgroundColor = ConsoleColor.Yellow; Console.WriteLine("SQL䡿" + sql.ToLower() + "\r\n" + DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); }; //ӡ־ - DbScoped.SugarScope.GetConnection(0).Aop.OnError = (e) => + DbScoped.SugarScope.GetConnection("0").Aop.OnError = (e) => { Console.WriteLine($"[ִSql]{e.Message}SQL={e.Sql}"); Console.WriteLine(); @@ -177,7 +176,6 @@ namespace ZR.Admin.WebApi //ʽ ӡSQL DbScoped.SugarScope.GetConnection(1).Aop.OnLogExecuting = (sql, pars) => { - Console.BackgroundColor = ConsoleColor.Yellow; Console.WriteLine("SQLBus" + sql.ToLower() + "\r\n" + DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); }; diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt index 27824d5..fb63b23 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt @@ -87,7 +87,7 @@ namespace {ApiControllerNamespace}.Controllers //从 Dto 映射到 实体 var model = parm.Adapt<{ModelName}>().ToCreate(HttpContext); - return SUCCESS(_{ModelName}Service.Add(model, it => new + return SUCCESS(_{ModelName}Service.Insert(model, it => new { {InsertColumn} })); diff --git a/ZR.Model/Models/Gendemo.cs b/ZR.Model/Models/Gendemo.cs index 0ba1695..ae0ae49 100644 --- a/ZR.Model/Models/Gendemo.cs +++ b/ZR.Model/Models/Gendemo.cs @@ -10,13 +10,14 @@ namespace ZR.Model.Models /// @date 2021-11-24 /// [SqlSugar.SugarTable("gen_demo")] + [SqlSugar.Tenant("0")] public class Gendemo { /// /// 描述 :自增id /// 空值 :False /// - [SqlSugar.SugarColumn(IsPrimaryKey = false, IsIdentity = true)] + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } /// /// 描述 :名称 diff --git a/ZR.Model/System/Article.cs b/ZR.Model/System/Article.cs index cffa116..f82f626 100644 --- a/ZR.Model/System/Article.cs +++ b/ZR.Model/System/Article.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Text; @@ -8,6 +9,7 @@ namespace ZR.Model.System /// 文章表 /// [SqlSugar.SugarTable("article")] + [Tenant("0")] public class Article { [SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)] diff --git a/ZR.Model/System/ArticleCategory.cs b/ZR.Model/System/ArticleCategory.cs index bd395d0..48c9d6d 100644 --- a/ZR.Model/System/ArticleCategory.cs +++ b/ZR.Model/System/ArticleCategory.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using SqlSugar; using System; using System.Collections.Generic; using System.Text; @@ -8,7 +9,8 @@ namespace ZR.Model.System /// /// 文章目录 /// - [SqlSugar.SugarTable("articleCategory")] + [SugarTable("articleCategory")] + [Tenant("0")] public class ArticleCategory { public int Category_Id { get; set; } @@ -16,7 +18,7 @@ namespace ZR.Model.System public int ParentId { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - [SqlSugar.SugarColumn(IsIgnore = true)] + [SugarColumn(IsIgnore = true)] public List Children { get; set; } } } diff --git a/ZR.Model/System/Generate/GenTable.cs b/ZR.Model/System/Generate/GenTable.cs index d2cd238..0d9790b6 100644 --- a/ZR.Model/System/Generate/GenTable.cs +++ b/ZR.Model/System/Generate/GenTable.cs @@ -8,6 +8,7 @@ namespace ZR.Model.System.Generate /// 代码生成表 /// [SqlSugar.SugarTable("gen_table")] + [SqlSugar.Tenant("0")] public class GenTable: SysBase { /// diff --git a/ZR.Model/System/Generate/GenTableColumn.cs b/ZR.Model/System/Generate/GenTableColumn.cs index e517540..964c770 100644 --- a/ZR.Model/System/Generate/GenTableColumn.cs +++ b/ZR.Model/System/Generate/GenTableColumn.cs @@ -9,6 +9,7 @@ namespace ZR.Model.System.Generate /// 代码生成表字段 /// [SqlSugar.SugarTable("gen_table_column")] + [SqlSugar.Tenant("0")] public class GenTableColumn: SysBase { [SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)] diff --git a/ZR.Model/System/SysConfig.cs b/ZR.Model/System/SysConfig.cs index 073feb4..3ecb688 100644 --- a/ZR.Model/System/SysConfig.cs +++ b/ZR.Model/System/SysConfig.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Text; @@ -10,7 +11,8 @@ namespace ZR.Model.System /// @author zhaorui /// @date 2021-09-29 /// - [SqlSugar.SugarTable("sys_config")] + [SugarTable("sys_config")] + [Tenant("0")] public class SysConfig: SysBase { /// diff --git a/ZR.Model/System/SysDept.cs b/ZR.Model/System/SysDept.cs index 95ee177..5f15151 100644 --- a/ZR.Model/System/SysDept.cs +++ b/ZR.Model/System/SysDept.cs @@ -8,7 +8,8 @@ namespace ZR.Model.System /// /// 部门表 /// - [SqlSugar.SugarTable("sys_dept")] + [SugarTable("sys_dept")] + [Tenant("0")] public class SysDept: SysBase { /** 部门ID */ diff --git a/ZR.Model/System/SysDictData.cs b/ZR.Model/System/SysDictData.cs index fe8d30d..bb674fb 100644 --- a/ZR.Model/System/SysDictData.cs +++ b/ZR.Model/System/SysDictData.cs @@ -9,7 +9,7 @@ namespace ZR.Model.System /// /// 字典数据表 /// - //[Table("sys_dict_data")] + [Tenant("0")] [SugarTable("sys_dict_data")] public class SysDictData: SysBase { diff --git a/ZR.Model/System/SysDictType.cs b/ZR.Model/System/SysDictType.cs index f46aad8..92c067a 100644 --- a/ZR.Model/System/SysDictType.cs +++ b/ZR.Model/System/SysDictType.cs @@ -10,7 +10,7 @@ namespace ZR.Model.System /// 字典类型表 /// [SugarTable("sys_dict_type")]//当和数据库名称不一样可以设置别名 - //[Table("sys_dict_type")] + [Tenant("0")] public class SysDictType : SysBase { /// diff --git a/ZR.Model/System/SysFile.cs b/ZR.Model/System/SysFile.cs index 5d17f40..569abb6 100644 --- a/ZR.Model/System/SysFile.cs +++ b/ZR.Model/System/SysFile.cs @@ -1,10 +1,12 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Text; namespace ZR.Model.System { - [SqlSugar.SugarTable("sys_file")] + [Tenant("0")] + [SugarTable("sys_file")] public class SysFile { public int Id { get; set; } diff --git a/ZR.Model/System/SysLogininfor.cs b/ZR.Model/System/SysLogininfor.cs index 4cd080d..1c16801 100644 --- a/ZR.Model/System/SysLogininfor.cs +++ b/ZR.Model/System/SysLogininfor.cs @@ -8,6 +8,7 @@ namespace ZR.Model.System /// sys_logininfor 表 /// [SugarTable("sys_logininfor")] + [Tenant("0")] public class SysLogininfor: SysBase { //[Key] diff --git a/ZR.Model/System/SysMenu.cs b/ZR.Model/System/SysMenu.cs index 36f53f7..ca0c3f9 100644 --- a/ZR.Model/System/SysMenu.cs +++ b/ZR.Model/System/SysMenu.cs @@ -1,12 +1,13 @@ -using System.Collections.Generic; +using SqlSugar; +using System.Collections.Generic; namespace ZR.Model.System { /// /// Sys_menu表 /// - //[Table("sys_menu")] - [SqlSugar.SugarTable("sys_menu")] + [SugarTable("sys_menu")] + [Tenant("0")] public class SysMenu: SysBase { /// diff --git a/ZR.Model/System/SysOperLog.cs b/ZR.Model/System/SysOperLog.cs index 93a8830..8c1147d 100644 --- a/ZR.Model/System/SysOperLog.cs +++ b/ZR.Model/System/SysOperLog.cs @@ -1,25 +1,27 @@ using Newtonsoft.Json; +using SqlSugar; using System; using System.Collections.Generic; using System.Text; namespace ZR.Model.System { - [SqlSugar.SugarTable("sys_oper_log")] + [SugarTable("sys_oper_log")] + [Tenant("0")] public class SysOperLog { - [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public long OperId { get; set; } /** 操作模块 */ //@Excel(name = "操作模块") - public String title { get; set; } + public string title { get; set; } /** 业务类型(0其它 1新增 2修改 3删除) */ //@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") public int businessType { get; set; } /** 业务类型数组 */ - [SqlSugar.SugarColumn(IsIgnore = true)] + [SugarColumn(IsIgnore = true)] public int[] businessTypes { get; set; } /** 请求方法 */ diff --git a/ZR.Model/System/SysPost.cs b/ZR.Model/System/SysPost.cs index 600cc07..a441522 100644 --- a/ZR.Model/System/SysPost.cs +++ b/ZR.Model/System/SysPost.cs @@ -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 { /// diff --git a/ZR.Model/System/SysRole.cs b/ZR.Model/System/SysRole.cs index 5026247..6f26887 100644 --- a/ZR.Model/System/SysRole.cs +++ b/ZR.Model/System/SysRole.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using SqlSugar; using System; using System.Collections.Generic; using System.Text; @@ -8,13 +9,14 @@ namespace ZR.Model.System /// /// 角色表 sys_role /// - [SqlSugar.SugarTable("sys_role")] + [SugarTable("sys_role")] + [Tenant("0")] public class SysRole : SysBase { /// /// 角色ID /// - [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public long RoleId { get; set; } /// @@ -40,18 +42,18 @@ namespace ZR.Model.System /// /// 删除标志(0代表存在 2代表删除) /// - [SqlSugar.SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)] + [SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)] public string DelFlag { get; set; } /// /// 菜单组 /// - [SqlSugar.SugarColumn(IsIgnore = true)] + [SugarColumn(IsIgnore = true)] public long[] MenuIds { get; set; } /// /// 部门组(数据权限) /// - [SqlSugar.SugarColumn(IsIgnore = true)] + [SugarColumn(IsIgnore = true)] public long[] DeptIds { get; set; } public SysRole() { } diff --git a/ZR.Model/System/SysRoleMenu.cs b/ZR.Model/System/SysRoleMenu.cs index 601c2ee..f1d7bef 100644 --- a/ZR.Model/System/SysRoleMenu.cs +++ b/ZR.Model/System/SysRoleMenu.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using SqlSugar; using System; using System.Collections.Generic; using System.Text; @@ -8,14 +9,15 @@ namespace ZR.Model.System /// /// 角色菜单 /// - [SqlSugar.SugarTable("sys_role_menu")] + [SugarTable("sys_role_menu")] + [Tenant("0")] public class SysRoleMenu { [JsonProperty("roleId")] - [SqlSugar.SugarColumn(IsPrimaryKey = true)] + [SugarColumn(IsPrimaryKey = true)] public long Role_id { get; set; } [JsonProperty("menuId")] - [SqlSugar.SugarColumn(IsPrimaryKey = true)] + [SugarColumn(IsPrimaryKey = true)] public long Menu_id { get; set; } public DateTime Create_time { get; set; } public string Create_by { get; set; } diff --git a/ZR.Model/System/SysRolePost.cs b/ZR.Model/System/SysRolePost.cs index 705b139..a9bf406 100644 --- a/ZR.Model/System/SysRolePost.cs +++ b/ZR.Model/System/SysRolePost.cs @@ -9,6 +9,7 @@ namespace ZR.Model.System /// 角色部门 /// [SugarTable("sys_role_post")] + [Tenant("0")] public class SysRolePost { public long RoleId { get; set; } diff --git a/ZR.Model/System/SysTasksLog.cs b/ZR.Model/System/SysTasksLog.cs index e339226..17e22d0 100644 --- a/ZR.Model/System/SysTasksLog.cs +++ b/ZR.Model/System/SysTasksLog.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Text; @@ -7,7 +8,8 @@ namespace ZR.Model.System /// /// 任务日志 /// - [SqlSugar.SugarTable("sys_Tasks_log")] + [SugarTable("sys_Tasks_log")] + [Tenant("0")] public class SysTasksLog { /// diff --git a/ZR.Model/System/SysTasksQz.cs b/ZR.Model/System/SysTasksQz.cs index ac02bf8..26988b6 100644 --- a/ZR.Model/System/SysTasksQz.cs +++ b/ZR.Model/System/SysTasksQz.cs @@ -11,6 +11,7 @@ namespace ZR.Model.System ///计划任务 /// [SugarTable("Sys_TasksQz")] + [Tenant("0")] public class SysTasksQz { public SysTasksQz() diff --git a/ZR.Model/System/SysUser.cs b/ZR.Model/System/SysUser.cs index f4390bf..c01ed61 100644 --- a/ZR.Model/System/SysUser.cs +++ b/ZR.Model/System/SysUser.cs @@ -10,6 +10,7 @@ namespace ZR.Model.System /// 用户表 /// [SugarTable("sys_user")] + [Tenant("0")] public class SysUser : SysBase { /// diff --git a/ZR.Model/System/SysUserPost.cs b/ZR.Model/System/SysUserPost.cs index 7804cca..67847dd 100644 --- a/ZR.Model/System/SysUserPost.cs +++ b/ZR.Model/System/SysUserPost.cs @@ -10,6 +10,7 @@ namespace ZR.Model.System /// 用户岗位 /// [SugarTable("sys_user_post")] + [Tenant("0")] public class SysUserPost { public long UserId { get; set; } diff --git a/ZR.Model/System/SysUserRole.cs b/ZR.Model/System/SysUserRole.cs index 1495195..78f6334 100644 --- a/ZR.Model/System/SysUserRole.cs +++ b/ZR.Model/System/SysUserRole.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Text; @@ -8,6 +9,7 @@ namespace ZR.Model.System /// 用户角色关联表 用户N-1 角色 /// [SqlSugar.SugarTable("sys_user_role")] + [Tenant("0")] public class SysUserRole { [SqlSugar.SugarColumn(ColumnName = "user_id", IsPrimaryKey = true)] diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj index 9d0f89b..e075f98 100644 --- a/ZR.Model/ZR.Model.csproj +++ b/ZR.Model/ZR.Model.csproj @@ -17,7 +17,6 @@ - diff --git a/ZR.Repository/BaseRepository.cs b/ZR.Repository/BaseRepository.cs index 3324044..3852a9a 100644 --- a/ZR.Repository/BaseRepository.cs +++ b/ZR.Repository/BaseRepository.cs @@ -4,7 +4,9 @@ using SqlSugar.IOC; using System; using System.Collections.Generic; using System.Data; +using System.Linq; using System.Linq.Expressions; +using System.Reflection; using ZR.Model; namespace ZR.Repository @@ -16,54 +18,37 @@ namespace ZR.Repository public class BaseRepository : IBaseRepository where T : class, new() { public ISqlSugarClient Context; - public BaseRepository(string configId = "0") + + public BaseRepository(ISqlSugarClient client = null) { - Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择 + var configId = typeof(T).GetCustomAttribute()?.configId; + if(configId != null) + { + Context = DbScoped.SugarScope.GetConnection(configId); + } + else + { + Context = client ?? DbScoped.SugarScope.GetConnection(1);//根据类传入的ConfigId自动选择 + } } #region add - /// - /// 插入指定列使用 - /// - /// - /// - /// - /// - public int Add(T parm, Expression> iClumns = null, bool ignoreNull = true) - { - return Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand(); - } + /// /// 插入实体 /// /// - /// 默认忽略null列 /// public int Add(T t) { - return Context.Insertable(t).ExecuteCommand(); + return Context.Insertable(t).IgnoreColumns(true).ExecuteCommand(); } - //public int InsertIgnoreNullColumn(T t) - //{ - // return Context.Insertable(t).IgnoreColumns(true).ExecuteCommand(); - //} - - //public int InsertIgnoreNullColumn(T t, params string[] columns) - //{ - // return Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand(); - //} - //public int Insert(SqlSugarClient client, T t) //{ // return client.Insertable(t).ExecuteCommand(); //} - //public long InsertBigIdentity(T t) - //{ - // return base.Context.Insertable(t).ExecuteReturnBigIdentity(); - //} - public int Insert(List t) { return Context.Insertable(t).ExecuteCommand(); @@ -82,10 +67,10 @@ namespace ZR.Repository //{ // return base.Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand(); //} - //public int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true) - //{ - // return base.Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand(); - //} + public int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true) + { + return Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand(); + } //public DbResult InsertTran(T t) //{ // var result = base.Context.Ado.UseTran(() => @@ -128,35 +113,33 @@ namespace ZR.Repository //{ // return base.Context.Ado.ExecuteCommand(sql, parameters) > 0; //} - + public IInsertable Insertable(T t) + { + return Context.Insertable(t); + } #endregion add #region update - //public bool UpdateEntity(T entity, bool ignoreNullColumns = false) - //{ - // return base.Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0; - //} + public bool Update(T entity, bool ignoreNullColumns = false) + { + return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0; + } - //public bool Update(T entity, Expression> expression) - //{ - // return base.Context.Updateable(entity).Where(expression).ExecuteCommand() > 0; - //} + public bool Update(T entity, Expression> expression, bool ignoreAllNull = false) + { + return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand() > 0; + } - //public bool Update(T entity, Expression> expression, bool ignoreAllNull = false) - //{ - // return base.Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand() > 0; - //} + public bool Update(T entity, Expression> expression, Expression> where) + { + return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0; + } - //public bool Update(T entity, Expression> expression, Expression> where) - //{ - // return base.Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0; - //} - - //public bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where) - //{ - // return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0; - //} + public bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where) + { + return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0; + } /// /// @@ -175,7 +158,6 @@ namespace ZR.Repository "Create_time" }; } - //base.Context.Updateable(entity).IgnoreColumns(c => list.Contains(c)).Where(isNull).ExecuteCommand() return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand() > 0; } @@ -281,40 +263,40 @@ namespace ZR.Repository // return Context.Queryable(tableName).ToList(); //} - //public (List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10) - //{ - // int totalNumber = 0; - // var list = Context.Queryable().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber); - // return (list, totalNumber); - //} + public (List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10) + { + int totalNumber = 0; + var list = Context.Queryable().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber); + return (list, totalNumber); + } - //public (List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10) - //{ - // int totalNumber = 0; - // var list = Context.Queryable().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber); - // return (list, totalNumber); - //} + public (List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10) + { + int totalNumber = 0; + var list = Context.Queryable().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber); + return (list, totalNumber); + } - //public (List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10) - //{ - // int totalNumber = 0; + public (List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10) + { + int totalNumber = 0; - // if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase)) - // { - // var list = Context.Queryable().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber); - // return (list, totalNumber); - // } - // else - // { - // var list = Context.Queryable().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber); - // return (list, totalNumber); - // } - //} + if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase)) + { + var list = Context.Queryable().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber); + return (list, totalNumber); + } + else + { + var list = Context.Queryable().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber); + return (list, totalNumber); + } + } - //public List SqlQueryToList(string sql, object obj = null) - //{ - // return Context.Ado.SqlQuery(sql, obj); - //} + public List SqlQueryToList(string sql, object obj = null) + { + return Context.Ado.SqlQuery(sql, obj); + } /// /// 获得一条数据 /// @@ -347,9 +329,9 @@ namespace ZR.Repository return source.ToPage(parm); } - public PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, string orderEnum = "Asc") + public PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, OrderByType orderEnum = OrderByType.Asc) { - var source = Context.Queryable().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc); + var source = Context.Queryable().Where(where).OrderByIF(orderEnum == OrderByType.Asc, order, OrderByType.Asc).OrderByIF(orderEnum == OrderByType.Desc, order, OrderByType.Desc); return source.ToPage(parm); } @@ -395,11 +377,6 @@ namespace ZR.Repository var result = (Context.Ado.UseStoredProcedure().GetDataTable(procedureName, parameters), parameters); return result; } - - //public string QueryableToJson(string select, Expression> expressionWhere) - //{ - // throw new NotImplementedException(); - //} } public static class QueryableExtension diff --git a/ZR.Repository/IBaseRepository.cs b/ZR.Repository/IBaseRepository.cs index 0bfe14f..90ca56e 100644 --- a/ZR.Repository/IBaseRepository.cs +++ b/ZR.Repository/IBaseRepository.cs @@ -15,19 +15,12 @@ namespace ZR.Repository public interface IBaseRepository where T : class, new() { #region add - int Add(T parm, Expression> iClumns = null, bool ignoreNull = true); int Add(T t); - //int InsertIgnoreNullColumn(T t); - - //int InsertIgnoreNullColumn(T t, params string[] columns); - //int Insert(SqlSugarClient client, T t); - //long InsertBigIdentity(T t); - int Insert(List t); - //int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true); + int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true); //int InsertIgnoreNullColumn(List t); @@ -46,14 +39,12 @@ namespace ZR.Repository //bool ExecuteCommand(string sql, params SugarParameter[] parameters); //bool ExecuteCommand(string sql, List parameters); - + IInsertable Insertable(T t); #endregion add #region update - //bool UpdateEntity(T entity, bool ignoreNullColumns = false); - - //bool Update(T entity, Expression> expression); + bool Update(T entity, bool ignoreNullColumns = false); /// /// 只更新表达式的值 @@ -61,22 +52,12 @@ namespace ZR.Repository /// /// /// - //bool Update(T entity, Expression> expression, bool ignoreAllNull = false); + bool Update(T entity, Expression> expression, bool ignoreAllNull = false); - //bool Update(T entity, Expression> expression, Expression> where); + bool Update(T entity, Expression> expression, Expression> where); - //bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where); + bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where); - /// - /// - /// - /// T - /// 忽略更新 - /// Null不更新 - /// - bool Update(T entity, List list = null, bool isNull = true); - - //bool Update(List entity); bool Update(Expression> where, Expression> columns); #endregion update @@ -105,7 +86,7 @@ namespace ZR.Repository /// PagedInfo GetPages(Expression> where, PagerInfo parm); - PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, string orderEnum = "Asc"); + PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, OrderByType orderEnum = OrderByType.Asc); bool Any(Expression> expression); @@ -124,15 +105,13 @@ namespace ZR.Repository //List QueryableToList(string tableName); - //(List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10); + (List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10); - //(List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10); + (List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10); - //(List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10); + (List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10); - //(List, int) QueryableToPage(Expression> expression, Bootstrap.BootstrapParams bootstrap); - - //List SqlQueryToList(string sql, object obj = null); + List SqlQueryToList(string sql, object obj = null); /// /// 获得一条数据 /// diff --git a/ZR.Repository/Repositories/GendemoRepository.cs b/ZR.Repository/Repositories/GendemoRepository.cs index e830a4c..ac6a610 100644 --- a/ZR.Repository/Repositories/GendemoRepository.cs +++ b/ZR.Repository/Repositories/GendemoRepository.cs @@ -2,6 +2,7 @@ using System; using Infrastructure.Attribute; using ZR.Repository.System; using ZR.Model.Models; +using SqlSugar; namespace ZR.Repository { @@ -14,6 +15,10 @@ namespace ZR.Repository [AppService(ServiceLifetime = LifeTime.Transient)] public class GendemoRepository : BaseRepository { + public GendemoRepository() + { + } + #region 业务逻辑代码 #endregion } diff --git a/ZR.Repository/System/ArticleRepository.cs b/ZR.Repository/System/ArticleRepository.cs index 57001a7..718735e 100644 --- a/ZR.Repository/System/ArticleRepository.cs +++ b/ZR.Repository/System/ArticleRepository.cs @@ -13,8 +13,17 @@ namespace ZR.Repository.System /// 文章管理 /// [AppService(ServiceLifetime = LifeTime.Transient)] - public class ArticleRepository + public class ArticleRepository : BaseRepository
{ } + + /// + /// 文章目录 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class ArticleCategoryRepository : BaseRepository + { + + } } diff --git a/ZR.Repository/System/GenTableRepository.cs b/ZR.Repository/System/GenTableRepository.cs index 0ce1970..e5839fe 100644 --- a/ZR.Repository/System/GenTableRepository.cs +++ b/ZR.Repository/System/GenTableRepository.cs @@ -1,4 +1,5 @@ using Infrastructure.Attribute; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; diff --git a/ZR.Repository/System/SysRoleRepository.cs b/ZR.Repository/System/SysRoleRepository.cs index 0b90901..7afb00c 100644 --- a/ZR.Repository/System/SysRoleRepository.cs +++ b/ZR.Repository/System/SysRoleRepository.cs @@ -33,13 +33,13 @@ namespace ZR.Repository.System /// public PagedInfo SelectRoleList(SysRole sysRole, PagerInfo pager) { - return Context.Queryable() - .Where(role => role.DelFlag == "0") - .WhereIF(!string.IsNullOrEmpty(sysRole.RoleName), role => role.RoleName.Contains(sysRole.RoleName)) - .WhereIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status) - .WhereIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey) - .OrderBy(role => role.RoleSort) - .ToPage(pager); + var exp = Expressionable.Create(); + exp.And(role => role.DelFlag == "0"); + exp.AndIF(!string.IsNullOrEmpty(sysRole.RoleName), role => role.RoleName.Contains(sysRole.RoleName)); + exp.AndIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status); + exp.AndIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey); + + return GetPages(exp.ToExpression(), pager, x => x.RoleSort); } /// diff --git a/ZR.Repository/System/SysTasksQzRepository.cs b/ZR.Repository/System/SysTasksQzRepository.cs new file mode 100644 index 0000000..a231073 --- /dev/null +++ b/ZR.Repository/System/SysTasksQzRepository.cs @@ -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 + { + } +} diff --git a/ZR.Service/BaseService.cs b/ZR.Service/BaseService.cs index 9f79143..e4ec4dd 100644 --- a/ZR.Service/BaseService.cs +++ b/ZR.Service/BaseService.cs @@ -1,4 +1,12 @@ -using ZR.Repository; +using Infrastructure.Model; +using SqlSugar; +using SqlSugar.IOC; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq.Expressions; +using ZR.Model; +using ZR.Repository; namespace ZR.Service { @@ -6,284 +14,367 @@ namespace ZR.Service /// 基础服务定义 /// /// - public class BaseService : BaseRepository, IBaseService where T : class, new() + public class BaseService : IBaseService where T : class, new() { - //#region 添加操作 - ///// - ///// 添加一条数据 - ///// - ///// T - ///// - //public int Add(T parm) + public IBaseRepository baseRepository; + + public BaseService(IBaseRepository repository) + { + this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + #region add + /// + /// 插入指定列使用 + /// + /// + /// + /// + /// + public int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true) + { + return baseRepository.Insert(parm, iClumns, ignoreNull); + } + /// + /// 插入实体 + /// + /// + /// + public int Add(T t) + { + return baseRepository.Add(t); + } + public IInsertable 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(); //} - ///// - ///// 添加 - ///// - ///// - ///// 插入列 - ///// 忽略null列 - ///// - //public int Add(T parm, Expression> iClumns = null, bool ignoreNull = true) + //public long InsertBigIdentity(T t) //{ - // return Add(parm); + // return base.Context.Insertable(t).ExecuteReturnBigIdentity(); //} - ///// - ///// 批量添加数据 - ///// - ///// List - ///// - //public int Add(List parm) + public int Insert(List t) + { + return baseRepository.Insert(t); + } + public long InsertReturnBigIdentity(T t) + { + return baseRepository.InsertReturnBigIdentity(t); + } + + //public int InsertIgnoreNullColumn(List t) //{ - // return 1;// Context.Insertable(parm).RemoveDataCache().ExecuteCommand(); + // return base.Context.Insertable(t).IgnoreColumns(true).ExecuteCommand(); //} - ///// - ///// 添加或更新数据,不推荐使用了 - ///// - ///// List - ///// - //public T Saveable(T parm, Expression> uClumns = null, Expression> iColumns = null) + //public int InsertIgnoreNullColumn(List t, params string[] columns) //{ - // var command = Context.Saveable(parm); - - // if (uClumns != null) + // return base.Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand(); + //} + //public DbResult 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 InsertTran(List t) + //{ + // var result = base.Context.Ado.UseTran(() => // { - // command = command.InsertIgnoreColumns(iColumns); - // } - - // return command.ExecuteReturnEntity(); + // base.Context.Insertable(t).ExecuteCommand(); + // }); + // return result; //} - ///// - ///// 批量添加或更新数据 - ///// - ///// List - ///// - //public List Saveable(List parm, Expression> uClumns = null, Expression> iColumns = null) + //public T InsertReturnEntity(T t) //{ - // 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 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> expression, bool ignoreAllNull = false) + { + return baseRepository.Update(entity, expression, ignoreAllNull); + } + + public bool Update(T entity, Expression> expression, Expression> where) + { + return baseRepository.Update(entity, expression, where); + } + + public bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where) + { + return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0; + } + + ///// + ///// + ///// + ///// + ///// + ///// 默认为true + ///// + //public bool Update(T entity, List list = null, bool isNull = true) + //{ + // if (list == null) // { - // command = command.UpdateIgnoreColumns(uClumns); - // } - - // if (iColumns != null) + // list = new List() // { - // command = command.InsertIgnoreColumns(iColumns); + // "Create_By", + // "Create_time" + // }; // } - - // return command.ExecuteReturnList(); + // //base.Context.Updateable(entity).IgnoreColumns(c => list.Contains(c)).Where(isNull).ExecuteCommand() + // return baseRepository.Update(entity, list, isNull); //} - //#endregion - //#region 查询操作 - - ///// - ///// 根据条件查询数据是否存在 - ///// - ///// 条件表达式树 - ///// - //public bool Any(Expression> where) + //public bool Update(List entity) //{ - // return true;// base.Context.Any(where); + // var result = base.Context.Ado.UseTran(() => + // { + // base.Context.Updateable(entity).ExecuteCommand(); + // }); + // return result.IsSuccess; //} + public bool Update(Expression> where, Expression> columns) + { + return baseRepository.Update(where, columns); + } + #endregion update - ///// - ///// 根据条件合计字段 - ///// - ///// 条件表达式树 - ///// - //public TResult Sum(Expression> where, Expression> field) - //{ - // return base.Context.Queryable().Where(where).Sum(field); - //} + public DbResult UseTran(Action action) + { + var result = baseRepository.UseTran(action) ; + return result; + } - ///// - ///// 根据主值查询单条数据 - ///// - ///// 主键值 - ///// 泛型实体 - ////public T GetId(object pkValue) - ////{ - //// return base.Context.Queryable().InSingle(pkValue); - ////} + public DbResult UseTran(SqlSugarClient client, Action action) + { + var result = client.Ado.UseTran(() => action()); + return result; + } - ///// - ///// 根据主键查询多条数据 - ///// - ///// - ///// - //public List GetIn(object[] ids) - //{ - // return Context.Queryable().In(ids).ToList(); - //} + public bool UseTran2(Action action) + { + var result = baseRepository.UseTran2(action); + return result; + } - ///// - ///// 根据条件取条数 - ///// - ///// 条件表达式树 - ///// - //public int GetCount(Expression> where) - //{ - // return Context.Queryable().Count(where); - - //} - - ///// - ///// 查询所有数据(无分页,请慎用) - ///// - ///// - //public List GetAll(bool useCache = false, int cacheSecond = 3600) - //{ - // return Context.Queryable().WithCacheIF(useCache, cacheSecond).ToList(); - //} - - ///// - ///// 获得一条数据 - ///// - ///// Expression> - ///// - //public T GetFirst2(Expression> where) - //{ - // return base.GetFirst(where);// Context.Queryable().Where(where).First(); - //} - - ///// - ///// 获得一条数据 - ///// - ///// string - ///// - ////public T GetFirst(string parm) - ////{ - //// return Context.Queryable().Where(parm).First(); - ////} - - ///// - ///// 根据条件查询分页数据 - ///// - ///// - ///// - ///// - //public PagedInfo GetPages(Expression> where, PagerInfo parm) - //{ - // var source = Context.Queryable().Where(where); - - // return source.ToPage(parm); - //} - - //public PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, string orderEnum = "Asc") - //{ - // var source = Context.Queryable().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc); - - // return source.ToPage(parm); - //} + #region delete /// - /// 根据条件查询数据 + /// 删除表达式 /// - /// 条件表达式树 + /// /// - // public List GetWhere(Expression> where, bool useCache = false, int cacheSecond = 3600) - // { - // var query = Context.Queryable().Where(where).WithCacheIF(useCache, cacheSecond); - // return query.ToList(); - // } + public int Delete(Expression> expression) + { + return baseRepository.Delete(expression); + } - // /// - ///// 根据条件查询数据 - ///// - ///// 条件表达式树 - ///// - // public List GetWhere(Expression> where, Expression> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600) - // { - // var query = Context.Queryable().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc).WithCacheIF(useCache, cacheSecond); - // return query.ToList(); - // } + /// + /// 批量删除 + /// + /// + /// + public int Delete(object[] obj) + { + return baseRepository.Delete(obj); + } + public int Delete(object id) + { + return baseRepository.Delete(id); + } + public bool DeleteTable() + { + return baseRepository.DeleteTable(); + } - // #endregion + #endregion delete - //#region 修改操作 + #region query - /////// - /////// 修改一条数据 - /////// - /////// T - /////// - ////public int Update(T parm) - ////{ - //// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand(); - ////} + public bool Any(Expression> expression) + { + return baseRepository.Any(expression); + } - /////// - /////// 批量修改 - /////// - /////// T - /////// - ////public int Update(List parm) - ////{ - //// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand(); - ////} + public ISugarQueryable Queryable() + { + return baseRepository.Queryable(); + } - /////// - /////// 按查询条件更新 - /////// - /////// - /////// - /////// - ////public int Update(Expression> where, Expression> columns) - ////{ - //// return Context.Updateable().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand(); - ////} + public List GetList(Expression> expression) + { + return baseRepository.GetList(expression); + } - //#endregion - - //#region 删除操作 - - /////// - /////// 删除一条或多条数据 - /////// - /////// string - /////// - ////public int Delete(object id) - ////{ - //// return Context.Deleteable(id).RemoveDataCache().ExecuteCommand(); - ////} - - /////// - /////// 删除一条或多条数据 - /////// - /////// string - /////// - ////public int Delete(object[] ids) - ////{ - //// return Context.Deleteable().In(ids).RemoveDataCache().ExecuteCommand(); - ////} - - /////// - /////// 根据条件删除一条或多条数据 - /////// - /////// 过滤条件 - /////// - ////public int Delete(Expression> where) - ////{ - //// return Context.Deleteable().Where(where).RemoveDataCache().ExecuteCommand(); - ////} - - //public int DeleteTable() + //public Task> QueryableToListAsync(Expression> expression) //{ - // return Context.Deleteable().RemoveDataCache().ExecuteCommand(); + // return Context.Queryable().Where(expression).ToListAsync(); //} - //#endregion + //public string QueryableToJson(string select, Expression> expressionWhere) + //{ + // var query = base.Context.Queryable().Select(select).Where(expressionWhere).ToList(); + // return query.JilToJson(); + //} + + //public List QueryableToList(string tableName) + //{ + // return Context.Queryable(tableName).ToList(); + //} + + //public (List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10) + //{ + // int totalNumber = 0; + // var list = Context.Queryable().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber); + // return (list, totalNumber); + //} + + //public (List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10) + //{ + // int totalNumber = 0; + // var list = Context.Queryable().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber); + // return (list, totalNumber); + //} + + //public (List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10) + //{ + // int totalNumber = 0; + + // if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase)) + // { + // var list = Context.Queryable().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber); + // return (list, totalNumber); + // } + // else + // { + // var list = Context.Queryable().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber); + // return (list, totalNumber); + // } + //} + + //public List SqlQueryToList(string sql, object obj = null) + //{ + // return Context.Ado.SqlQuery(sql, obj); + //} + /// + /// 获得一条数据 + /// + /// Expression> + /// + public T GetFirst(Expression> where) + { + return baseRepository.GetFirst(where); + } + + /// + /// 根据主值查询单条数据 + /// + /// 主键值 + /// 泛型实体 + public T GetId(object pkValue) + { + return baseRepository.GetId(pkValue); + } + /// + /// 根据条件查询分页数据 + /// + /// + /// + /// + public PagedInfo GetPages(Expression> where, PagerInfo parm) + { + var source = baseRepository.GetPages(where, parm); + + return source; + } + + public PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, OrderByType orderEnum = OrderByType.Asc) + { + return baseRepository.GetPages(where, parm, order, orderEnum); + } + /// + /// 查询所有数据(无分页,请慎用) + /// + /// + public List GetAll(bool useCache = false, int cacheSecond = 3600) + { + return baseRepository.GetAll(useCache, cacheSecond); + } + + public int Count(Expression> where) + { + return baseRepository.Count(where); + } + #endregion query + + /// + /// 此方法不带output返回值 + /// var list = new List(); + /// list.Add(new SugarParameter(ParaName, ParaValue)); input + /// + /// + /// + /// + public DataTable UseStoredProcedureToDataTable(string procedureName, List parameters) + { + return baseRepository.UseStoredProcedureToDataTable(procedureName, parameters); + } + + /// + /// 带output返回值 + /// var list = new List(); + /// list.Add(new SugarParameter(ParaName, ParaValue, true)); output + /// list.Add(new SugarParameter(ParaName, ParaValue)); input + /// + /// + /// + /// + public (DataTable, List) UseStoredProcedureToTuple(string procedureName, List parameters) + { + return baseRepository.UseStoredProcedureToTuple(procedureName, parameters); + } + + //public string QueryableToJson(string select, Expression> expressionWhere) + //{ + // throw new NotImplementedException(); + //} } } diff --git a/ZR.Service/Business/GendemoService.cs b/ZR.Service/Business/GendemoService.cs index 8328c68..d5a1af0 100644 --- a/ZR.Service/Business/GendemoService.cs +++ b/ZR.Service/Business/GendemoService.cs @@ -1,5 +1,6 @@ using Infrastructure; using Infrastructure.Attribute; +using SqlSugar; using ZR.Model.Models; using ZR.Repository; @@ -12,10 +13,10 @@ namespace ZR.Service.Business /// @date 2021-11-24 ///
[AppService(ServiceType = typeof(IGendemoService), ServiceLifetime = LifeTime.Transient)] - public class GendemoService: BaseService, IGendemoService + public class GendemoService : BaseService, IGendemoService { private readonly GendemoRepository _Gendemorepository; - public GendemoService(GendemoRepository repository) + public GendemoService(GendemoRepository repository) : base(repository) { _Gendemorepository = repository; } diff --git a/ZR.Service/IBaseService.cs b/ZR.Service/IBaseService.cs index 3e0b4ba..2a009e0 100644 --- a/ZR.Service/IBaseService.cs +++ b/ZR.Service/IBaseService.cs @@ -2,8 +2,9 @@ using SqlSugar; using System; using System.Collections.Generic; +using System.Data; using System.Linq.Expressions; -using ZR.Repository; +using ZR.Model; namespace ZR.Service { @@ -11,200 +12,145 @@ namespace ZR.Service /// 基础服务定义 /// /// - public interface IBaseService : IBaseRepository where T : class, new() + public interface IBaseService where T : class, new() { - #region 添加操作 + #region add + int Add(T t); + + //int Insert(SqlSugarClient client, T t); + + //long InsertBigIdentity(T t); + IInsertable Insertable(T t); + int Insert(List t); + int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true); + + //int InsertIgnoreNullColumn(List t); + + //int InsertIgnoreNullColumn(List t, params string[] columns); + + //DbResult InsertTran(T t); + + //DbResult InsertTran(List 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 parameters); + + #endregion add + + #region update + + bool Update(T entity, bool ignoreNullColumns = false); + /// - /// 添加一条数据 + /// 只更新表达式的值 /// + /// + /// + /// + bool Update(T entity, Expression> expression, bool ignoreAllNull = false); + + bool Update(T entity, Expression> expression, Expression> where); + + bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where); + + /// + /// + /// + /// T + /// 忽略更新 + /// Null不更新 + /// + //bool Update(T entity, List list = null, bool isNull = true); + + //bool Update(List entity); + bool Update(Expression> where, Expression> columns); + + #endregion update + + DbResult UseTran(Action action); + + DbResult UseTran(SqlSugarClient client, Action action); + + bool UseTran2(Action action); + + #region delete + + int Delete(Expression> expression); + int Delete(object[] obj); + int Delete(object id); + bool DeleteTable(); + + #endregion delete + + #region query + /// + /// 根据条件查询分页数据 + /// + /// /// /// - //int Add(T parm); + PagedInfo GetPages(Expression> where, PagerInfo parm); - //int Add(T parm, Expression> iClumns = null, bool ignoreNull = false); + PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, OrderByType orderEnum = OrderByType.Asc); - ///// - ///// 批量添加数据 - ///// - ///// List - ///// - //int Add(List parm); + bool Any(Expression> expression); - ///// - ///// 添加或更新数据 - ///// - ///// - ///// - //T Saveable(T parm, Expression> uClumns = null, Expression> iColumns = null); + ISugarQueryable Queryable(); + List GetAll(bool useCache = false, int cacheSecond = 3600); - ///// - ///// 批量添加或更新数据 - ///// - ///// List - ///// - //List Saveable(List parm, Expression> uClumns = null, Expression> iColumns = null); + //ISugarQueryable Queryable(string tableName, string shortName); + //ISugarQueryable Queryable() where T1 : class where T2 : new(); + List GetList(Expression> expression); - //#endregion + //Task> QueryableToListAsync(Expression> expression); - //#region 查询操作 + //string QueryableToJson(string select, Expression> expressionWhere); - ///// - ///// 根据条件查询数据是否存在 - ///// - ///// 条件表达式树 - ///// - //bool Any(Expression> where); + //List QueryableToList(string tableName); - ///// - ///// 根据条件合计字段 - ///// - ///// 条件表达式树 - ///// - //TResult Sum(Expression> where, Expression> field); + //(List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10); + //(List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10); - ///// - ///// 根据主值查询单条数据 - ///// - ///// 主键值 - ///// 泛型实体 - //T GetId(object pkValue); + //(List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10); + //(List, int) QueryableToPage(Expression> expression, Bootstrap.BootstrapParams bootstrap); - ///// - ///// 根据主键查询多条数据 - ///// - ///// - ///// - //List GetIn(object[] ids); + //List SqlQueryToList(string sql, object obj = null); + /// + /// 获得一条数据 + /// + /// Expression> + /// + T GetFirst(Expression> where); + T GetId(object pkValue); - - ///// - ///// 根据条件取条数 - ///// - ///// 条件表达式树 - ///// - //int GetCount(Expression> where); - - - ///// - ///// 查询所有数据(无分页,请慎用) - ///// - ///// - //List GetAll(bool useCache = false, int cacheSecond = 3600); - - - ///// - ///// 获得一条数据 - ///// - ///// Expression> - ///// - //T GetFirst(Expression> where); - - - ///// - ///// 获得一条数据 - ///// - ///// string - ///// + /// + /// 获得一条数据 + /// + /// string + /// //T GetFirst(string parm); - ///// - ///// 根据条件查询分页数据 - ///// - ///// - ///// - ///// - //PagedInfo GetPages(Expression> where, Model.PagerInfo parm); + int Count(Expression> where); - ///// - ///// 根据条件查询分页 - ///// - ///// - ///// - ///// - ///// - ///// - //PagedInfo GetPages(Expression> where, Model.PagerInfo parm, Expression> order, string orderEnum = "Asc"); + #endregion query - ///// - ///// 根据条件查询数据 - ///// - ///// 条件表达式树 - ///// - ////List GetWhere(Expression> where, bool useCache = false, int cacheSecond = 3600); + #region Procedure - /////// - /////// 根据条件查询数据 - /////// - /////// 条件表达式树 - /////// - ////List GetWhere(Expression> where, Expression> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600); + DataTable UseStoredProcedureToDataTable(string procedureName, List parameters); + (DataTable, List) UseStoredProcedureToTuple(string procedureName, List parameters); - //#endregion - - //#region 修改操作 - - ///// - ///// 修改一条数据 - ///// - ///// T - ///// - //int Update(T parm); - - - ///// - ///// 批量修改 - ///// - ///// T - ///// - //int Update(List parm); - - - ///// - ///// 按查询条件更新 - ///// - ///// - ///// - ///// - //int Update(Expression> where, Expression> columns); - - - //#endregion - - //#region 删除操作 - - ///// - ///// 删除一条或多条数据 - ///// - ///// string - ///// - //int Delete(object id); - - - ///// - ///// 删除一条或多条数据 - ///// - ///// string - ///// - //int Delete(object[] ids); - - ///// - ///// 根据条件删除一条或多条数据 - ///// - ///// 过滤条件 - ///// - //int Delete(Expression> where); - - ///// - ///// 清空表 - ///// - ///// - //int DeleteTable(); - #endregion - + #endregion Procedure } } \ No newline at end of file diff --git a/ZR.Service/System/ArticleCategoryService.cs b/ZR.Service/System/ArticleCategoryService.cs index 7ef4573..7bc2a9f 100644 --- a/ZR.Service/System/ArticleCategoryService.cs +++ b/ZR.Service/System/ArticleCategoryService.cs @@ -1,7 +1,10 @@ using Infrastructure.Attribute; +using SqlSugar; +using SqlSugar.IOC; using System.Collections.Generic; using System.Linq; using ZR.Model.System; +using ZR.Repository.System; using ZR.Service.System.IService; namespace ZR.Service.System @@ -12,6 +15,9 @@ namespace ZR.Service.System [AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)] public class ArticleCategoryService : BaseService, IArticleCategoryService { + public ArticleCategoryService(ArticleCategoryRepository repository) : base(repository) + { + } /// /// 构建前端所需要树结构 /// diff --git a/ZR.Service/System/ArticleService.cs b/ZR.Service/System/ArticleService.cs index 863efa9..5a74be4 100644 --- a/ZR.Service/System/ArticleService.cs +++ b/ZR.Service/System/ArticleService.cs @@ -1,5 +1,7 @@ using Infrastructure.Attribute; +using SqlSugar; using ZR.Model.System; +using ZR.Repository.System; using ZR.Service.System.IService; namespace ZR.Service.System @@ -10,6 +12,8 @@ namespace ZR.Service.System [AppService(ServiceType = typeof(IArticleService), ServiceLifetime = LifeTime.Transient)] public class ArticleService : BaseService
, IArticleService { - + public ArticleService(ArticleRepository repository) : base(repository) + { + } } } diff --git a/ZR.Service/System/SysConfigService.cs b/ZR.Service/System/SysConfigService.cs index 8684572..b477dda 100644 --- a/ZR.Service/System/SysConfigService.cs +++ b/ZR.Service/System/SysConfigService.cs @@ -1,13 +1,4 @@ -using Infrastructure; using Infrastructure.Attribute; -using Infrastructure.Extensions; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using ZR.Common; -using ZR.Model.Models; using ZR.Model.System; using ZR.Repository; @@ -15,15 +6,12 @@ namespace ZR.Service.System { /// /// 参数配置Service业务层处理 - /// - /// @author zhaorui - /// @date 2021-09-29 /// [AppService(ServiceType = typeof(ISysConfigService), ServiceLifetime = LifeTime.Transient)] - public class SysConfigService: BaseService, ISysConfigService + public class SysConfigService : BaseService, ISysConfigService { private readonly SysConfigRepository _SysConfigrepository; - public SysConfigService(SysConfigRepository repository) + public SysConfigService(SysConfigRepository repository) : base(repository) { _SysConfigrepository = repository; } diff --git a/ZR.Service/System/SysDeptService.cs b/ZR.Service/System/SysDeptService.cs index 359e5ff..14da4b7 100644 --- a/ZR.Service/System/SysDeptService.cs +++ b/ZR.Service/System/SysDeptService.cs @@ -22,7 +22,7 @@ namespace ZR.Service.System { public SysDeptRepository DeptRepository; - public SysDeptService(SysDeptRepository deptRepository) + public SysDeptService(SysDeptRepository deptRepository) : base(deptRepository) { DeptRepository = deptRepository; } diff --git a/ZR.Service/System/SysDictDataService.cs b/ZR.Service/System/SysDictDataService.cs index 2c698c8..1e02c0c 100644 --- a/ZR.Service/System/SysDictDataService.cs +++ b/ZR.Service/System/SysDictDataService.cs @@ -9,12 +9,15 @@ using ZR.Service.System.IService; namespace ZR.Service.System { + /// + /// 字典数据类 + /// [AppService(ServiceType = typeof(ISysDictDataService), ServiceLifetime = LifeTime.Transient)] - public class SysDictDataService: ISysDictDataService + public class SysDictDataService : BaseService, ISysDictDataService { private readonly SysDictDataRepository SysDictDataRepository; - public SysDictDataService(SysDictDataRepository sysDictDataRepository) + public SysDictDataService(SysDictDataRepository sysDictDataRepository) : base(sysDictDataRepository) { SysDictDataRepository = sysDictDataRepository; } @@ -32,7 +35,7 @@ namespace ZR.Service.System /// /// 根据字典类型查询 /// - /// + /// /// public List SelectDictDataByType(string dictType) { diff --git a/ZR.Service/System/SysDictService.cs b/ZR.Service/System/SysDictService.cs index e90db62..3bed701 100644 --- a/ZR.Service/System/SysDictService.cs +++ b/ZR.Service/System/SysDictService.cs @@ -13,12 +13,12 @@ namespace ZR.Service.System /// 字典类型 /// [AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)] - public class SysDictService : ISysDictService + public class SysDictService : BaseService, ISysDictService { private SysDictRepository DictRepository; private SysDictDataRepository DictDataRepository; - public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository) + public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository) : base(sysDictRepository) { this.DictRepository = sysDictRepository; this.DictDataRepository = dictDataRepository; diff --git a/ZR.Service/System/SysLoginService.cs b/ZR.Service/System/SysLoginService.cs index 020e14b..8f73529 100644 --- a/ZR.Service/System/SysLoginService.cs +++ b/ZR.Service/System/SysLoginService.cs @@ -19,7 +19,7 @@ namespace ZR.Service.System { private SysLogininfoRepository SysLogininfoRepository; - public SysLoginService(SysLogininfoRepository sysLogininfo) + public SysLoginService(SysLogininfoRepository sysLogininfo): base(sysLogininfo) { SysLogininfoRepository = sysLogininfo; } diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.Service/System/SysMenuService.cs index cbc39c6..1afff0b 100644 --- a/ZR.Service/System/SysMenuService.cs +++ b/ZR.Service/System/SysMenuService.cs @@ -15,14 +15,14 @@ namespace ZR.Service /// 菜单 /// [AppService(ServiceType = typeof(ISysMenuService), ServiceLifetime = LifeTime.Transient)] - public class SysMenuService: ISysMenuService + public class SysMenuService : BaseService, ISysMenuService { public SysMenuRepository MenuRepository; public ISysRoleService SysRoleService; public SysMenuService( - SysMenuRepository menuRepository, - ISysRoleService sysRoleService) + SysMenuRepository menuRepository, + ISysRoleService sysRoleService) : base(menuRepository) { MenuRepository = menuRepository; SysRoleService = sysRoleService; diff --git a/ZR.Service/System/SysOperLogService.cs b/ZR.Service/System/SysOperLogService.cs index 043ba8c..1ff3eda 100644 --- a/ZR.Service/System/SysOperLogService.cs +++ b/ZR.Service/System/SysOperLogService.cs @@ -13,11 +13,11 @@ namespace ZR.Service.System /// 操作日志 /// [AppService(ServiceType = typeof(ISysOperLogService), ServiceLifetime = LifeTime.Transient)] - public class SysOperLogService : ISysOperLogService + public class SysOperLogService : BaseService, ISysOperLogService { public SysOperLogRepository sysOperLogRepository; - public SysOperLogService(SysOperLogRepository sysOperLog) + public SysOperLogService(SysOperLogRepository sysOperLog) : base(sysOperLog) { sysOperLogRepository = sysOperLog; } diff --git a/ZR.Service/System/SysPermissionService.cs b/ZR.Service/System/SysPermissionService.cs index 607d3f9..7ebf695 100644 --- a/ZR.Service/System/SysPermissionService.cs +++ b/ZR.Service/System/SysPermissionService.cs @@ -8,6 +8,9 @@ using ZR.Service.System.IService; namespace ZR.Service.System { + /// + /// 角色权限 + /// [AppService(ServiceType = typeof(ISysPermissionService), ServiceLifetime = LifeTime.Transient)] public class SysPermissionService : ISysPermissionService { diff --git a/ZR.Service/System/SysPostService.cs b/ZR.Service/System/SysPostService.cs index 5a5e977..0767784 100644 --- a/ZR.Service/System/SysPostService.cs +++ b/ZR.Service/System/SysPostService.cs @@ -16,7 +16,7 @@ namespace ZR.Service.System public class SysPostService : BaseService, ISysPostService { public SysPostRepository PostRepository; - public SysPostService(SysPostRepository postRepository) + public SysPostService(SysPostRepository postRepository): base(postRepository) { PostRepository = postRepository; } diff --git a/ZR.Service/System/SysTasksLogService.cs b/ZR.Service/System/SysTasksLogService.cs index 7b7ae0d..fdebc8d 100644 --- a/ZR.Service/System/SysTasksLogService.cs +++ b/ZR.Service/System/SysTasksLogService.cs @@ -6,6 +6,9 @@ using ZR.Service.System.IService; namespace ZR.Service.System { + /// + /// 任务日志 + /// [AppService(ServiceLifetime = LifeTime.Transient, ServiceType = typeof(ISysTasksLogService))] public class SysTasksLogService : BaseRepository, ISysTasksLogService { diff --git a/ZR.Service/System/SysTasksQzService.cs b/ZR.Service/System/SysTasksQzService.cs index 1569287..17e6e85 100644 --- a/ZR.Service/System/SysTasksQzService.cs +++ b/ZR.Service/System/SysTasksQzService.cs @@ -1,12 +1,18 @@ using Infrastructure.Attribute; using ZR.Model.System; +using ZR.Repository.System; using ZR.Service.System.IService; namespace ZR.Service.System { + /// + /// 定时任务 + /// [AppService(ServiceType = typeof(ISysTasksQzService), ServiceLifetime = LifeTime.Transient)] public class SysTasksQzService : BaseService, ISysTasksQzService { - + public SysTasksQzService(SysTasksQzRepository repository) : base(repository) + { + } } } diff --git a/ZR.Service/System/SysUserRoleService.cs b/ZR.Service/System/SysUserRoleService.cs index 94bdfc1..183b10f 100644 --- a/ZR.Service/System/SysUserRoleService.cs +++ b/ZR.Service/System/SysUserRoleService.cs @@ -9,6 +9,9 @@ using ZR.Service.System.IService; namespace ZR.Service.System { + /// + /// 用户角色 + /// [AppService(ServiceType = typeof(ISysUserRoleService),ServiceLifetime = LifeTime.Transient)] public class SysUserRoleService: ISysUserRoleService { diff --git a/ZR.Service/System/SysUserService.cs b/ZR.Service/System/SysUserService.cs index 2fe57d4..92e08a6 100644 --- a/ZR.Service/System/SysUserService.cs +++ b/ZR.Service/System/SysUserService.cs @@ -10,6 +10,9 @@ using ZR.Service.System.IService; namespace ZR.Service { + /// + /// 系统用户 + /// [AppService(ServiceType = typeof(ISysUserService), ServiceLifetime = LifeTime.Transient)] public class SysUserService : BaseService, ISysUserService { @@ -22,7 +25,7 @@ namespace ZR.Service SysUserRepository userRepository, ISysRoleService sysRoleService, ISysUserRoleService userRoleService, - ISysUserPostService userPostService) + ISysUserPostService userPostService) : base(userRepository) { UserRepository = userRepository; RoleService = sysRoleService; diff --git a/ZR.Vue/src/main.js b/ZR.Vue/src/main.js index 408b53d..e81993f 100644 --- a/ZR.Vue/src/main.js +++ b/ZR.Vue/src/main.js @@ -56,15 +56,6 @@ Vue.component('DictTag', DictTag) Vue.use(permission) -/** - * If you don't want to use mock-server - * you want to use MockJs for mock api - * you can execute: mockXHR() - * - * Currently MockJs will be used in the production environment, - * please remove it before going online! ! ! - */ - Vue.use(Element, { size: Cookies.get('size') || 'medium' // set element-ui default size })