90 lines
3.0 KiB
C#
90 lines
3.0 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.Advertisement.SearchRecommends;
|
|
using ARW.Service.Api.IBusinessService.Advertisement.SearchRecommends;
|
|
using ARW.Model.Dto.Api.Advertisement.SearchRecommends;
|
|
using ARW.Model.Models.Business.Advertisement.SearchRecommends;
|
|
using ARW.Model.Vo.Api.Advertisement.SearchRecommends;
|
|
|
|
namespace ARW.Service.Api.BusinessService.Advertisement.SearchRecommends
|
|
{
|
|
/// <summary>
|
|
/// 搜索推荐接口实现类Api
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-10-25
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(ISearchRecommendServiceApi), ServiceLifetime = LifeTime.Transient)]
|
|
public class SearchRecommendServiceImplApi : BaseService<SearchRecommend>, ISearchRecommendServiceApi
|
|
{
|
|
private readonly SearchRecommendRepository _SearchRecommendRepository;
|
|
|
|
public SearchRecommendServiceImplApi(SearchRecommendRepository SearchRecommendRepository)
|
|
{
|
|
this._SearchRecommendRepository = SearchRecommendRepository;
|
|
}
|
|
|
|
#region Api接口代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询搜索推荐列表(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<SearchRecommendVoApi>> GetSearchRecommendListApi(SearchRecommendQueryDtoApi parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<SearchRecommend>();
|
|
|
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.SearchRecommendTitle), s => s.SearchRecommendTitle.Contains(parm.SearchRecommendTitle));
|
|
var query = _SearchRecommendRepository
|
|
.Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.SearchRecommendSort, OrderByType.Asc)
|
|
.Select(s => new SearchRecommendVoApi
|
|
{
|
|
Title = s.SearchRecommendTitle,
|
|
});
|
|
|
|
|
|
return await query.ToListAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询搜索推荐详情(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public async Task<string> GetSearchRecommendDetails(SearchRecommendDtoApi parm)
|
|
{
|
|
|
|
var query = _SearchRecommendRepository
|
|
.Queryable()
|
|
.Where(s => s.SearchRecommendGuid == parm.SearchRecommendGuid)
|
|
.Select(s => new SearchRecommendApiDetailsVo
|
|
{
|
|
SearchRecommendId = s.SearchRecommendId,
|
|
SearchRecommendGuid = s.SearchRecommendGuid,
|
|
SearchRecommendTitle = s.SearchRecommendTitle,
|
|
SearchRecommendSort = s.SearchRecommendSort,
|
|
}).Take(1);
|
|
|
|
|
|
return await query.ToJsonAsync();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|