You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.7 KiB
54 lines
1.7 KiB
|
|
using System.ComponentModel;
|
|
using Admin.Bodk.Customer.Modules;
|
|
using Admin.NET.Core;
|
|
using Furion.DatabaseAccessor;
|
|
using Furion.DependencyInjection;
|
|
using Furion.DynamicApiController;
|
|
using Furion.FriendlyException;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
|
|
namespace Admin.Bodk.Customer;
|
|
/// <summary>
|
|
/// 设备管理服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Order = 2)]
|
|
public class CustomerService: IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<Entities.Customer> _customer;
|
|
public CustomerService(SqlSugarRepository<Entities.Customer> customer)
|
|
{
|
|
_customer = customer;
|
|
}
|
|
/// <summary>
|
|
/// 获取客户列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[DisplayName("获取客户列表")]
|
|
public async Task<SqlSugarPagedList<Entities.Customer>> PostCustomerList(CustomerInput input)
|
|
{
|
|
return await _customer.AsQueryable()
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Name),
|
|
m => m.Name != null && m.Name.Contains(input.Name))
|
|
.ToPagedListAsync(input.Page, input.PageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加客户
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[UnitOfWork]
|
|
[ApiDescriptionSettings(Name = "Add"), HttpPost]
|
|
[DisplayName("增加客户")]
|
|
public async Task<long> AddCustomer(CustomerDot input)
|
|
{
|
|
if(input is null) throw Oops.Oh("参数不能为空");
|
|
var customer = input.Adapt<Entities.Customer>();
|
|
var newEquipment = await _customer.AsInsertable(customer).ExecuteReturnEntityAsync();
|
|
return newEquipment.Id;
|
|
}
|
|
}
|