using 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;
|
}
|
}
|
}
|
}
|