public bool Update(FunctionPower functionPower) { var old = GetModel(functionPower.ID); if (functionPower.FatharFunctionID == 0) { functionPower.SortPath = functionPower.Sort.ToString(); } else { var father = GetModel(functionPower.FatharFunctionID); functionPower.SortPath = father.SortPath + "_" + functionPower.Sort.ToString(); } var list = _dbHelper.GetModelList <FunctionPower>(" and SortPath like '" + old.SortPath + "_%'"); foreach (var item in list) { var indexof = item.SortPath.IndexOf(old.SortPath); item.SortPath = functionPower.SortPath + item.SortPath.Substring(indexof + old.SortPath.Length); _dbHelper.Update(item); } return(_dbHelper.Update(functionPower)); }
public IActionResult Save(FunctionPower functionPower) { if (functionPower.ID == 0) { functionPowerDataService.Add(functionPower); } else { functionPowerDataService.Update(functionPower); } return(Json(new APIResult <FunctionPower>(data: functionPower))); }
public bool Add(FunctionPower functionPower) { if (functionPower.FatharFunctionID == 0) { functionPower.SortPath = functionPower.Sort.ToString(); } else { var father = GetModel(functionPower.FatharFunctionID); functionPower.SortPath = father.SortPath + "_" + functionPower.Sort.ToString(); } return(_dbHelper.Insert(functionPower)); }
public List <DepartmentFunctionPower> GetPowers(int?departmentID, int?appInfoID) { string sql = @"select DepartmentFunctionPower.ID as DFPID, FunctionPower.*,DepartmentFunctionPower.*,Department.*,DepartmentFunctionPower.ID as DFPID from DepartmentFunctionPower join FunctionPower on FunctionPower.ID = DepartmentFunctionPower.FunctionPowerID join Department on Department.ID = DepartmentFunctionPower.DepartmentID where 1=1"; var search = new { DepartmentID = departmentID, AppInfoID = appInfoID }; if (departmentID.HasValue) { sql += " and departmentID = @DepartmentID"; } if (appInfoID.HasValue) { sql += " and AppInfoID=@AppInfoID"; } using (var dr = _dbHelper.GetReader(sql, search)) { List <DepartmentFunctionPower> powers = new List <DepartmentFunctionPower>(); while (dr.Read()) { Department department = new Department(); department.Name = (string)dr["Name"]; department.ID = (int)dr["DepartmentID"]; department.Manager = (int)dr["Manager"]; department.CreateBy = (int)dr["CreateBy"]; department.Deleted = (bool)dr["Deleted"]; department.CreateDate = (DateTime)dr["CreateDate"]; DepartmentFunctionPower departmentFunctionPower = new DepartmentFunctionPower(); departmentFunctionPower.Department = department; departmentFunctionPower.DepartmentID = department.ID; departmentFunctionPower.ID = (int)dr["DFPID"]; FunctionPower functionPower = new FunctionPower(); functionPower.ID = (int)dr["FunctionPowerID"]; functionPower.Level = (int)dr["Level"]; functionPower.Power = dr["Power"] == DBNull.Value ? "" : (string)dr["Power"]; functionPower.Sort = (int)dr["Sort"]; functionPower.SortPath = dr["SortPath"] == DBNull.Value ? "" : (string)dr["SortPath"]; functionPower.Url = dr["Url"] == DBNull.Value ? "" : (string)dr["Url"]; functionPower.FunctionType = (string)dr["FunctionType"]; functionPower.FunctionName = (string)dr["FunctionName"]; functionPower.FatharFunctionID = (int)dr["FatharFunctionID"]; functionPower.AppInfoID = (int)dr["AppInfoID"]; departmentFunctionPower.FunctionPower = functionPower; departmentFunctionPower.ID = (int)dr["DFPID"]; departmentFunctionPower.FunctionPowerID = functionPower.ID; powers.Add(departmentFunctionPower); } return(powers); } }
public List <RoleFunctionPower> GetPowers(int?roleID, int?appInfoID) { string sql = @"select FunctionPower.*,RoleFunctionPower.*,Role.*,RoleFunctionPower.ID as RFPID from RoleFunctionPower join FunctionPower on FunctionPower.ID = RoleFunctionPower.FunctionPowerID join [Role] on [Role] .ID = RoleFunctionPower.RoleID where 1=1"; var search = new { RoleID = roleID, AppInfoID = appInfoID }; if (roleID.HasValue) { sql += " and RoleID = @RoleID"; } if (appInfoID.HasValue) { sql += " and AppInfoID=@AppInfoID"; } using (var dr = dbHelper.GetReader(sql, search)) { List <RoleFunctionPower> powers = new List <RoleFunctionPower>(); while (dr.Read()) { Role role = new Role(); role.RoleName = (string)dr["RoleName"]; role.ID = (int)dr["RoleID"]; RoleFunctionPower roleFunctionPower = new RoleFunctionPower(); roleFunctionPower.Role = role; roleFunctionPower.RoleID = role.ID; FunctionPower functionPower = new FunctionPower(); functionPower.ID = (int)dr["FunctionPowerID"]; functionPower.Level = (int)dr["Level"]; functionPower.Power = dr["Power"] == DBNull.Value ? "" : (string)dr["Power"]; functionPower.Sort = (int)dr["Sort"]; functionPower.SortPath = (string)dr["SortPath"]; functionPower.Url = dr["Url"] == DBNull.Value ? "" : (string)dr["Url"]; functionPower.FunctionType = (string)dr["FunctionType"]; functionPower.FunctionName = (string)dr["FunctionName"]; functionPower.FatharFunctionID = (int)dr["FatharFunctionID"]; functionPower.AppInfoID = (int)dr["AppInfoID"]; roleFunctionPower.FunctionPower = functionPower; roleFunctionPower.FunctionPowerID = functionPower.ID; roleFunctionPower.ID = (int)dr["RFPID"]; powers.Add(roleFunctionPower); } return(powers); } }
public IActionResult Index(int?ID) { var appInfoList = appInfoDataService.GetList(); if (!ID.HasValue) { if (appInfoList.Count() == 0) { throw new Exception("暂无程序信息"); } ID = appInfoList.First().ID; } var list = ExternalFunctionPowerSort.Sort(functionPowerDataService.GetList(ID.Value).MapperList <ExternalFunctionPowerViewModel, FunctionPower>()); ViewBag.List = list; FunctionPower functionPower = new FunctionPower { AppInfoID = ID.Value }; return(View(functionPower)); }