20230201_145_upperpc/InSituLaboratory.Service/RoleService.cs
2024-03-11 13:12:02 +08:00

49 lines
1.3 KiB
C#

using InSituLaboratory.Entities;
using InSituLaboratory.IService;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InSituLaboratory.Service
{
public class RoleService : BaseService, IRoleService
{
public RoleService(DbContext context)
: base(context)
{
}
public bool CheckRoleName(string roleName, int roleId)
{
return this.Query<SysRole>(r =>
r.RoleName == roleName &&
r.RoleId != roleId)
.Count() > 0;
}
public IEnumerable<SysRole> GetRoles(string key)
{
return this.Set<SysRole>()
.Include(r => r.Users)
.Include(r => r.Menus)
.Where(r =>
string.IsNullOrEmpty(key) ||
r.RoleName.Contains(key) ||
r.RoleDesc.Contains(key)
);
//return this.Query<SysRole>(m =>
// string.IsNullOrEmpty(key) ||
// m.RoleName.Contains(key) ||
// m.RoleDesc.Contains(key)
//);
}
}
}