BaseService.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using SqlSugar;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using ZR.Common;
  5. using ZR.Repository;
  6. namespace ZR.Service
  7. {
  8. /// <summary>
  9. /// 基础服务定义
  10. /// </summary>
  11. /// <typeparam name="T"></typeparam>
  12. public class BaseService<T> : BaseRepository<T> where T : class, new()
  13. {
  14. //public IBaseRepository<T> baseRepository;
  15. //public BaseService(IBaseRepository<T> repository)
  16. //{
  17. // this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository));
  18. //}
  19. #region 获取序列号
  20. private readonly object LockDbFlag = new object();
  21. public object GetSequenceNo(string SqCode)
  22. {
  23. lock (LockDbFlag)
  24. {
  25. SugarParameter parameter1 = new("seq_code", SqCode)
  26. {
  27. Direction = ParameterDirection.Input,
  28. };
  29. SugarParameter parameter2 = new("count_num", 1)
  30. {
  31. Direction = ParameterDirection.Input,
  32. };
  33. SugarParameter parameter3 = new("out_id", default)
  34. {
  35. Direction = ParameterDirection.Output,
  36. };
  37. var RetVal = UseStoredProcedureToTuple("sys_proc_get_sequences", new List<SugarParameter> { parameter1, parameter2 , parameter3 });
  38. return parameter3.Value;
  39. }
  40. }
  41. #endregion
  42. }
  43. }