RepositoryExtension.MallGoods.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Data;
  2. using System.Threading.Tasks;
  3. using Wicture.DbRESTFul;
  4. using Wicture.DbRESTFul.Infrastructure.Repository;
  5. using System.Collections.Generic;
  6. using JiaZhiQuan.Common.Models.MallGoodsModel;
  7. namespace JiaZhiQuan.Common
  8. {
  9. public static partial class RepositoryExtension
  10. {
  11. /// <summary>
  12. /// 新增商品变更事件
  13. /// </summary>
  14. /// <param name="conn"></param>
  15. /// <param name="trans"></param>
  16. /// <param name="goodsId">商品id</param>
  17. /// <param name="operatorId">操作人id</param>
  18. /// <param name="operatorType">操作人类型:0 平台 1 买家 2 卖家 3 运营人员 MallGoodsChangeOperatorType 枚举</param>
  19. /// <param name="eventName">事件类型</param>
  20. /// <param name="eventDesc">事件描述</param>
  21. /// <param name="eventType">操作类型(1,创建、编辑2,审核,3,刊登, 4,删除, 5,启用禁用, 6,销售) 枚举MallGoodsChangeEventType</param>
  22. /// <returns></returns>
  23. /// <exception cref="LogicalException"></exception>
  24. public static async Task AddGoodsChangeEvent(this DbRESTFulRepository repository, List<MallGoodsChangeEvent> chages, IDbConnection conn = null, IDbTransaction trans = null)
  25. {
  26. int count = await repository.QuerySingleOrDefaultAsync<int>(@"
  27. insert into mall_goods_change_events(
  28. goodsId,
  29. eventName,
  30. eventDesc,
  31. operatorId,
  32. operatorType,
  33. eventType,
  34. createAt)
  35. values(
  36. @goodsId,
  37. @eventName,
  38. @eventDesc,
  39. @operatorId,
  40. @operatorType,
  41. @eventType,
  42. @createAt);select row_count() as count;",
  43. chages, conn, trans);
  44. if (count > 0) return;
  45. throw new LogicalException("新增商品变更事件失败");
  46. }
  47. }
  48. }