|
@@ -29,7 +29,7 @@ namespace Services
|
|
|
{
|
|
|
var predicate = Expressionable.Create<SysDept>();
|
|
|
predicate = predicate.And(it => it.DelFlag == "0");
|
|
|
- predicate = predicate.AndIF(dept.DeptName.IfNotEmpty(), it => it.Name.Contains(dept.DeptName));
|
|
|
+ predicate = predicate.AndIF(dept.deptName.IfNotEmpty(), it => it.name.Contains(dept.deptName));
|
|
|
|
|
|
var response = GetList(predicate.ToExpression());
|
|
|
|
|
@@ -43,9 +43,9 @@ namespace Services
|
|
|
/// <returns></returns>
|
|
|
public string CheckDeptNameUnique(SysDept dept)
|
|
|
{
|
|
|
- long deptId = dept.DeptId == 0 ? -1L : dept.DeptId;
|
|
|
- SysDept info = GetFirst(it => it.Name == dept.Name && it.ParentId == dept.ParentId);
|
|
|
- if (info != null && info.DeptId != deptId)
|
|
|
+ long deptId = dept.deptId == 0 ? -1L : dept.deptId;
|
|
|
+ SysDept info = GetFirst(it => it.name == dept.name && it.parentId == dept.parentId);
|
|
|
+ if (info != null && info.deptId != deptId)
|
|
|
{
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
}
|
|
@@ -59,19 +59,20 @@ namespace Services
|
|
|
/// <returns></returns>
|
|
|
public int InsertDept(SysDept dept)
|
|
|
{
|
|
|
- // SysDept info = GetFirst(it => it.DeptId == dept.ParentId);
|
|
|
- // //如果父节点不为正常状态,则不允许新增子节点
|
|
|
- // if (info != null && UserConstants.DEPT_NORMAL != info?.Status)
|
|
|
+ // SysDept info = GetFirst(it => it.deptId == dept.parentId);
|
|
|
+ //如果父节点不为正常状态,则不允许新增子节点
|
|
|
+ // if (info != null && UserConstants.DEPT_NORMAL != info?.status)
|
|
|
// {
|
|
|
// throw new CustomException("部门停用,不允许新增");
|
|
|
// }
|
|
|
- // dept.Ancestors = "";
|
|
|
+ // dept.ancestors = "";
|
|
|
// if (info != null)
|
|
|
// {
|
|
|
- // dept.Ancestors = info.Ancestors + "," + dept.ParentId;
|
|
|
+ // dept.ancestors = info.ancestors + "," + dept.parentId;
|
|
|
// }
|
|
|
- // return Add(dept);
|
|
|
- return 0;
|
|
|
+ dept.CreateTime = DateTime.Now;
|
|
|
+ dept.UpdateTime = DateTime.Now;
|
|
|
+ return Add(dept);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -81,14 +82,15 @@ namespace Services
|
|
|
/// <returns></returns>
|
|
|
public int UpdateDept(SysDept dept)
|
|
|
{
|
|
|
- // SysDept newParentDept = GetFirst(it => it.DeptId == dept.ParentId);
|
|
|
- // SysDept oldDept = GetFirst(m => m.DeptId == dept.DeptId);
|
|
|
+ dept.UpdateTime = DateTime.Now;
|
|
|
+ // SysDept newParentDept = GetFirst(it => it.deptId == dept.parentId);
|
|
|
+ // SysDept oldDept = GetFirst(m => m.deptId == dept.deptId);
|
|
|
// if (newParentDept != null && oldDept != null)
|
|
|
// {
|
|
|
- // string newAncestors = newParentDept.Ancestors + "," + newParentDept.DeptId;
|
|
|
- // string oldAncestors = oldDept.Ancestors;
|
|
|
- // dept.Ancestors = newAncestors;
|
|
|
- // UpdateDeptChildren(dept.DeptId, newAncestors, oldAncestors);
|
|
|
+ // string newAncestors = newParentDept.ancestors + "," + newParentDept.deptId;
|
|
|
+ // string oldAncestors = oldDept.ancestors;
|
|
|
+ // dept.ancestors = newAncestors;
|
|
|
+ // UpdateDeptChildren(dept.deptId, newAncestors, oldAncestors);
|
|
|
// }
|
|
|
// int result = Context.Updateable(dept).ExecuteCommand();
|
|
|
// if (UserConstants.DEPT_NORMAL.Equals(dept.Status) && dept.Ancestors.IfNotEmpty()
|
|
@@ -97,8 +99,8 @@ namespace Services
|
|
|
// // 如果该部门是启用状态,则启用该部门的所有上级部门
|
|
|
// UpdateParentDeptStatusNormal(dept);
|
|
|
// }
|
|
|
- // return result;
|
|
|
- return 0;
|
|
|
+ int result = Update(dept, true);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -122,7 +124,7 @@ namespace Services
|
|
|
/// <param name="oldAncestors">旧的父ID集合</param>
|
|
|
public void UpdateDeptChildren(long deptId, string newAncestors, string oldAncestors)
|
|
|
{
|
|
|
- // List<SysDept> children = GetChildrenDepts(GetSysDepts(new SysDeptQueryDto()), deptId);
|
|
|
+ List<SysDept> children = GetChildrenDepts(GetSysDepts(new SysDeptQueryDto()), deptId);
|
|
|
|
|
|
// foreach (var child in children)
|
|
|
// {
|
|
@@ -161,11 +163,11 @@ namespace Services
|
|
|
public List<SysDept> BuildDeptTree(List<SysDept> depts)
|
|
|
{
|
|
|
List<SysDept> returnList = new List<SysDept>();
|
|
|
- List<long> tempList = depts.Select(f => f.DeptId).ToList();
|
|
|
+ List<long> tempList = depts.Select(f => f.deptId).ToList();
|
|
|
foreach (var dept in depts)
|
|
|
{
|
|
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
|
|
- if (!tempList.Contains(dept.ParentId))
|
|
|
+ if (!tempList.Contains(dept.parentId))
|
|
|
{
|
|
|
RecursionFn(depts, dept);
|
|
|
returnList.Add(dept);
|
|
@@ -221,7 +223,7 @@ namespace Services
|
|
|
/// <returns></returns>
|
|
|
private List<SysDept> GetChildList(List<SysDept> list, SysDept dept)
|
|
|
{
|
|
|
- return list.Where(p => p.ParentId == dept.DeptId).ToList();
|
|
|
+ return list.Where(p => p.parentId == dept.deptId).ToList();
|
|
|
}
|
|
|
|
|
|
#region 角色部门
|