소스 검색

重新提交

storemanagement
zhaoy 10 달 전
부모
커밋
c902174f9f
20개의 변경된 파일850개의 추가작업 그리고 2개의 파일을 삭제
  1. +0
    -1
      .gitignore
  2. +13
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/DeleteOrgInput.cs
  3. +30
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgAddInput.cs
  4. +13
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgListInput.cs
  5. +51
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgOutput.cs
  6. +24
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgPageInput.cs
  7. +62
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgTreeNode.cs
  8. +30
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Organize/UpdateOrgInput.cs
  9. +16
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Role/QueryRoleMenuListDto.cs
  10. +1
    -1
      BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoInput.cs
  11. +40
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoOutput.cs
  12. +22
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoPageInput.cs
  13. +21
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleMenuDtoInput.cs
  14. +20
    -0
      BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs
  15. +2
    -0
      BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
  16. +80
    -0
      BPA.SAAS.Manage.Application/Org/OrganizeServices.cs
  17. +101
    -0
      BPA.SAAS.Manage.Application/Org/RolesServices.cs
  18. +185
    -0
      BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs
  19. +58
    -0
      BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
  20. +81
    -0
      BPA.SAAS.Manage.Comm/Util/ITreeNode.cs

+ 0
- 1
.gitignore 파일 보기

@@ -20,7 +20,6 @@
*.props
/BPA.SAAS.Manage.Web.Entry/obj/Debug/net6.0/BPA.SAAS.Manage.Web.Entry.csproj.AssemblyReference.cache
/BPA.SAAS.Manage.Web.Entry/obj/Debug/net6.0/staticwebassets.build.json
*.cs
/BPA.SAAS.Manage.Web.Core/obj/Debug/net6.0/BPA.SAAS.Manage.Web.Core.csproj.AssemblyReference.cache
/BPA.SAAS.Manage.Web.Entry/obj/Debug/net6.0/apphost.exe
/BPA.SAAS.Manage.Core/BPA.SAAS.Manage.Core.xml


+ 13
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/DeleteOrgInput.cs 파일 보기

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class DeleteOrgInput
{
public string Id { get; set; }
}
}

+ 30
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgAddInput.cs 파일 보기

@@ -0,0 +1,30 @@
using BPA.SAAS.Manage.Comm.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class OrgAddInput
{
/// <summary>
/// 机构名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 上级id
/// </summary>
public string PID { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
public int Sort { get; set; }
}
}

+ 13
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgListInput.cs 파일 보기

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class OrgListInput
{
public string Pid { get; set; }
}
}

+ 51
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgOutput.cs 파일 보기

@@ -0,0 +1,51 @@
using BPA.SAAS.Manage.Comm.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class OrgOutput
{
public string Id { get; set; }
/// <summary>
/// 机构名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 上级id
/// </summary>
public string PID { get; set; }
/// <summary>
/// 类型 默认 机构
/// </summary>
public int Type { get; set; }
/// <summary>
/// 上级ID集合
/// </summary>
public string Pids { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// AutoKey 唯一值
/// </summary>
public string AutoKey { get; set; }
/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 加盟商id
/// </summary>
public string GroupId { get; set; }
public DateTime CreateAt { get; set; }
}
}

+ 24
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgPageInput.cs 파일 보기

@@ -0,0 +1,24 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class OrgPageInput: PageInputBase
{
public string Id { get; set; }

/// <summary>
/// 父Id
/// </summary>
public string Pid { get; set; }

/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
}
}

+ 62
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/OrgTreeNode.cs 파일 보기

@@ -0,0 +1,62 @@
using BPA.SAAS.Manage.Comm.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class OrgTreeNode : ITreeNode
{

public int Type { get; set; }

/// <summary>
/// Id
/// </summary>
public string key { get; set; }

/// <summary>
/// 父Id
/// </summary>
public string parentId { get; set; }

/// <summary>
/// 名称
/// </summary>
public string title { get; set; }

/// <summary>
/// 值
/// </summary>
public string value { get; set; }

/// <summary>
/// 排序,越小优先级越高
/// </summary>
public int weight { get; set; }

/// <summary>
/// 子节点
/// </summary>
public List<OrgTreeNode> Children { get; set; } = new List<OrgTreeNode>();


public string GetId()
{
return key;
}

public string GetPid()
{
return parentId;
}

public void SetChildren(IList children)
{
Children = (List<OrgTreeNode>)children;
}
}
}

