using System.ComponentModel; using Admin.Bodk.Device.Entities; using Admin.Bodk.Device.Entities.Dto; using Admin.Bodk.Device.Entities.equipment; using Admin.Bodk.Device.Entities.TaskChain; 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.Device.Services; /// /// 基地管理服务 /// [ApiDescriptionSettings(Order = 2)] public class BaseService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _baseRep; private readonly SqlSugarRepository _supportRep; public BaseService(SqlSugarRepository baseRep, SqlSugarRepository supportRep) { _baseRep = baseRep; _supportRep = supportRep; } /// /// 获取基地信息列表 /// /// /// [DisplayName("获取基地信息列表")] [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] public async Task> PostList(BaseInput input) { return await _baseRep.AsQueryable() .Select((u) => new BaseOutput { Id = u.Id, Name = u.Name, Address = u.Address, Longitude =113.88596284379673 , Latitude = 22.961465648223214, Remark = u.Remark, Phone = u.Phone, SupportList =SqlFunc.Subqueryable().Where(tc => tc.BaseId == u.Id).ToList() }) .ToPagedListAsync(input.Page, input.PageSize); } /// /// 增加基地 /// /// /// [UnitOfWork] [ApiDescriptionSettings(Name = "Add"), HttpPost] [DisplayName("增加客户")] public async Task AddCustomer(BaseAddInput input) { if(input is null) throw Oops.Oh("参数不能为空"); var customer = input.Adapt(); var newEquipment = await (_baseRep).AsInsertable(customer).ExecuteReturnEntityAsync(); return newEquipment.Id; } }