From 964a430c977cfc2f539d6b7fab6161827fdd71db Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期五, 12 四月 2024 16:31:53 +0800 Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024 --- Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 113 insertions(+), 0 deletions(-) diff --git a/Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs b/Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs new file mode 100644 index 0000000..550738b --- /dev/null +++ b/Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs @@ -0,0 +1,113 @@ +锘縰sing Rhea.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; + +namespace Tiger.Business +{ + public partial class Biz + { + /// <summary> + /// 瀹㈡埛 + /// </summary> + public partial class MqCustomer : ICustomer + { + /// <summary> + /// 鑾峰彇鍒嗛〉 + /// </summary> + /// <param name="pageList"></param> + /// <returns></returns> + public async Task<ApiAction<PageAble<Customer>>> GetCustomers(PageAble<Customer> pageList) + { + var res = new ApiAction<PageAble<Customer>>(); + try + { + RefAsync<int> total = 0; + pageList.data = await Db.Queryable<Customer>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.CustomerCode.Contains(pageList.sqlcmd)).OrderBy(x=>x.CustomerCode).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); + pageList.totals = total; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鑾峰彇瀹㈡埛淇℃伅寮傚父"); + } + res.Data = pageList; + return res; + } + + /// <summary> + /// 鑾峰彇瀹㈡埛淇℃伅 + /// </summary> + /// <returns></returns> + public async Task<ApiAction<List<Customer>>> GetCustomerInfo() + { + var res = new ApiAction<List<Customer>>(); + try + { + List<Customer> result = await Db.Queryable<Customer>().ToListAsync(); + res.Data = result; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鑾峰彇瀹㈡埛淇℃伅寮傚父"); + } + return res; + } + + public async Task<ApiAction> SaveImportCustomerInfo(List<Customer> list) + { + var res = new ApiAction(); + //鏇存柊瀹㈡埛璁板綍 + var db = Db; + var dbTran = await db.UseTranAsync(async () => + { + await db.Saveable(list).ExecuteCommandAsync(); + }); + if (!dbTran.IsSuccess) + { + res.IsSuccessed = false; + res.Message = $"瀵煎叆寮傚父"; + } + return res; + } + + /// <summary> + /// 淇濆瓨瀹㈡埛 + /// </summary> + /// <param name="user"></param> + /// <returns></returns> + public async Task<ApiAction> SaveCustomer(Customer customer) + { + var result = new ApiAction(); + try + { + + var db = Db; + var dbTran = db.UseTran(() => + { + var y = db.Storageable(customer) + .WhereColumns(t => new { t.CustomerCode }) + .ToStorage(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"瀵煎叆寮傚父"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨瀹㈡埛寮傚父"); + } + return result; + } + } + } +} -- Gitblit v1.9.3