MattressJSAuditExcutor.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Data.SqlClient;
  3. using System.Linq;
  4. using JLHHJSvr.BLL;
  5. using JLHHJSvr.Com;
  6. using JLHHJSvr.Com.Model;
  7. using JLHHJSvr.Helper;
  8. using JLHHJSvr.LJException;
  9. using LJLib.DAL.SQL;
  10. using LJLib.Net.SPI.Com;
  11. using LJLib.Net.SPI.Server;
  12. using LJLib.SQLEX;
  13. namespace JLHHJSvr.Excutor
  14. {
  15. internal sealed class MattressJSAuditExcutor : ExcutorBase<MattressJSAuditRequest, MattressJSAuditResponse>
  16. {
  17. protected override void ExcuteInternal(MattressJSAuditRequest request, object state, MattressJSAuditResponse rslt)
  18. {
  19. var tokendata = BllHelper.GetToken(request.token);
  20. if (!request.list.Any())
  21. {
  22. rslt.ErrMsg = "至少提交一条需要审核的记录";
  23. return;
  24. }
  25. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  26. using (var cmd = con.CreateCommand())
  27. {
  28. con.Open();
  29. if (request.type == 1)
  30. {
  31. var power83 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 83);
  32. if (!power83)
  33. {
  34. throw new LJCommonException("你没有审核权限");
  35. }
  36. }
  37. else
  38. {
  39. var power84 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 84);
  40. if (!power84)
  41. {
  42. throw new LJCommonException("你没有撤审权限");
  43. }
  44. }
  45. var mattressHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  46. using (cmd.Transaction = con.BeginTransaction())
  47. {
  48. try
  49. {
  50. foreach (var bill in request.list)
  51. {
  52. if (request.type == 1) mattressHelper.MattressJSAudit(bill.mattressid);
  53. else mattressHelper.MattressJSCancelAudit(bill.mattressid);
  54. }
  55. cmd.Transaction.Commit();
  56. }
  57. catch (Exception e)
  58. {
  59. cmd.Transaction?.Rollback();
  60. rslt.ErrMsg = e.Message;
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }