FunctionCodeService.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Bowin.Common.Utility;
  2. using YLShipBuildLandMap.Entity;
  3. using YLShipBuildLandMap.Entity.ViewModel.SystemSetting;
  4. using Microsoft.EntityFrameworkCore;
  5. using Newtonsoft.Json.Linq;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. namespace YLShipBuildLandMap.Services.SystemSetting
  11. {
  12. public class FunctionCodeService : IFunctionCodeService
  13. {
  14. private YLShipBuildLandMapContext DbContext { get; set; }
  15. public FunctionCodeService(YLShipBuildLandMapContext dbContext)
  16. {
  17. DbContext = dbContext;
  18. }
  19. public List<string> GetUserFunctionCodes(Guid userID)
  20. {
  21. var sql = (from u in DbContext.SysUser.Where(x => x.UserId == userID)
  22. from r in u.SysUserSysRole
  23. from rf in r.Role.SysRoleSysFunctionCode
  24. select rf.FunctionCode).Distinct();
  25. return sql.ToList();
  26. }
  27. public List<FunctionCodeView> GetFunctionCodeList()
  28. {
  29. var sql = (from f in DbContext.SysFunctionCode
  30. select new FunctionCodeView {
  31. FunctionCode = f.FunctionCode,
  32. FunctionName = f.FunctionName,
  33. ParentFunctionCode = f.ParentFunctionCode ?? "",
  34. OrderNo = f.OrderNo
  35. });
  36. return sql.OrderBy(x => x.OrderNo).ToList();
  37. }
  38. public List<string> GetRoleFunctionCode(Guid roleID)
  39. {
  40. var sql = (from rf in DbContext.SysRoleSysFunctionCode.Where(x => x.RoleId == roleID)
  41. select rf.FunctionCode);
  42. return sql.ToList();
  43. }
  44. }
  45. }