|
|
|
|
|
|
|
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.Authentication.JwtBearer;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
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("获取客户列表")]
|
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
|
|
|
|
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]
|
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
|
|
|
|
[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;
|
|
|
|
}
|
|
|
|
}
|