+ 30
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Organize/UpdateOrgInput.cs 파일 보기

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Organize
{
public class UpdateOrgInput
{
public string Id { get; set; }
/// <summary>
/// 机构名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 上级id
/// </summary>
public string Pid { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
public int Sort { get; set; }
}
}

+ 16
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Role/QueryRoleMenuListDto.cs 파일 보기

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
{
public class QueryRoleMenuListDto
{
public string Name { get; set; }
public string Id { get; set; }

public bool IsParentMenu { get; set; }
}
}

+ 1
- 1
BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoInput.cs 파일 보기

@@ -20,7 +20,7 @@ namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
/// <summary>
/// 排序
/// </summary>
public string Sort { get; set; }
public int Sort { get; set; }
/// <summary>
/// 备注
/// </summary>


+ 40
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoOutput.cs 파일 보기

@@ -0,0 +1,40 @@
using BPA.SAAS.Manage.Comm.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
{
public class RoleDtoOutput
{
public string Id { get; set; }
// <summary>
/// 角色名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 角色类型-集团角色_0、加盟商角色_1、门店角色_2
/// </summary>
public int RoleType { get; set; }
public DateTime? CreateAt { get; set; }
/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
public CommonStatus Status { get; set; }

}
}

+ 22
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoPageInput.cs 파일 보기

@@ -0,0 +1,22 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
{
public class RoleDtoPageInput: PageInputBase
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }

/// <summary>
/// 编码
/// </summary>
public string Code { get; set; }
}
}

+ 21
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleMenuDtoInput.cs 파일 보기

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
{
public class RoleMenuDtoInput
{
/// <summary>
/// 角色Id
/// </summary>
public string SysRoleId { get; set; }

/// <summary>
/// 菜单Id
/// </summary>
public List<string> SysMenuId { get; set; }
}
}

+ 20
- 0
BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs 파일 보기

@@ -0,0 +1,20 @@
using BPA.SAAS.Manage.Application.Org.Dtos.Organize;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org.Interface
{
public interface IOrganizeService
{
Task<PageUtil> QueryOrgPageList(OrgPageInput input);
Task<List<OrgOutput>> GetOrgList(OrgListInput input);
Task<bool> AddOrg(OrgAddInput input);
Task<bool> DeleteOrg(DeleteOrgInput input);
Task<bool> UpdateOrg(UpdateOrgInput input);
Task<dynamic> GetOrgTree();
}
}

+ 2
- 0
BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs 파일 보기

