diff --git a/Infrastructure/OptionsSetting.cs b/Infrastructure/OptionsSetting.cs index 84ef25d..7833a53 100644 --- a/Infrastructure/OptionsSetting.cs +++ b/Infrastructure/OptionsSetting.cs @@ -7,7 +7,10 @@ namespace Infrastructure public class OptionsSetting { public static string ConnAdmin = "conn_zrAdmin"; - public static string ConnDbType = "conn_zrAdmin_Type"; + public static string ConnDbType = "conn_zrAdmin_type"; + public static string ConnBus = "conn_bus"; + public static string ConnBusDbType = "conn_bus_type"; + public static string DbKey = "DbKey"; public string Redis { get; set; } diff --git a/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs b/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs index 73a12fb..171b9db 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs @@ -38,11 +38,9 @@ namespace ZR.Admin.WebApi.Controllers.System [HttpGet("list")] public IActionResult List([FromQuery] SysRole role, [FromQuery] PagerInfo pager) { - var list = sysRoleService.SelectRoleList(role); + var list = sysRoleService.SelectRoleList(role, pager); - VMPageResult vMPageResult = new(list, pager); - - return SUCCESS(vMPageResult, TIME_FORMAT_FULL); + return SUCCESS(list, TIME_FORMAT_FULL); } /// @@ -124,7 +122,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// /// [HttpPut("dataScope")] - [ActionPermissionFilter(Permission = "system:role:update")] + [ActionPermissionFilter(Permission = "system:role:authorize")] [Log(Title = "角色管理", BusinessType = BusinessType.UPDATE)] public IActionResult DataScope([FromBody] SysRole sysRoleDto) { diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs index 0968dfb..8b8cf2d 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs @@ -40,7 +40,7 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpGet("list")] - [ActionPermissionFilter(Permission = "system:task:list")] + [ActionPermissionFilter(Permission = "monitor:job:list")] public IActionResult Query([FromQuery] TasksQueryDto parm, [FromQuery] PagerInfo pager) { //开始拼装查询条件 @@ -71,13 +71,12 @@ namespace ZR.Admin.WebApi.Controllers return SUCCESS(_tasksQzService.GetAll()); } - /// /// 添加任务 /// /// [HttpPost("create")] - [ActionPermissionFilter(Permission = "system:task:add")] + [ActionPermissionFilter(Permission = "monitor:job:add")] [Log(Title = "添加任务", BusinessType = BusinessType.INSERT)] public IActionResult Create([FromBody] TasksCreateDto parm) { @@ -104,7 +103,7 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpPost("update")] - [ActionPermissionFilter(Permission = "system:task:edit")] + [ActionPermissionFilter(Permission = "monitor:job:edit")] [Log(Title = "修改任务", BusinessType = BusinessType.UPDATE)] public async Task Update([FromBody] TasksUpdateDto parm) { @@ -156,7 +155,7 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpDelete("delete")] - [ActionPermissionFilter(Permission = "system:task:delete")] + [ActionPermissionFilter(Permission = "monitor:job:delete")] [Log(Title = "删除任务", BusinessType = BusinessType.DELETE)] public async Task Delete(string id) { @@ -185,7 +184,7 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpGet("start")] - [ActionPermissionFilter(Permission = "system:task:start")] + [ActionPermissionFilter(Permission = "monitor:job:start")] [Log(Title = "启动任务", BusinessType = BusinessType.OTHER)] public async Task Start(string id) { @@ -216,7 +215,7 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpGet("stop")] - [ActionPermissionFilter(Permission = "system:task:stop")] + [ActionPermissionFilter(Permission = "monitor:job:stop")] [Log(Title = "停止任务", BusinessType = BusinessType.OTHER)] public async Task Stop(string id) { @@ -248,7 +247,7 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpGet("run")] - [ActionPermissionFilter(Permission = "system:task:run")] + [ActionPermissionFilter(Permission = "monitor:job:run")] [Log(Title = "执行任务", BusinessType = BusinessType.OTHER)] public async Task Run(string id) { diff --git a/ZR.Admin.WebApi/Startup.cs b/ZR.Admin.WebApi/Startup.cs index 360469a..29f5d2c 100644 --- a/ZR.Admin.WebApi/Startup.cs +++ b/ZR.Admin.WebApi/Startup.cs @@ -11,7 +11,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; +using SqlSugar.IOC; +using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Admin.WebApi.Middleware; @@ -116,12 +120,54 @@ namespace ZR.Admin.WebApi /// עServices /// /// - private static void InjectRepositories(IServiceCollection services) + private void InjectRepositories(IServiceCollection services) { services.AddAppService(); //ƻ services.AddTaskSchedulers(); + + string connStr = Configuration.GetConnectionString(OptionsSetting.ConnAdmin); + string connStrBus = Configuration.GetConnectionString(OptionsSetting.ConnBus); + string dbKey = Configuration[OptionsSetting.DbKey]; + int dbType = Convert.ToInt32(Configuration[OptionsSetting.ConnDbType]); + int dbType_bus = Convert.ToInt32(Configuration[OptionsSetting.ConnBusDbType]); + + IocConfig db1 = new IocConfig() + { + ConfigId = "0", //⻧õ + ConnectionString = connStr, + DbType = (IocDbType)dbType, + IsAutoCloseConnection = true//Զͷ + }; + IocConfig db2 = new IocConfig() + { + ConfigId = "1", // ⻧õ + ConnectionString = connStrBus, + DbType = (IocDbType)dbType_bus, + IsAutoCloseConnection = true//Զͷ + }; + SugarIocServices.AddSqlSugar(new List() { db1, db2 }); + + //ʽ ӡSQL + 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) => + { + Console.WriteLine($"[ִSql]{e.Message}SQL={e.Sql}"); + Console.WriteLine(); + }; + //Bus Db־ + DbScoped.SugarScope.GetConnection(1).Aop.OnError = (e) => + { + Console.WriteLine($"[ִSqlBus]{e.Message}SQL={e.Sql}"); + Console.WriteLine(); + }; } } } diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj index 7b52794..72dcad4 100644 --- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj +++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj @@ -32,6 +32,7 @@ + diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index 3b2e17c..51eede7 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -7,9 +7,11 @@ } }, "ConnectionStrings": { - "conn_zrAdmin": "server=127.0.0.1;user=zr;pwd=abc;database=admin" + "conn_zrAdmin": "server=127.0.0.1;user=zr;pwd=abc;database=admin", + "conn_bus": "server=127.0.0.1;user=zr;pwd=abc;database=admin" }, - "conn_zrAdmin_Type": 0, //MySql = 0, SqlServer = 1 + "conn_zrAdmin_type": 0, //MySql = 0, SqlServer = 1 + "conn_bus_type": 0, "urls": "http://localhost:8888", //Ŀurl "sysConfig": { "DBCommandTimeout": 10, diff --git a/ZR.Repository/BaseRepository.cs b/ZR.Repository/BaseRepository.cs index a4d0fab..644cb52 100644 --- a/ZR.Repository/BaseRepository.cs +++ b/ZR.Repository/BaseRepository.cs @@ -1,6 +1,7 @@ using Infrastructure; using Infrastructure.Model; using SqlSugar; +using SqlSugar.IOC; using System; using System.Collections.Generic; using System.Dynamic; @@ -21,46 +22,8 @@ namespace ZR.Repository { if (dbContext == null) { - string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin); - string dbKey = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbKey); - int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.ConnDbType); - if (!string.IsNullOrEmpty(dbKey)) - { - connStr = NETCore.Encrypt.EncryptProvider.DESDecrypt(connStr, dbKey); - } - - var Db = new SqlSugarClient(new List() - { - new ConnectionConfig(){ - ConnectionString = connStr, - DbType = (DbType)dbType, - IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样 - InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息 - ConfigId = 0 - }, - new ConnectionConfig(){ - ConnectionString = "", - DbType = DbType.SqlServer, - IsAutoCloseConnection = true, - InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息 - ConfigId = 1 - }, - }); - - //调式代码 用来打印SQL - Db.GetConnection(0).Aop.OnLogExecuting = (sql, pars) => - { - Console.BackgroundColor = ConsoleColor.Yellow; - Console.WriteLine("【SQL语句】" + sql.ToLower() + "\r\n" + Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); - }; - //出错打印日志 - Db.GetConnection(0).Aop.OnError = (e) => - { - Console.WriteLine($"[执行Sql出错]{e.Message},SQL={e.Sql}"); - Console.WriteLine(); - }; - - Context = Db.GetConnection(configId);//根据类传入的ConfigId自动选择 + //Console.WriteLine("configId:" + configId); + base.Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择 } } @@ -87,115 +50,115 @@ namespace ZR.Repository return Context.Insertable(t).ExecuteCommand(); } - public int InsertIgnoreNullColumn(T t) - { - 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 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 long InsertBigIdentity(T t) + //{ + // return base.Context.Insertable(t).ExecuteReturnBigIdentity(); + //} public int Insert(List t) { return base.Context.Insertable(t).ExecuteCommand(); } - public int InsertIgnoreNullColumn(List t) - { - return base.Context.Insertable(t).IgnoreColumns(true).ExecuteCommand(); - } + //public int InsertIgnoreNullColumn(List t) + //{ + // return base.Context.Insertable(t).IgnoreColumns(true).ExecuteCommand(); + //} - public int InsertIgnoreNullColumn(List t, params string[] columns) - { - 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 DbResult InsertTran(T t) - { - var result = base.Context.Ado.UseTran(() => - { - base.Context.Insertable(t).ExecuteCommand(); - }); - return result; - } + //public int InsertIgnoreNullColumn(List t, params string[] columns) + //{ + // 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 DbResult InsertTran(T t) + //{ + // var result = base.Context.Ado.UseTran(() => + // { + // base.Context.Insertable(t).ExecuteCommand(); + // }); + // return result; + //} - public DbResult InsertTran(List t) - { - var result = base.Context.Ado.UseTran(() => - { - base.Context.Insertable(t).ExecuteCommand(); - }); - return result; - } + //public DbResult InsertTran(List t) + //{ + // var result = base.Context.Ado.UseTran(() => + // { + // base.Context.Insertable(t).ExecuteCommand(); + // }); + // return result; + //} - public T InsertReturnEntity(T t) - { - return base.Context.Insertable(t).ExecuteReturnEntity(); - } + //public T InsertReturnEntity(T t) + //{ + // return base.Context.Insertable(t).ExecuteReturnEntity(); + //} - public T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock) - { - return base.Context.Insertable(t).With(sqlWith).ExecuteReturnEntity(); - } + //public T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock) + //{ + // return base.Context.Insertable(t).With(sqlWith).ExecuteReturnEntity(); + //} - public bool ExecuteCommand(string sql, object parameters) - { - return base.Context.Ado.ExecuteCommand(sql, parameters) > 0; - } + //public bool ExecuteCommand(string sql, 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, 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; - } + //public bool ExecuteCommand(string sql, List parameters) + //{ + // return base.Context.Ado.ExecuteCommand(sql, parameters) > 0; + //} #endregion add #region update - public bool UpdateEntity(T entity, bool ignoreNullColumns = false) - { - return base.Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0; - } + //public bool UpdateEntity(T entity, bool ignoreNullColumns = false) + //{ + // return base.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) + //{ + // return base.Context.Updateable(entity).Where(expression).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, bool ignoreAllNull = false) + //{ + // return base.Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).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(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; + //} /// /// @@ -218,14 +181,14 @@ namespace ZR.Repository return base.Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand() > 0; } - public bool Update(List entity) - { - var result = base.Context.Ado.UseTran(() => - { - base.Context.Updateable(entity).ExecuteCommand(); - }); - return result.IsSuccess; - } + //public bool Update(List entity) + //{ + // var result = base.Context.Ado.UseTran(() => + // { + // base.Context.Updateable(entity).ExecuteCommand(); + // }); + // return result.IsSuccess; + //} public bool Update(Expression> where, Expression> columns) { return base.Context.Updateable().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand() > 0; @@ -252,20 +215,20 @@ namespace ZR.Repository #region delete - public bool DeleteExp(Expression> expression) - { - return Context.Deleteable().Where(expression).ExecuteCommand() > 0; - } + //public bool DeleteExp(Expression> expression) + //{ + // return Context.Deleteable().Where(expression).ExecuteCommand() > 0; + //} //public bool Delete(PkType[] primaryKeyValues) //{ // return base.Context.Deleteable().In(primaryKeyValues).ExecuteCommand() > 0; //} - public int Delete(object[] obj) - { - return Context.Deleteable().In(obj).ExecuteCommand(); - } + //public int Delete(object[] obj) + //{ + // return Context.Deleteable().In(obj).ExecuteCommand(); + //} public int Delete(object id) { return Context.Deleteable(id).ExecuteCommand(); @@ -289,20 +252,20 @@ namespace ZR.Repository return Context.Queryable(); } - public ISugarQueryable Queryable(string tableName, string shortName) - { - return Context.Queryable(tableName, shortName); - } + //public ISugarQueryable Queryable(string tableName, string shortName) + //{ + // return Context.Queryable(tableName, shortName); + //} public List QueryableToList(Expression> expression) { return Context.Queryable().Where(expression).ToList(); } - public Task> QueryableToListAsync(Expression> expression) - { - return Context.Queryable().Where(expression).ToListAsync(); - } + //public Task> QueryableToListAsync(Expression> expression) + //{ + // return Context.Queryable().Where(expression).ToListAsync(); + //} //public string QueryableToJson(string select, Expression> expressionWhere) //{ @@ -310,45 +273,45 @@ namespace ZR.Repository // return query.JilToJson(); //} - public List QueryableToList(string tableName) - { - return Context.Queryable(tableName).ToList(); - } + //public List QueryableToList(string tableName) + //{ + // return Context.Queryable(tableName).ToList(); + //} - public List QueryableToList(string tableName, Expression> expression) - { - return Context.Queryable(tableName).Where(expression).ToList(); - } + //public List QueryableToList(string tableName, Expression> expression) + //{ + // return Context.Queryable(tableName).Where(expression).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) { diff --git a/ZR.Repository/IBaseRepository.cs b/ZR.Repository/IBaseRepository.cs index 719eda4..343e332 100644 --- a/ZR.Repository/IBaseRepository.cs +++ b/ZR.Repository/IBaseRepository.cs @@ -18,42 +18,42 @@ namespace ZR.Repository int Add(T parm, Expression> iClumns = null, bool ignoreNull = true); int Add(T t); - int InsertIgnoreNullColumn(T t); + //int InsertIgnoreNullColumn(T t); - int InsertIgnoreNullColumn(T t, params string[] columns); + //int InsertIgnoreNullColumn(T t, params string[] columns); //int Insert(SqlSugarClient client, T t); - long InsertBigIdentity(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); + //int InsertIgnoreNullColumn(List t); - int InsertIgnoreNullColumn(List t, params string[] columns); + //int InsertIgnoreNullColumn(List t, params string[] columns); - DbResult InsertTran(T t); + //DbResult InsertTran(T t); - DbResult InsertTran(List t); + //DbResult InsertTran(List t); - T InsertReturnEntity(T t); + //T InsertReturnEntity(T t); - T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock); + //T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock); - bool ExecuteCommand(string sql, object parameters); + //bool ExecuteCommand(string sql, object parameters); - bool ExecuteCommand(string sql, params SugarParameter[] parameters); + //bool ExecuteCommand(string sql, params SugarParameter[] parameters); - bool ExecuteCommand(string sql, List parameters); + //bool ExecuteCommand(string sql, List parameters); #endregion add #region update - bool UpdateEntity(T entity, bool ignoreNullColumns = false); + //bool UpdateEntity(T entity, bool ignoreNullColumns = false); - bool Update(T entity, Expression> expression); + //bool Update(T entity, Expression> expression); /// /// 只更新表达式的值 @@ -61,11 +61,11 @@ 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); /// /// @@ -76,7 +76,7 @@ namespace ZR.Repository /// bool Update(T entity, List list = null, bool isNull = true); - bool Update(List entity); + //bool Update(List entity); bool Update(Expression> where, Expression> columns); #endregion update @@ -89,10 +89,10 @@ namespace ZR.Repository #region delete - bool DeleteExp(Expression> expression); + //bool DeleteExp(Expression> expression); //bool Delete(PkType[] primaryKeyValues); - int Delete(object[] obj); + //int Delete(object[] obj); int Delete(object id); bool DeleteTable(); @@ -120,19 +120,19 @@ namespace ZR.Repository List QueryableToList(Expression> expression); - Task> QueryableToListAsync(Expression> expression); + //Task> QueryableToListAsync(Expression> expression); //string QueryableToJson(string select, Expression> expressionWhere); - List QueryableToList(string tableName); + //List QueryableToList(string tableName); - List QueryableToList(string tableName, Expression> expression); + //List QueryableToList(string tableName, Expression> expression); - (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); diff --git a/ZR.Repository/Repositories/GendemoRepository.cs b/ZR.Repository/Repositories/GendemoRepository.cs index 1d1c8c6..f603632 100644 --- a/ZR.Repository/Repositories/GendemoRepository.cs +++ b/ZR.Repository/Repositories/GendemoRepository.cs @@ -14,6 +14,10 @@ namespace ZR.Repository [AppService(ServiceLifetime = LifeTime.Transient)] public class GendemoRepository : BaseRepository { + public GendemoRepository() : base(configId: 1) + { + } + #region 业务逻辑代码 #endregion } diff --git a/ZR.Repository/System/SysRoleRepository.cs b/ZR.Repository/System/SysRoleRepository.cs index 2a70a10..0b90901 100644 --- a/ZR.Repository/System/SysRoleRepository.cs +++ b/ZR.Repository/System/SysRoleRepository.cs @@ -1,6 +1,8 @@ using Infrastructure.Attribute; +using Infrastructure.Model; using SqlSugar; using System.Collections.Generic; +using ZR.Model; using ZR.Model.System; namespace ZR.Repository.System @@ -14,8 +16,22 @@ namespace ZR.Repository.System /// /// 根据条件分页查询角色数据 /// + /// /// - public List SelectRoleList(SysRole sysRole) + public List SelectRoleList() + { + return Context.Queryable() + .Where(role => role.DelFlag == "0") + .OrderBy(role => role.RoleSort) + .ToList(); + } + /// + /// 根据条件分页查询角色数据 + /// + /// + /// + /// + public PagedInfo SelectRoleList(SysRole sysRole, PagerInfo pager) { return Context.Queryable() .Where(role => role.DelFlag == "0") @@ -23,7 +39,7 @@ namespace ZR.Repository.System .WhereIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status) .WhereIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey) .OrderBy(role => role.RoleSort) - .ToList(); + .ToPage(pager); } /// diff --git a/ZR.Repository/ZR.Repository.csproj b/ZR.Repository/ZR.Repository.csproj index 54c98ed..e91f923 100644 --- a/ZR.Repository/ZR.Repository.csproj +++ b/ZR.Repository/ZR.Repository.csproj @@ -13,6 +13,7 @@ + diff --git a/ZR.Service/System/IService/ISysRoleService.cs b/ZR.Service/System/IService/ISysRoleService.cs index f4f2bcc..b4947f1 100644 --- a/ZR.Service/System/IService/ISysRoleService.cs +++ b/ZR.Service/System/IService/ISysRoleService.cs @@ -1,4 +1,5 @@ -using System; +using Infrastructure.Model; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,8 +13,9 @@ namespace ZR.Service.System.IService /// 根据条件分页查询角色数据 /// /// 角色信息 + /// /// 角色数据集合信息 - public List SelectRoleList(SysRole role); + public PagedInfo SelectRoleList(SysRole role, Model.PagerInfo pager); /// /// 查询所有角色 diff --git a/ZR.Service/System/SysRoleService.cs b/ZR.Service/System/SysRoleService.cs index 94b82f4..f0df631 100644 --- a/ZR.Service/System/SysRoleService.cs +++ b/ZR.Service/System/SysRoleService.cs @@ -1,10 +1,12 @@ using Infrastructure; using Infrastructure.Attribute; +using Infrastructure.Model; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; +using ZR.Model; using ZR.Model.System; using ZR.Repository.System; using ZR.Service.System.IService; @@ -33,9 +35,9 @@ namespace ZR.Service /// /// 角色信息 /// 角色数据集合信息 - public List SelectRoleList(SysRole role) + public PagedInfo SelectRoleList(SysRole role, PagerInfo pager) { - return SysRoleRepository.SelectRoleList(role); + return SysRoleRepository.SelectRoleList(role, pager); } /// @@ -45,7 +47,7 @@ namespace ZR.Service /// public List SelectRoleAll() { - return SysRoleRepository.SelectRoleList(new SysRole()); + return SysRoleRepository.SelectRoleList(); } /// diff --git a/ZR.Vue/src/assets/styles/index.scss b/ZR.Vue/src/assets/styles/index.scss index 7fbd419..8da1200 100644 --- a/ZR.Vue/src/assets/styles/index.scss +++ b/ZR.Vue/src/assets/styles/index.scss @@ -255,6 +255,13 @@ aside { padding: 10px 20px !important; } +/* tree border */ +.tree-border { + margin-top: 5px; + border: 1px solid #e5e6e7; + background: #FFFFFF none; + border-radius:4px; +} .pagination-container .el-pagination { right: 0; position: absolute; @@ -419,39 +426,6 @@ aside { color: #FFFFFF; } -/* text color */ -.text-navy { - color: #1ab394; -} - -.text-primary { - color: inherit; -} - -.text-success { - color: #1c84c6; -} - -.text-info { - color: #23c6c8; -} - -.text-warning { - color: #f8ac59; -} - -.text-danger { - color: #ed5565; -} - -.text-muted { - color: #888888; -} - -/* image */ -.img-circle { - border-radius: 50%; -} .img-lg { width: 120px; diff --git a/ZR.Vue/src/layout/components/Sidebar/Logo.vue b/ZR.Vue/src/layout/components/Sidebar/Logo.vue index c794875..5ac6ffe 100644 --- a/ZR.Vue/src/layout/components/Sidebar/Logo.vue +++ b/ZR.Vue/src/layout/components/Sidebar/Logo.vue @@ -28,6 +28,7 @@