diff --git a/ARW.Model/Dto/Api/Advertisement/Banners/BannerApiDto.cs b/ARW.Model/Dto/Api/Advertisement/Banners/BannerApiDto.cs
new file mode 100644
index 0000000..c9f10ae
--- /dev/null
+++ b/ARW.Model/Dto/Api/Advertisement/Banners/BannerApiDto.cs
@@ -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
+{
+
+ ///
+ /// 轮播图查询对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class BannerQueryDtoApi : PagerInfo
+ {
+ [Required(ErrorMessage = "轮播图位置不能为空")]
+ public int BannerPosition { get; set; }
+ }
+
+}
diff --git a/ARW.Model/Vo/Api/Advertisement/Banners/BannerApiVo.cs b/ARW.Model/Vo/Api/Advertisement/Banners/BannerApiVo.cs
new file mode 100644
index 0000000..f605bc8
--- /dev/null
+++ b/ARW.Model/Vo/Api/Advertisement/Banners/BannerApiVo.cs
@@ -0,0 +1,36 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+
+namespace ARW.Model.Vo.Api.Advertisement.Banners
+{
+ ///
+ /// 轮播图展示对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class BannerVoApi
+ {
+
+ ///
+ /// 描述 :位置
+ ///
+ public int BannerPosition { get; set; }
+
+
+ ///
+ /// 描述 :图片
+ ///
+ public string BannerImg { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ ///
+ public int BannerSort { get; set; }
+
+ }
+
+}
diff --git a/ARW.Service/Api/BusinessService/Advertisement/Banners/BannerServiceApi.cs b/ARW.Service/Api/BusinessService/Advertisement/Banners/BannerServiceApi.cs
new file mode 100644
index 0000000..bea55ef
--- /dev/null
+++ b/ARW.Service/Api/BusinessService/Advertisement/Banners/BannerServiceApi.cs
@@ -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
+{
+ ///
+ /// 轮播图接口实现类Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ [AppService(ServiceType = typeof(IBannerServiceApi), ServiceLifetime = LifeTime.Transient)]
+ public class BannerServiceImplApi : BaseService, IBannerServiceApi
+ {
+ private readonly BannerRepository _BannerRepository;
+
+ public BannerServiceImplApi(BannerRepository BannerRepository)
+ {
+ this._BannerRepository = BannerRepository;
+ }
+
+ #region Api接口代码
+
+
+ ///
+ /// 查询轮播图列表(Api)
+ ///
+ ///
+ ///
+ public async Task> GetBannerListApi(BannerQueryDtoApi parm)
+ {
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+
+ 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
+
+ }
+}
diff --git a/ARW.Service/Api/IBusinessService/Advertisement/Banners/IBannerServiceApi.cs b/ARW.Service/Api/IBusinessService/Advertisement/Banners/IBannerServiceApi.cs
new file mode 100644
index 0000000..8f848b5
--- /dev/null
+++ b/ARW.Service/Api/IBusinessService/Advertisement/Banners/IBannerServiceApi.cs
@@ -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
+{
+ ///
+ /// 轮播图接口类Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public interface IBannerServiceApi : IBaseService
+ {
+ ///
+ /// 获取轮播图分页列表(Api)
+ ///
+ ///
+ ///
+ Task> GetBannerListApi(BannerQueryDtoApi parm);
+
+
+
+ }
+}
diff --git a/ARW.Service/Business/BusinessService/Advertisement/Banners/BannerService.cs b/ARW.Service/Business/BusinessService/Advertisement/Banners/BannerService.cs
index 4c281b9..04a7ae8 100644
--- a/ARW.Service/Business/BusinessService/Advertisement/Banners/BannerService.cs
+++ b/ARW.Service/Business/BusinessService/Advertisement/Banners/BannerService.cs
@@ -33,13 +33,13 @@ namespace ARW.Service.Business.BusinessService.Advertisement.Banners
this._BannerRepository = BannerRepository;
}
- #region 业务逻辑代码
-
-
- ///
+ #region 业务逻辑代码
+
+
+ ///
/// 查询轮播图分页列表
///
- public async Task> GetBannerList(BannerQueryDto parm)
+ public async Task> GetBannerList(BannerQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create();
@@ -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);
}
- ///
+ ///
/// 添加或修改轮播图
///
public async Task AddOrUpdateBanner(Banner model)
@@ -84,10 +84,10 @@ namespace ARW.Service.Business.BusinessService.Advertisement.Banners
#endregion
-
-#endregion
+
+ #endregion
}
}
diff --git a/ARW.WebApi/Controllers/Api/Advertisement/Banners/BannerApiController.cs b/ARW.WebApi/Controllers/Api/Advertisement/Banners/BannerApiController.cs
new file mode 100644
index 0000000..d716d6b
--- /dev/null
+++ b/ARW.WebApi/Controllers/Api/Advertisement/Banners/BannerApiController.cs
@@ -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
+{
+ ///
+ /// 轮播图控制器Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ //[Verify]
+ [Route("api/[controller]")]
+ public class BannerApiController : BaseController
+ {
+ private readonly IBannerServiceApi _BannerServiceApi;
+
+ ///
+ /// 依赖注入
+ ///
+ /// 轮播图轮播图Api服务
+ public BannerApiController(IBannerServiceApi BannerServiceApi)
+ {
+ _BannerServiceApi = BannerServiceApi;
+ }
+
+
+ ///
+ /// 获取轮播图列表(Api)
+ ///
+ /// 查询参数
+ ///
+ [HttpGet("getBannerList")]
+ public async Task GetBannerListApi([FromQuery] BannerQueryDtoApi parm)
+ {
+ var res = await _BannerServiceApi.GetBannerListApi(parm);
+ return SUCCESS(res);
+ }
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/Business/Advertisement/Banners/BannerController.cs b/ARW.WebApi/Controllers/Business/Advertisement/Banners/BannerController.cs
index fce3807..bcd7a55 100644
--- a/ARW.WebApi/Controllers/Business/Advertisement/Banners/BannerController.cs
+++ b/ARW.WebApi/Controllers/Business/Advertisement/Banners/BannerController.cs
@@ -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().ToUpdate(HttpContext);
else modal = parm.Adapt().ToCreate(HttpContext);
@@ -88,8 +88,8 @@ namespace ARW.WebApi.Controllers.Business.Advertisement.Banners
var response = _BannerService.Delete(idsArr);
return SUCCESS("删除成功!");
}
-
-
+
+