emoticon_api/ARW.Service/Api/BusinessService/Settings/PlatformSpecs/PlatformSpecServiceApi.cs
2023-10-22 15:26:27 +08:00

95 lines
3.2 KiB
C#

using Infrastructure.Attribute;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model;
using ARW.Repository;
using ARW.Repository.Business.Settings.PlatformSpecs;
using ARW.Service.Api.IBusinessService.Settings.PlatformSpecs;
using ARW.Model.Dto.Api.Settings.PlatformSpecs;
using ARW.Model.Models.Business.Settings.PlatformSpecs;
using ARW.Model.Vo.Api.Settings.PlatformSpecs;
namespace ARW.Service.Api.BusinessService.Settings.PlatformSpecs
{
/// <summary>
/// 平台资质与规范接口实现类Api
///
/// @author lwh
/// @date 2023-10-22
/// </summary>
[AppService(ServiceType = typeof(IPlatformSpecServiceApi), ServiceLifetime = LifeTime.Transient)]
public class PlatformSpecServiceImplApi : BaseService<PlatformSpec>, IPlatformSpecServiceApi
{
private readonly PlatformSpecRepository _PlatformSpecRepository;
public PlatformSpecServiceImplApi(PlatformSpecRepository PlatformSpecRepository)
{
this._PlatformSpecRepository = PlatformSpecRepository;
}
#region Api接口代码
/// <summary>
/// 查询平台资质与规范列表(Api)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public async Task<List<PlatformSpecVoApi>> GetPlatformSpecListApi(PlatformSpecQueryDtoApi parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create<PlatformSpec>();
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.PlatformSpecTitle), s => s.PlatformSpecTitle.Contains(parm.PlatformSpecTitle));
var query = _PlatformSpecRepository
.Queryable()
.Where(predicate.ToExpression())
.OrderBy(s => s.PlatformSpecSort, OrderByType.Asc)
.Select(s => new PlatformSpecVoApi
{
PlatformSpecId = s.PlatformSpecId,
PlatformSpecGuid = s.PlatformSpecGuid,
PlatformSpecTitle = s.PlatformSpecTitle,
PlatformSpecContent = s.PlatformSpecContent,
PlatformSpecSort = s.PlatformSpecSort,
});
return await query.ToListAsync();
}
/// <summary>
/// 查询平台资质与规范详情(Api)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public async Task<string> GetPlatformSpecDetails(PlatformSpecDtoApi parm)
{
var query = _PlatformSpecRepository
.Queryable()
.Where(s => s.PlatformSpecGuid == parm.PlatformSpecGuid)
.Select(s => new PlatformSpecApiDetailsVo
{
PlatformSpecId = s.PlatformSpecId,
PlatformSpecGuid = s.PlatformSpecGuid,
PlatformSpecTitle = s.PlatformSpecTitle,
PlatformSpecContent = s.PlatformSpecContent,
PlatformSpecSort = s.PlatformSpecSort,
}).Take(1);
return await query.ToJsonAsync();
}
#endregion
}
}