feat 添加轮播图接口
This commit is contained in:
parent
efcf747dd9
commit
d708494842
21
ARW.Model/Dto/Api/Advertisement/Banners/BannerApiDto.cs
Normal file
21
ARW.Model/Dto/Api/Advertisement/Banners/BannerApiDto.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Advertisement.Banners;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Advertisement.Banners
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图查询对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-09
|
||||
/// </summary>
|
||||
public class BannerQueryDtoApi : PagerInfo
|
||||
{
|
||||
[Required(ErrorMessage = "轮播图位置不能为空")]
|
||||
public int BannerPosition { get; set; }
|
||||
}
|
||||
|
||||
}
|
36
ARW.Model/Vo/Api/Advertisement/Banners/BannerApiVo.cs
Normal file
36
ARW.Model/Vo/Api/Advertisement/Banners/BannerApiVo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Api.Advertisement.Banners
|
||||
{
|
||||
/// <summary>
|
||||
/// 轮播图展示对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-09
|
||||
/// </summary>
|
||||
public class BannerVoApi
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :位置
|
||||
/// </summary>
|
||||
public int BannerPosition { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :图片
|
||||
/// </summary>
|
||||
public string BannerImg { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
public int BannerSort { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
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.Banners;
|
||||
using ARW.Service.Api.IBusinessService.Advertisement.Banners;
|
||||
using ARW.Model.Dto.Api.Advertisement.Banners;
|
||||
using ARW.Model.Models.Business.Advertisement.Banners;
|
||||
using ARW.Model.Vo.Api.Advertisement.Banners;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.Advertisement.Banners
|
||||
{
|
||||
/// <summary>
|
||||
/// 轮播图接口实现类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-09
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IBannerServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||
public class BannerServiceImplApi : BaseService<Banner>, IBannerServiceApi
|
||||
{
|
||||
private readonly BannerRepository _BannerRepository;
|
||||
|
||||
public BannerServiceImplApi(BannerRepository BannerRepository)
|
||||
{
|
||||
this._BannerRepository = BannerRepository;
|
||||
}
|
||||
|
||||
#region Api接口代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询轮播图列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<BannerVoApi>> GetBannerListApi(BannerQueryDtoApi 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 BannerVoApi
|
||||
{
|
||||
BannerPosition = s.BannerPosition,
|
||||
BannerImg = s.BannerImg,
|
||||
BannerSort = s.BannerSort,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.Advertisement.Banners;
|
||||
using ARW.Model.Models.Business.Advertisement.Banners;
|
||||
using ARW.Model.Vo.Api.Advertisement.Banners;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.Advertisement.Banners
|
||||
{
|
||||
/// <summary>
|
||||
/// 轮播图接口类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-09
|
||||
/// </summary>
|
||||
public interface IBannerServiceApi : IBaseService<Banner>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取轮播图分页列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<BannerVoApi>> GetBannerListApi(BannerQueryDtoApi parm);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -33,13 +33,13 @@ namespace ARW.Service.Business.BusinessService.Advertisement.Banners
|
||||
this._BannerRepository = BannerRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 查询轮播图分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<BannerVo>> GetBannerList(BannerQueryDto parm)
|
||||
public async Task<PagedInfo<BannerVo>> GetBannerList(BannerQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Banner>();
|
||||
@ -48,21 +48,21 @@ namespace ARW.Service.Business.BusinessService.Advertisement.Banners
|
||||
var query = _BannerRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.BannerSort,OrderByType.Asc)
|
||||
.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,
|
||||
});
|
||||
BannerId = s.BannerId,
|
||||
BannerGuid = s.BannerGuid,
|
||||
BannerPosition = s.BannerPosition,
|
||||
BannerImg = s.BannerImg,
|
||||
BannerSort = s.BannerSort,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 添加或修改轮播图
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateBanner(Banner model)
|
||||
@ -87,7 +87,7 @@ namespace ARW.Service.Business.BusinessService.Advertisement.Banners
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ARW.Admin.WebApi.Extensions;
|
||||
using ARW.Admin.WebApi.Filters;
|
||||
using ARW.Common;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Dto.Api.Advertisement.Banners;
|
||||
using ARW.Service.Api.IBusinessService.Advertisement.Banners;
|
||||
using ARW.Model.Models.Business.Advertisement.Banners;
|
||||
using ARW.Model.Vo.Api.Advertisement.Banners;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.Advertisement.Banners
|
||||
{
|
||||
/// <summary>
|
||||
/// 轮播图控制器Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-09
|
||||
/// </summary>
|
||||
//[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class BannerApiController : BaseController
|
||||
{
|
||||
private readonly IBannerServiceApi _BannerServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="BannerServiceApi">轮播图轮播图Api服务</param>
|
||||
public BannerApiController(IBannerServiceApi BannerServiceApi)
|
||||
{
|
||||
_BannerServiceApi = BannerServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取轮播图列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getBannerList")]
|
||||
public async Task<IActionResult> GetBannerListApi([FromQuery] BannerQueryDtoApi parm)
|
||||
{
|
||||
var res = await _BannerServiceApi.GetBannerListApi(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ namespace ARW.WebApi.Controllers.Business.Advertisement.Banners
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new Banner();
|
||||
var modal = new Banner();
|
||||
if (parm.BannerId != 0) modal = parm.Adapt<Banner>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<Banner>().ToCreate(HttpContext);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user