/// <summary>
 /// 修改角色
 /// </summary>
 /// <param name="roleModel">角色实体</param>
 /// <param name="valueList">角色值</param>
 /// <returns></returns>
 public DbResult <bool> SystemRoleValueUpdate(SystemManagerRoleModel roleModel, List <RoleCommit> valueList)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var result = conn.Ado.UseTran(() =>
         {
             var begin = conn.Updateable <SystemManagerRoleModel>(roleModel).ExecuteCommand();
             //判断添加的角色权限
             if (roleModel.SystemManagerRoleLevel == (int)OrdinaryManager)
             {
                 //先删除该用户之前的权限
                 conn.Deleteable <SystemManagerRoleValueModel>().Where(t => t.SystemManagerRoleId == roleModel.SystemManagerRoleId).ExecuteCommand();
                 if (valueList.Count > 0)
                 {
                     var list = new List <SystemManagerRoleValueModel>();
                     foreach (var item in valueList)
                     {
                         var model = new SystemManagerRoleValueModel()
                         {
                             SystemManagerRoleId          = roleModel.SystemManagerRoleId,
                             SystemManagerRoleNavId       = item.QueryNavId,
                             SystemManagerRoleValueAction = item.QueryActionId,
                             SystemManagerRoleValueId     = 0,
                             SystemManagerRoleValueTime   = DateTime.Now
                         };
                         list.Add(model);
                     }
                     conn.Insertable <SystemManagerRoleValueModel>(list.ToArray()).ExecuteCommand();
                 }
             }
         });
         return(result);
     }
 }
 /// <summary>
 /// 编辑状态下,根据别名判断和ID是否已存在
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public bool GetExtisByName(string name, int navId)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var rows = conn.Queryable <NavigationModel>().Where(t => t.NavIdent == name && t.NavId != navId).Any();
         return(rows);
     }
 }
 /// <summary>
 /// 获取管理员列表,不分页
 /// </summary>
 /// <returns></returns>
 public List <ManagerModel> GetManagerList()
 {
     using (var db = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = db.Queryable <ManagerModel>().OrderBy(t => t.ManagerCount, OrderByType.Desc).OrderBy(t => t.ManagerInsertTime, OrderByType.Desc).ToList();
         return(query);
     }
 }
 /// <summary>
 /// 根据用户名查询SALT
 /// </summary>
 /// <param name="managerName">登录名称</param>
 /// <returns></returns>
 public string GetSaltForManagerName(string managerName)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <ManagerModel>().Where(t => t.ManagerName == managerName).Select(t => t.ManagerSalt).ToString();
         return(query);
     }
 }
 /// <summary>
 /// 实现管理员登录
 /// </summary>
 /// <param name="loginName">登录用户名</param>
 /// <param name="loginPass">登录用户密码(从前台传过来已被加密状态)</param>
 /// <returns></returns>
 public ManagerModel GetManagerLogin(string loginName, string loginPass)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var queryAble = conn.Queryable <ManagerModel>().Where(t => t.ManagerName == loginName && t.ManagerPass == loginPass).First();
         return(queryAble);
     }
 }
 /// <summary>
 /// 根据传过来的角色ID,判断是否有管理员使用该角色
 /// </summary>
 /// <param name="roleId">角色ID</param>
 /// <returns></returns>
 public bool GetManagerUsingRole(int roleId)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <ManagerModel>().Where(t => t.ManagerRoleId == roleId).Any();
         return(query);
     }
 }
 /// <summary>
 /// 获取所有导航数据
 /// </summary>
 /// <returns></returns>
 public List <NavigationModel> GetNavigationAllList()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <NavigationModel>().OrderBy(t => t.NavSort, SqlSugar.OrderByType.Desc).OrderBy(t => t.NavInsertTime).ToList();
         return(query);
     }
 }
 /// <summary>
 /// 获取到所有的父级导航
 /// </summary>
 /// <returns></returns>
 public List <NavigationModel> GetNavUpperLevel()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <NavigationModel>().Where(t => t.NavParentId == 0).ToList();
         return(query);
     }
 }
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <param name="id">主键参数ID</param>
 /// <returns></returns>
 public SystemOperLogModel GetSystemLogModel(int id)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <SystemOperLogModel>().Where(t => t.LogId == id).First();
         return(query);
     }
 }
 /// <summary>
 /// 删除日志信息,利用List<int>
 /// </summary>
 /// <returns></returns>
 public int DeleteLogInfo(List <int> deleteLogList)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var rows = conn.Deleteable <SystemOperLogModel>().In(deleteLogList).ExecuteCommand();
         return(rows);
     }
 }
 /// <summary>
 /// 获取正常管理员的经营数量
 /// </summary>
 /// <returns></returns>
 public int GetManagerEableCount()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var count = conn.Queryable <ManagerModel>().Where(t => t.ManagerStatus == (int)Status.Enable).Count();
         return(count);
     }
 }
 /// <summary>
 /// 管理员详情页可以用的获取权限实例列表=>获取状态为启用的
 /// </summary>
 /// <returns></returns>
 public List <SystemManagerRoleModel> GetRoleList()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <SystemManagerRoleModel>().Where(t => t.SystemManagerRoleStatus == (int)EnumStatus.Status.Enable).OrderBy(t => t.SystemManagerRoleCreateTime, OrderByType.Desc).ToList();
         return(query);
     }
 }
 /// <summary>
 /// 获取全部角色信息
 /// </summary>
 /// <returns></returns>
 public List <SystemManagerRoleModel> GetSystemRoleAllList()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <SystemManagerRoleModel>().ToList();
         return(query);
     }
 }
 /// <summary>
 /// 获取角色正常的角色
 /// </summary>
 /// <returns></returns>
 public int GetEableRoleCount()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <SystemManagerRoleModel>().Where(t => t.SystemManagerRoleStatus == (int)EnumStatus.Status.Enable).Count();
         return(query);
     }
 }
 /// <summary>
 /// 删除管理员信息,利用List<int>
 /// </summary>
 /// <param name="deleteManagerList"></param>
 /// <returns></returns>
 public int DeleteManagerInfo(List <int> deleteManagerList)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var rows = conn.Deleteable <ManagerModel>().In(deleteManagerList).ExecuteCommand();
         return(rows);
     }
 }
 /// <summary>
 /// 获取导航实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public NavigationModel GetModel(int id)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <NavigationModel>().Where(t => t.NavId == id).First();
         return(query);
     }
 }
 /// <summary>
 /// 搜索日志
 /// </summary>
 /// <param name="pageIndex">页码</param>
 /// <param name="pageSize">页数</param>
 /// <param name="totalCount">返回总数</param>
 /// <param name="keyword">搜索关键词</param>
 /// <param name="operId">搜索的类型ID</param>
 /// <returns></returns>
 public List <SystemOperLogModel> GetSystemLogDbList(int pageIndex, int pageSize, out int totalCount, string keyword, int operId = -1)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var refCount = 0;
         var query    = conn.Queryable <SystemOperLogModel>().WhereIF(!string.IsNullOrEmpty(keyword), t => t.LogNewAccess.Contains(keyword) || t.LogOldAccess.Contains(keyword) || t.LogUserId.ToString().Contains(keyword) || t.LogActionName.Contains(keyword) || t.LogObjectRemark.Contains(keyword) || t.LogPageUrl.Contains(keyword) || t.LogCurrentIP.Contains(keyword)).WhereIF(operId > -1, t => t.LogOperId == operId).OrderBy(t => t.LogDateTime, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref refCount);
         totalCount = refCount;
         return(query);
     }
 }
 /// <summary>
 /// 搜索日志
 /// </summary>
 /// <param name="pageIndex">页码</param>
 /// <param name="pageSize">页数</param>
 /// <param name="totalCount">返回总数</param>
 /// <param name="keyword">搜索关键词</param>
 /// <returns></returns>
 public List <SystemManagerRoleModel> GetRoleList(int pageIndex, int pageSize, out int totalCount, string keyword)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var refCount = 0;
         var query    = conn.Queryable <SystemManagerRoleModel>().WhereIF(!string.IsNullOrEmpty(keyword), t => t.SystemManagerRoleName.Contains(keyword)).OrderBy(t => t.SystemManagerRoleCreateTime, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref refCount);
         totalCount = refCount;
         return(query);
     }
 }
 /// <summary>
 /// 先获取父级导航,然后获取子级数据,规定后台只有2级
 /// </summary>
 /// <returns></returns>
 public List <NavigationModel> GetNavList()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var parent_0 = conn.Queryable <NavigationModel>().Where(t => t.NavParentId == 0).OrderBy(t => t.NavSort, SqlSugar.OrderByType.Desc).OrderBy(t => t.NavInsertTime).ToList();
         foreach (var item in parent_0)
         {
             item.ActionList = conn.Queryable <NavigationModel>().Where(t => t.NavParentId == item.NavId).OrderBy(t => t.NavSort, SqlSugar.OrderByType.Desc).OrderBy(t => t.NavInsertTime).ToList();
         }
         return(parent_0);
     }
 }
 /// <summary>
 /// 获取角色信息,且获取详情信息
 /// </summary>
 /// <param name="responeRoleId"></param>
 /// <returns></returns>
 public SystemManagerRoleModel GetRoleModel(int responeRoleId)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var query = conn.Queryable <SystemManagerRoleModel>().Where(t => t.SystemManagerRoleId == responeRoleId).First();
         if (query != null)
         {
             if (query.SystemManagerRoleLevel == (int)OrdinaryManager)
             {
                 var list = conn.Queryable <SystemManagerRoleValueModel>().Where(t => t.SystemManagerRoleId == responeRoleId).ToList();
                 query.GetSystemManagerRoleValueList = list;
             }
         }
         return(query);
     }
 }
 public bool GetManagerLoginNameIsAny(string loginName, int id)
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         // 添加状态:直接判断该用户名是否存在
         // 编辑状态:除此ID外是否存在该用户名
         bool query = false;
         if (id > 0)
         {
             query = conn.Queryable <ManagerModel>().Where(t => t.ManagerId != id).Where(t => t.ManagerName == loginName).Any();
         }
         else
         {
             query = conn.Queryable <ManagerModel>().Where(t => t.ManagerName == loginName).Any();
         }
         return(query);
     }
 }
 /// <summary>
 /// 获取角色信息,然后获取详情
 /// </summary>
 /// <returns></returns>
 public List <SystemManagerRoleModel> GetRoleDetailList()
 {
     using (var conn = SqlSugarConnection.GetSqlSugarClient())
     {
         var list = conn.Queryable <SystemManagerRoleModel>().OrderBy(t => t.SystemManagerRoleCreateTime, OrderByType.Desc).ToList();
         foreach (var item in list)
         {
             if (item.SystemManagerRoleLevel == (int)OrdinaryManager)
             {
                 item.GetSystemManagerRoleValueList = conn.Queryable <SystemManagerRoleValueModel>().Where(t => t.SystemManagerRoleId == item.SystemManagerRoleId).ToList();
             }
             else
             {
                 continue;
             }
         }
         return(list);
     }
 }