ACLUserRelation.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Data;
  3. using System.Collections.Generic;
  4. using WMS.Info;
  5. using WMS.Util;
  6. using System.Linq;
  7. using SqlSugar;
  8. namespace WMS.Core
  9. {
  10. /// <summary>
  11. /// 描 述:用户关系
  12. /// </summary>
  13. public class ACLUserRelation
  14. {
  15. public List<ACL_USERITEM> GetUserList(string objectno, EACLObjType eACLObjType)
  16. {
  17. try
  18. {
  19. var getAll8 = SysDbCore.GetDbCtx().Queryable<ACL_USERITEM>().Where(it =>
  20. SqlFunc.Subqueryable<ACL_USERRELATION>().Where(s => s.F_OBJTYPENUM == (int)eACLObjType && s.F_ITEMNO == objectno && s.F_USERNO == it.F_NO).Any()).ToList();
  21. getAll8.ForEach(it =>
  22. {
  23. it.F_PASSWORD = "";
  24. it.F_DATA = "";
  25. });
  26. return getAll8;
  27. }
  28. catch (Exception ex)
  29. {
  30. throw ex;
  31. }
  32. }
  33. public void SaveEntityList(string objectno, EACLObjType eACLObjType,List<string> UserNos)
  34. {
  35. try
  36. {
  37. void action(SqlSugarClient ctx)
  38. {
  39. ctx.Deleteable<ACL_USERRELATION>().Where(it => it.F_OBJTYPENUM == (int)eACLObjType && it.F_ITEMNO == objectno).ExecuteCommand();
  40. if (UserNos != null && UserNos.Count > 0)
  41. {
  42. foreach (string s in UserNos)
  43. {
  44. ctx.Insertable<ACL_USERRELATION>(new ACL_USERRELATION()
  45. {
  46. F_ITEMNO = objectno,
  47. F_NO = Guid.NewGuid().ToString(),
  48. F_OBJTYPENUM = (int)eACLObjType,
  49. F_USERNO = s
  50. }).ExecuteCommand();
  51. }
  52. }
  53. }
  54. SysDbCore.DbTranExec(action);
  55. }
  56. catch (Exception ex)
  57. {
  58. throw ex;
  59. }
  60. }
  61. }
  62. }