shgx_tz_mom/ZR.Repository/System/SysDeptRepository.cs

49 lines
1.5 KiB
C#
Raw Normal View History

2021-08-23 16:57:25 +08:00
using Infrastructure.Attribute;
using System.Collections.Generic;
using ZR.Model.System;
namespace ZR.Repository.System
{
/// <summary>
/// 部门管理
/// </summary>
2021-12-25 12:05:30 +08:00
[AppService(ServiceLifetime = LifeTime.Transient)]
2021-09-27 08:06:09 +08:00
public class SysDeptRepository : BaseRepository<SysDept>
2021-08-23 16:57:25 +08:00
{
/// <summary>
///
/// </summary>
/// <param name="deptId"></param>
/// <returns></returns>
public List<SysDept> SelectChildrenDeptById(long deptId)
{
string sql = "select * from sys_dept where find_in_set(@deptId, ancestors)";
2021-09-27 08:06:09 +08:00
return Context.SqlQueryable<SysDept>(sql).AddParameters(new { @deptId = deptId }).ToList();
2021-08-23 16:57:25 +08:00
}
2021-12-25 12:05:30 +08:00
public int UdateDeptChildren(List<SysDept> dept)
2021-08-23 16:57:25 +08:00
{
2021-12-25 12:05:30 +08:00
return Context.Updateable(dept).WhereColumns(f => new { f.DeptId })
.UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
2021-08-23 16:57:25 +08:00
}
}
2022-01-22 20:47:48 +08:00
/// <summary>
/// 角色部门
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysRoleDeptRepository : BaseRepository<SysRoleDept>
{
/// <summary>
/// 根据角色获取菜单id
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
public List<SysRoleDept> SelectRoleDeptByRoleId(long roleId)
{
return Context.Queryable<SysRoleDept>().Where(it => it.RoleId == roleId).ToList();
}
}
2021-08-23 16:57:25 +08:00
}