|
@@ -1,4 +1,5 @@
|
|
|
-using FuelServer.Core.Entity;
|
|
|
+using Fuel.Core.Entity;
|
|
|
+using FuelServer.Core.Entity;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -9,23 +10,34 @@ namespace Fuel.Application.Service
|
|
|
{
|
|
|
public class UserService : IUserService
|
|
|
{
|
|
|
- private readonly EntityHelper _entityHelper;
|
|
|
- public UserService(EntityHelper entityHelper)
|
|
|
+ public readonly IFreeSql _fsql;
|
|
|
+ public UserService(IFreeSql fsql)
|
|
|
{
|
|
|
- _entityHelper = entityHelper;
|
|
|
+ _fsql = fsql;
|
|
|
}
|
|
|
public users ValidateCredentials(string username, string password)
|
|
|
{
|
|
|
- return _entityHelper.GetEntitiesAsync<users>(_ => _.Account == username && _.Password == password).Result.FirstOrDefault(); ;
|
|
|
+ return _fsql.Select<users>().Where(_ => _.Account == username && _.Password == password).First();
|
|
|
}
|
|
|
- public async Task<IEnumerable<string>> GetUserPermissions(string userId)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<IEnumerable<string>> GetUserPermissions(int userId = 1)
|
|
|
{
|
|
|
-
|
|
|
- return await Task.FromResult(new List<string>
|
|
|
- {
|
|
|
- "Admin:Index:GET",
|
|
|
- "Admin:Edit:POST"
|
|
|
-
|
|
|
+ var Permission = _fsql.Select<users, AdUserRole,AdRolePermission,AdPermission>()
|
|
|
+ .LeftJoin((a, b, c,d) => a.Id == b.UserId)
|
|
|
+ .LeftJoin((a, b, c, d) => b.RoleId == c.RoleId)
|
|
|
+ .LeftJoin((a, b, c, d) => c.PermissionId == d.Id)
|
|
|
+ .Where((a, b, c, d) => a.Id == userId)
|
|
|
+ .ToList((a, b, c, d) => new { d });
|
|
|
+ var permissionList = new List<string>();
|
|
|
+ foreach (var permission in Permission)
|
|
|
+ {
|
|
|
+ permissionList.Add(permission.d.Code);
|
|
|
+ }
|
|
|
+ return permissionList;
|
|
|
});
|
|
|
}
|
|
|
}
|