UserService.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using FuelServer.Core.Entity;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Fuel.Application.Service
  8. {
  9. public class UserService : IUserService
  10. {
  11. private readonly EntityHelper _entityHelper;
  12. public UserService(EntityHelper entityHelper)
  13. {
  14. _entityHelper = entityHelper;
  15. }
  16. public users ValidateCredentials(string username, string password)
  17. {
  18. return _entityHelper.GetEntitiesAsync<users>(_ => _.Account == username && _.Password == password).Result.FirstOrDefault(); ;
  19. }
  20. public async Task<IEnumerable<string>> GetUserPermissions(string userId)
  21. {
  22. // 这里是模拟数据,实际应用中应该从数据库或其他来源获取权限信息
  23. return await Task.FromResult(new List<string>
  24. {
  25. "Admin:Index:GET",
  26. "Admin:Edit:POST"
  27. // 更多权限...
  28. });
  29. }
  30. }
  31. }