94 lines
2.6 KiB
C#
94 lines
2.6 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 Infrastructure;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.Advertisement.Banners;
|
|
using ARW.Service.Business.IBusinessService.Advertisement.Banners;
|
|
using ARW.Model.Dto.Business.Advertisement.Banners;
|
|
using ARW.Model.Models.Business.Advertisement.Banners;
|
|
using ARW.Model.Vo.Business.Advertisement.Banners;
|
|
|
|
namespace ARW.Service.Business.BusinessService.Advertisement.Banners
|
|
{
|
|
/// <summary>
|
|
/// 轮播图接口实现类
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-10-09
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IBannerService), ServiceLifetime = LifeTime.Transient)]
|
|
public class BannerServiceImpl : BaseService<Banner>, IBannerService
|
|
{
|
|
private readonly BannerRepository _BannerRepository;
|
|
|
|
public BannerServiceImpl(BannerRepository BannerRepository)
|
|
{
|
|
this._BannerRepository = BannerRepository;
|
|
}
|
|
|
|
#region 业务逻辑代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询轮播图分页列表
|
|
/// </summary>
|
|
public async Task<PagedInfo<BannerVo>> GetBannerList(BannerQueryDto parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<Banner>();
|
|
|
|
predicate = predicate.AndIF(parm.BannerPosition != null, s => s.BannerPosition == parm.BannerPosition);
|
|
var query = _BannerRepository
|
|
.Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.BannerSort,OrderByType.Asc)
|
|
.Select(s => new BannerVo
|
|
{
|
|
BannerId = s.BannerId,
|
|
BannerGuid = s.BannerGuid,
|
|
BannerPosition = s.BannerPosition,
|
|
BannerImg = s.BannerImg,
|
|
BannerSort = s.BannerSort,
|
|
});
|
|
|
|
|
|
return await query.ToPageAsync(parm);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改轮播图
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateBanner(Banner model)
|
|
{
|
|
if (model.BannerId != 0)
|
|
{
|
|
var response = await _BannerRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
|
|
var response = await _BannerRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
#region Excel处理
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|