GetDeptExcutor.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using DirectService.Tools;
  7. using JLHHJSvr.BLL;
  8. using JLHHJSvr.Com;
  9. using JLHHJSvr.Com.Model;
  10. using JLHHJSvr.DBA.DBModle;
  11. using JLHHJSvr.LJException;
  12. using LJLib.DAL.SQL;
  13. using LJLib.Net.SPI.Server;
  14. using LJLib.SQLEX;
  15. namespace JLHHJSvr.Excutor
  16. {
  17. internal sealed class GetDeptExcutor : ExcutorBase<GetDeptRequest, GetDeptResponse>
  18. {
  19. protected override void ExcuteInternal(GetDeptRequest request, object state, GetDeptResponse rslt)
  20. {
  21. var tokendata = BllHelper.GetToken(request.token);
  22. if (tokendata == null)
  23. {
  24. rslt.ErrMsg = "会话已经中断,请重新登录";
  25. return;
  26. }
  27. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  28. using (var cmd = con.CreateCommand())
  29. {
  30. con.Open();
  31. rslt.list = new List<u_dept>();
  32. var whereList = new List<string>();
  33. var powerDeptList = UserHelper.getPowerDept(cmd, tokendata.empid);
  34. if(powerDeptList != null && powerDeptList.Count > 0)
  35. {
  36. whereList.Add($"u_dept.deptid IN {ListEx.getString(powerDeptList)}");
  37. } else
  38. {
  39. throw new LJCommonException("该用户没有相关权限部门,请检查!");
  40. }
  41. DbSqlHelper.Select(cmd, "u_dept", null, null, null, 0, 0, rslt.list, null,
  42. "deptid, deptname, profitrate, pricelistid, springtypeid, flag");
  43. }
  44. }
  45. }
  46. }