@@ -12,6 +12,8 @@ namespace BPA.SAAS.Manage.Application.Org.Interface
{
Task<PageUtil> Page(RoleDtoPageInput input);
Task<bool> Add(RoleDtoInput input);
Task<bool> Update(RoleDtoInput input);
Task<bool> Delete(List<string> input);
Task<List<QueryRoleMenuListDto>> GetMenuRole(string RoleId);
Task<bool> AddOrUpdateMenuRole(RoleMenuDtoInput input);
Task<bool> Disable(string Id);


+ 80
- 0
BPA.SAAS.Manage.Application/Org/OrganizeServices.cs 파일 보기

@@ -0,0 +1,80 @@
using BPA.SAAS.Manage.Application.Org.Dtos.Organize;
using BPA.SAAS.Manage.Application.Org.Interface;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org
{
[ApiDescriptionSettings("Org", Tag = "组织机构管理")]
public class OrganizeServices: IDynamicApiController
{
IOrganizeService _organizeService;
public OrganizeServices(IOrganizeService organizeService)
{
_organizeService=organizeService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/organize/page")]
public async Task<PageUtil> QueryOrgPageList([FromBody]OrgPageInput input)
{
return await _organizeService.QueryOrgPageList(input);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/organize/getorglist")]
public async Task<List<OrgOutput>> GetOrgList(OrgListInput input)
{
return await _organizeService.GetOrgList(input);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/organize/addorg")]
public async Task<bool> AddOrg(OrgAddInput input)
{
return await _organizeService.AddOrg(input);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/organize/deleteorg")]
public async Task<bool> DeleteOrg(DeleteOrgInput input)
{
return await _organizeService.DeleteOrg(input);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/organize/updateorg")]
public async Task<bool> UpdateOrg(UpdateOrgInput input)
{
return await _organizeService.UpdateOrg(input);
}
/// <summary>
/// 获取组织机构树
/// </summary>
/// <returns></returns>
[HttpGet("/api/organize/tree")]
public async Task<dynamic> GetOrgTree()
{
return await _organizeService.GetOrgTree();
}
}
}

+ 101
- 0
BPA.SAAS.Manage.Application/Org/RolesServices.cs 파일 보기

@@ -0,0 +1,101 @@
using BPA.SAAS.Manage.Application.Org.Dtos.Role;
using BPA.SAAS.Manage.Application.Org.Interface;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org
{
[ApiDescriptionSettings("SYS", Tag = "角色信息")]
public class RolesServices: IDynamicApiController
{
IRoleService _roleService;
public RolesServices(IRoleService roleService)
{
_roleService=roleService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/roles/page")]
public async Task<PageUtil> Page(RoleDtoPageInput input)
{
return await _roleService.Page(input);
}
/// <summary>
/// 根据角色查询角色菜单
/// </summary>
/// <param name="RoleId"></param>
/// <returns></returns>
[HttpGet("/api/roles/getmenurole")]
public async Task<List<QueryRoleMenuListDto>> GetMenuRole(string RoleId)
{
return await _roleService.GetMenuRole(RoleId);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/roles/add")]
public async Task<bool> Add(RoleDtoInput input)
{
return await _roleService.Add(input);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/roles/update")]
public async Task<bool> Update(RoleDtoInput input)
{
return await _roleService.Update(input);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/roles/delete")]
public async Task<bool> Delete(List<string> input)
{
return await _roleService.Delete(input);
}
/// <summary>
/// 编辑角色菜单
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/roles/addorupdatemenurole")]
public async Task<bool> AddOrUpdateMenuRole(RoleMenuDtoInput input)
{
return await _roleService.AddOrUpdateMenuRole(input);
}
/// <summary>
/// 启用
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/roles/enable")]
public async Task<bool> Enable(string Id)
{
return await _roleService.Enable(Id);
}
/// <summary>
/// 禁用
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/roles/disable")]
public async Task<bool> Disable(string Id)
{
return await _roleService.Disable(Id);
}
}
}

+ 185
- 0
BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs 파일 보기

@@ -0,0 +1,185 @@
using BPA.SAAS.Manage.Application.Org.Dtos.Organize;
using BPA.SAAS.Manage.Application.Org.Interface;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Comm.Util;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Org;
using Furion.DatabaseAccessor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace BPA.SAAS.Manage.Application.Org.Services
{
public class OrganizeService : IOrganizeService, ITransient
{
private readonly ISqlSugarClient _db;
public OrganizeService(ISqlSugarClient db)
{
_db = db;
}
/// <summary>
/// 分页获取组织机构列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PageUtil> QueryOrgPageList(OrgPageInput input)
{
RefAsync<int> total = 0;
var name = !string.IsNullOrEmpty(input.Name?.Trim());
var id = !string.IsNullOrEmpty(input.Id?.Trim());
var pId = !string.IsNullOrEmpty(input.Pid?.Trim());
var data = await _db.Queryable<BPA_Organize>()
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Pid), u => u.Pids.Contains(input.Pid.Trim()) || u.Id == input.Pid.Trim())
.Select<OrgOutput>()
.OrderBy(a => a.CreateAt, OrderByType.Asc)
.ToPageListAsync(input.Current, input.PageSize, total);
PageUtil util = new PageUtil()
{
Total = total,
Data = data

};
return util;
}
/// <summary>
/// 获取组织机构列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<List<OrgOutput>> GetOrgList(OrgListInput input)
{
var pId = !string.IsNullOrEmpty(input.Pid?.Trim());
var orgs = await _db.Queryable<BPA_Organize>()
.WhereIF(pId, u => u.PID == input.Pid)
.Where(u => u.Status != CommonStatus.DELETED).ToListAsync();
return orgs.Adapt<List<OrgOutput>>();
}
/// <summary>
/// 新增组织
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> AddOrg(OrgAddInput input)
{
if (!string.IsNullOrEmpty(input.Tel))
{
var tel = Regex.IsMatch(input.Tel, "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
if (tel == false) throw Oops.Oh("手机号错误");
}
var sysOrg = input.Adapt<BPA_Organize>();
await FillPids(sysOrg);
return await _db.Insertable(sysOrg).CallEntityMethod(m => m.Create()).ExecuteCommandAsync()>0;
}
/// <summary>
/// 删除组织机构
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> DeleteOrg(DeleteOrgInput input)
{
var sysOrg = await _db.Queryable<BPA_Organize>().FirstAsync(u => u.Id == input.Id);
// 级联删除子节点
var childIdList = await GetChildIdListWithSelfById(sysOrg.Id);
var orgs = await _db.Queryable<BPA_Organize>().Where(u => childIdList.Contains(u.Id)).ToListAsync();
return await _db.Deleteable(orgs).ExecuteCommandAsync()>0;
}

/// <summary>
/// 更新组织机构
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> UpdateOrg(UpdateOrgInput input)
{
if (input.Pid != Guid.Empty.ToString() && !string.IsNullOrEmpty(input.Pid) && input.Pid != "0")
{
var org = await _db.Queryable<BPA_Organize>().FirstAsync(u => u.Id == input.Pid);
_ = org ?? throw Oops.Oh("父机构不存在");
}

if (!string.IsNullOrEmpty(input.Tel))
{
var tel = Regex.IsMatch(input.Tel, "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
if (tel == false) throw Oops.Oh("手机号错误");
}

if (input.Id == input.Pid)
throw Oops.Oh("当前机构Id不能与父机构Id相同");

// 如果是编辑,父id不能为自己的子节点
var childIdListById = await GetChildIdListWithSelfById(input.Id);
if (childIdListById.Contains(input.Pid))
throw Oops.Oh("当前机构Id不能与父机构Id相同");

var sysOrg = await _db.Queryable<BPA_Organize>().FirstAsync(u => u.Id == input.Id);
sysOrg.Name=input.Name;
sysOrg.Tel = input.Tel;
sysOrg.Remark = input.Remark;
sysOrg.Sort= input.Sort;
await FillPids(sysOrg);
return await _db.Updateable(sysOrg).IgnoreColumns(ignoreAllNullColumns: true)
.ExecuteCommandAsync()>0;
}
/// <summary>
/// 获取组织机构树
/// </summary>
/// <returns></returns>
public async Task<dynamic> GetOrgTree()
{
var dataScopeList = new List<string>();
var orgs = await _db.Queryable<BPA_Organize>().WhereIF(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id))
.Where(u => u.Status == CommonStatus.ENABLE).OrderBy(u => u.Sort)
.Select(u => new OrgTreeNode
{
key = u.Id,
parentId = u.PID,
title = u.Name,
value = u.Id.ToString(),
weight = u.Sort,
Type = u.Type,
}).ToListAsync();

return new TreeBuildUtil<OrgTreeNode>().Build(orgs);

}
/// <summary>
/// 填充父Ids字段
/// </summary>
/// <param name="sysOrg"></param>
/// <returns></returns>
private async Task FillPids(BPA_Organize sysOrg)
{
if (string.IsNullOrWhiteSpace(sysOrg.PID) || sysOrg.PID == "0")
{
sysOrg.Pids = "[0],";
sysOrg.PID = "0";
}
else
{
var t = await _db.Queryable<BPA_Organize>().FirstAsync(u => u.Id == sysOrg.PID);
sysOrg.Pids = t.Pids + "[" + t.Id + "],";
}
}
/// <summary>
/// 根据节点Id获取所有子节点Id集合,包含自己
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
private async Task<List<string>> GetChildIdListWithSelfById(string id)
{
var childIdList = await _db.Queryable<BPA_Organize>()
.Where(u => u.Pids.Contains(id.ToString()))
.Select(u => u.Id).ToListAsync();
childIdList.Add(id);
return childIdList;
}
}
}

+ 58
- 0
BPA.SAAS.Manage.Application/Org/Services/RoleService.cs 파일 보기

@@ -48,6 +48,11 @@ namespace BPA.SAAS.Manage.Application.Org.Services
};
return util;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> Add(RoleDtoInput input)
{

@@ -64,6 +69,59 @@ namespace BPA.SAAS.Manage.Application.Org.Services
return await _db.Insertable(role).CallEntityMethod(t => t.Create()).ExecuteCommandAsync() > 0;
}
/// <summary>
/// 修改
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> Update(RoleDtoInput input)
{
var BPA_Roles = await _db.Queryable<BPA_Roles>().Where(a => a.Code == input.Code).FirstAsync();
var code = BPA_Roles.Code;
if (code != input.Code)
{
throw Oops.Oh("角色编码不能进行修改");
}
var Roles = await _db.Queryable<BPA_Roles>().Where(a => a.Id == input.Id).FirstAsync();
Roles.Name= input.Name;
Roles.Code= input.Code;
Roles.Remark= input.Remark;
Roles.Sort = input.Sort;
return _db.Updateable(Roles).ExecuteCommandHasChange();

}
/// <summary>
/// 删除
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> Delete(List<string> input)
{
try
{
_db.Ado.BeginTran();
// 查询数据库中是否存在未删除的活动信息
var resEntitites = _db.Queryable<BPA_Roles>().In(input).ToList();
var ids = resEntitites.Select(a => a.Id).ToArray();
//校验用户
var dara = _db.Queryable<BPA_UserRole>().Where(x => ids.Contains(x.SysRoleId)).ToList();
if (dara.Count() <= 0)
{
var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync();
_db.Ado.CommitTran();
return res > 0;
}
else
{
throw Oops.Oh("删除失败, 请检查用户是否关联该角色");
}
}
catch (Exception)
{
_db.Ado.RollbackTran();
throw Oops.Oh("删除失败");
}
}
/// <summary>
/// 根据角色查询角色菜单
/// </summary>
/// <param name="RoleId"></param>


+ 81
- 0
BPA.SAAS.Manage.Comm/Util/ITreeNode.cs 파일 보기

@@ -0,0 +1,81 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Comm.Util
{
/// <summary>
/// 树基类
/// </summary>
public interface ITreeNode
{
/// <summary>
/// 获取节点id
/// </summary>
/// <returns></returns>
string GetId();

/// <summary>
/// 获取节点父id
/// </summary>
/// <returns></returns>
string GetPid();

/// <summary>
/// 设置Children
/// </summary>
/// <param name="children"></param>
void SetChildren(IList children);
}
/// <summary>
/// 递归工具类,用于遍历有父子关系的节点,例如菜单树,字典树等等
/// </summary>
/// <typeparam name="T"></typeparam>
public class TreeBuildUtil<T> where T : ITreeNode
{
/// <summary>
/// 顶级节点的父节点Id(默认00000000-0000-0000-0000-000000000000)
/// </summary>
private readonly string _rootParentId = "0";

/// <summary>
/// 构造树节点
/// </summary>
/// <param name="nodes"></param>
/// <returns></returns>
public List<T> Build(List<T> nodes)
{
nodes.ForEach(u => BuildChildNodes(nodes, u, new List<T>()));

var result = new List<T>();
nodes.ForEach(u =>
{
if (_rootParentId == u.GetPid())
result.Add(u);
});
return result;
}

/// <summary>
/// 构造子节点集合
/// </summary>
/// <param name="totalNodes"></param>
/// <param name="node"></param>
/// <param name="childNodeList"></param>
private void BuildChildNodes(List<T> totalNodes, T node, List<T> childNodeList)
{
var nodeSubList = new List<T>();
totalNodes.ForEach(u =>
{
if (u.GetPid().Equals(node.GetId()))
nodeSubList.Add(u);
});
nodeSubList.ForEach(u => BuildChildNodes(totalNodes, u, new List<T>()));
childNodeList.AddRange(nodeSubList);
node.SetChildren(childNodeList);
}
}
}

불러오는 중...
취소
저장