From b5d9841156820cd4a6f34dd9079d204713c8fe49 Mon Sep 17 00:00:00 2001 From: lwh <2679599887@qq.com> Date: Mon, 12 Jun 2023 23:11:25 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=88=9D=E5=A7=8B=E5=8C=96=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/Api/ShopManager/Shops/ShopApiDto.cs | 34 ++++ .../Vo/Api/ShopManager/Shops/ShopApiVo.cs | 153 ++++++++++++++++++ .../ShopManager/Shops/ShopServiceApi.cs | 130 +++++++++++++++ .../ShopManager/Shops/IShopServiceApi.cs | 44 +++++ .../ShopManager/Shops/ShopApiController.cs | 104 ++++++++++++ .../ShopManager/Shops/ShopController.cs | 2 + 6 files changed, 467 insertions(+) create mode 100644 ARW.Model/Dto/Api/ShopManager/Shops/ShopApiDto.cs create mode 100644 ARW.Model/Vo/Api/ShopManager/Shops/ShopApiVo.cs create mode 100644 ARW.Service/Api/BusinessService/ShopManager/Shops/ShopServiceApi.cs create mode 100644 ARW.Service/Api/IBusinessService/ShopManager/Shops/IShopServiceApi.cs create mode 100644 ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs diff --git a/ARW.Model/Dto/Api/ShopManager/Shops/ShopApiDto.cs b/ARW.Model/Dto/Api/ShopManager/Shops/ShopApiDto.cs new file mode 100644 index 0000000..07ca684 --- /dev/null +++ b/ARW.Model/Dto/Api/ShopManager/Shops/ShopApiDto.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.ShopManager.Shops; + +namespace ARW.Model.Dto.Api.ShopManager.Shops +{ + + /// + /// 店铺查询对象Api + /// + /// @author 黎文豪 + /// @date 2023-06-12 + /// + public class ShopQueryDtoApi : PagerInfo + { + public string ShopName { get; set; } + public int? ShopAuditStatus { get; set; } + } + + + /// + /// 店铺详情输入对象Api + /// + /// @author 黎文豪 + /// @date 2023-06-12 + /// + public class ShopDtoApi + { + [Required(ErrorMessage = "ShopGuid不能为空")] + public long ShopGuid { get; set; } + } + +} diff --git a/ARW.Model/Vo/Api/ShopManager/Shops/ShopApiVo.cs b/ARW.Model/Vo/Api/ShopManager/Shops/ShopApiVo.cs new file mode 100644 index 0000000..d1e383c --- /dev/null +++ b/ARW.Model/Vo/Api/ShopManager/Shops/ShopApiVo.cs @@ -0,0 +1,153 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Api.ShopManager.Shops +{ + /// + /// 店铺展示对象Api + /// + /// @author 黎文豪 + /// @date 2023-06-12 + /// + public class ShopVoApi + { + + + /// + /// 描述 : + /// + [EpplusIgnore] + public int ShopId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long ShopGuid { get; set; } + + + /// + /// 描述 :用户id + /// + [EpplusIgnore] + public int? ShopUserId { get; set; } + + + /// + /// 描述 :客户guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long? ShopCustomerGuid { get; set; } + + + /// + /// 描述 :经营类目guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "经营类目guid")] + public long ShopBusinessCategoryGuid { get; set; } + + + /// + /// 描述 :图标 + /// + [EpplusTableColumn(Header = "图标")] + public string ShopLogo { get; set; } + + + /// + /// 描述 :营业执照 + /// + [EpplusTableColumn(Header = "营业执照")] + public string ShopBusinessLicense { get; set; } + + + /// + /// 描述 :名称 + /// + [EpplusTableColumn(Header = "名称")] + public string ShopName { get; set; } + + + /// + /// 描述 :简介 + /// + [EpplusTableColumn(Header = "简介")] + public string ShopIntro { get; set; } + + + /// + /// 描述 :排序 + /// + [EpplusTableColumn(Header = "排序")] + public int ShopSort { get; set; } + + + /// + /// 描述 :销售单量 + /// + [EpplusTableColumn(Header = "销售单量")] + public int ShopSalesOrderCount { get; set; } + + + /// + /// 描述 :审核状态 + /// + [EpplusTableColumn(Header = "审核状态")] + public int ShopAuditStatus { get; set; } + + + /// + /// 描述 :审核人 + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "审核人")] + public long ShopAuditUserGuid { get; set; } + + } + + + /// + /// 店铺详情展示对象Api + /// + public class ShopApiDetailsVo + { + [EpplusIgnore] + public int ShopId { get; set; } + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long ShopGuid { get; set; } + [EpplusIgnore] + public int? ShopUserId { get; set; } + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long? ShopCustomerGuid { get; set; } + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "经营类目guid")] + public long ShopBusinessCategoryGuid { get; set; } + [EpplusTableColumn(Header = "图标")] + public string ShopLogo { get; set; } + [EpplusTableColumn(Header = "营业执照")] + public string ShopBusinessLicense { get; set; } + [EpplusTableColumn(Header = "名称")] + public string ShopName { get; set; } + [EpplusTableColumn(Header = "简介")] + public string ShopIntro { get; set; } + [EpplusTableColumn(Header = "排序")] + public int ShopSort { get; set; } + [EpplusTableColumn(Header = "销售单量")] + public int ShopSalesOrderCount { get; set; } + [EpplusTableColumn(Header = "审核状态")] + public int ShopAuditStatus { get; set; } + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "审核人")] + public long ShopAuditUserGuid { get; set; } + + } + +} diff --git a/ARW.Service/Api/BusinessService/ShopManager/Shops/ShopServiceApi.cs b/ARW.Service/Api/BusinessService/ShopManager/Shops/ShopServiceApi.cs new file mode 100644 index 0000000..abd6e75 --- /dev/null +++ b/ARW.Service/Api/BusinessService/ShopManager/Shops/ShopServiceApi.cs @@ -0,0 +1,130 @@ +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.ShopManager.Shops; +using ARW.Service.Api.IBusinessService.ShopManager.Shops; +using ARW.Model.Dto.Api.ShopManager.Shops; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Api.ShopManager.Shops; + +namespace ARW.Service.Api.BusinessService.ShopManager.Shops +{ + /// + /// 店铺接口实现类Api + /// + /// @author 黎文豪 + /// @date 2023-06-12 + /// + [AppService(ServiceType = typeof(IShopServiceApi), ServiceLifetime = LifeTime.Transient)] + public class ShopServiceImplApi : BaseService, IShopServiceApi + { + private readonly ShopRepository _ShopRepository; + + public ShopServiceImplApi(ShopRepository ShopRepository) + { + this._ShopRepository = ShopRepository; + } + + #region Api接口代码 + + + /// + /// 查询店铺列表(Api) + /// + /// + /// + public async Task> GetShopListApi(ShopQueryDtoApi parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ShopName), it => it.ShopName.Contains(parm.ShopName)); + predicate = predicate.AndIF(parm.ShopAuditStatus != null, it => it.ShopAuditStatus == parm.ShopAuditStatus); + var query = _ShopRepository + .Queryable() + .Where(predicate.ToExpression()) + .OrderBy(s => s.ShopSort, OrderByType.Desc) + .Select(s => new ShopVoApi + { + ShopId = s.ShopId, + ShopGuid = s.ShopGuid, + ShopUserId = s.ShopUserId, + ShopCustomerGuid = s.ShopCustomerGuid, + ShopBusinessCategoryGuid = s.ShopBusinessCategoryGuid, + ShopLogo = s.ShopLogo, + ShopBusinessLicense = s.ShopBusinessLicense, + ShopName = s.ShopName, + ShopIntro = s.ShopIntro, + ShopSort = s.ShopSort, + ShopSalesOrderCount = s.ShopSalesOrderCount, + ShopAuditStatus = s.ShopAuditStatus, + ShopAuditUserGuid = s.ShopAuditUserGuid, + }); + + + return await query.ToPageAsync(parm); + } + + /// + /// 查询店铺详情(Api) + /// + /// + /// + public Task GetShopDetails(ShopDtoApi parm) + { + + var query = _ShopRepository + .Queryable() + .Where(s => s.ShopGuid == parm.ShopGuid) + .Select(s => new ShopApiDetailsVo + { + ShopId = s.ShopId, + ShopGuid = s.ShopGuid, + ShopUserId = s.ShopUserId, + ShopCustomerGuid = s.ShopCustomerGuid, + ShopBusinessCategoryGuid = s.ShopBusinessCategoryGuid, + ShopLogo = s.ShopLogo, + ShopBusinessLicense = s.ShopBusinessLicense, + ShopName = s.ShopName, + ShopIntro = s.ShopIntro, + ShopSort = s.ShopSort, + ShopSalesOrderCount = s.ShopSalesOrderCount, + ShopAuditStatus = s.ShopAuditStatus, + ShopAuditUserGuid = s.ShopAuditUserGuid, + }).Take(1); + + + return query.ToJsonAsync(); + } + + + /// + /// 添加或修改店铺 + /// + public async Task AddOrUpdateShop(Shop model) + { + if (model.ShopId != 0) + { + var response = await _ShopRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + model.ShopAuditStatus = 1; + var response = await _ShopRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + + #endregion + + } +} diff --git a/ARW.Service/Api/IBusinessService/ShopManager/Shops/IShopServiceApi.cs b/ARW.Service/Api/IBusinessService/ShopManager/Shops/IShopServiceApi.cs new file mode 100644 index 0000000..513d7cb --- /dev/null +++ b/ARW.Service/Api/IBusinessService/ShopManager/Shops/IShopServiceApi.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Api.ShopManager.Shops; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Api.ShopManager.Shops; + +namespace ARW.Service.Api.IBusinessService.ShopManager.Shops +{ + /// + /// 店铺接口类Api + /// + /// @author 黎文豪 + /// @date 2023-06-12 + /// + public interface IShopServiceApi : IBaseService + { + /// + /// 获取店铺分页列表(Api) + /// + /// + /// + Task> GetShopListApi(ShopQueryDtoApi parm); + + /// + /// 获取店铺详情(Api) + /// + /// + /// + Task GetShopDetails(ShopDtoApi parm); + + + /// + /// 添加或修改店铺 + /// + /// + /// + Task AddOrUpdateShop(Shop parm); + + } +} diff --git a/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs b/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs new file mode 100644 index 0000000..1f7a593 --- /dev/null +++ b/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs @@ -0,0 +1,104 @@ +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.ShopManager.Shops; +using ARW.Service.Api.IBusinessService.ShopManager.Shops; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Api.ShopManager.Shops; +using Microsoft.AspNetCore.Authorization; +using Geocoding; +using ARW.Model.Dto.Business.ShopManager.Shops; +using ARW.Service.Business.IBusinessService.ShopManager.Shops; + +namespace ARW.WebApi.Controllers.Api.ShopManager.Shops +{ + /// + /// 店铺控制器Api + /// + /// @author 黎文豪 + /// @date 2023-06-12 + /// + [Verify] + [Route("api/[controller]")] + public class ShopApiController : BaseController + { + private readonly IShopServiceApi _ShopServiceApi; + + /// + /// 依赖注入 + /// + /// 店铺店铺Api服务 + public ShopApiController(IShopServiceApi ShopServiceApi) + { + _ShopServiceApi = ShopServiceApi; + } + + + /// + /// 获取店铺列表(Api) + /// + /// 查询参数 + /// + [HttpGet("getShopList")] + public async Task GetShopListApi([FromQuery] ShopQueryDtoApi parm) + { + var res = await _ShopServiceApi.GetShopListApi(parm); + return SUCCESS(res); + } + + + /// + /// 添加或修改店铺 + /// + /// + /// + [HttpPost("addOrUpdateShop")] + [Log(Title = "添加或修改店铺", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateShop([FromBody] ShopDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new Shop(); + if (parm.ShopId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + //var res = await _ShopServiceApi.AddOrUpdateShop(modal); + //return SUCCESS(res); + } + + + /// + /// 获取Shop详情(Api) + /// + /// 查询参数 + /// + [HttpGet("getShopDetails")] + public async Task GetShopDetails([FromQuery] ShopDtoApi parm) + { + //if (parm == null) throw new CustomException("参数错误!"); + + var res = await _ShopServiceApi.GetShopDetails(parm); + + if (res != "[]") + { + res = res.Remove(0, 1); + res = res.Substring(0, res.Length - 1); + var data = res.FromJSON(); + return SUCCESS(data); + } + else + { + return SUCCESS(res); + } + } + + } +} diff --git a/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs b/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs index 0a1d320..4822b4b 100644 --- a/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs +++ b/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs @@ -110,6 +110,8 @@ namespace ARW.WebApi.Controllers.Business.ShopManager.Shops if (parm.ShopId != 0) modal = parm.Adapt().ToUpdate(HttpContext); else modal = parm.Adapt().ToCreate(HttpContext); + modal.ShopAuditStatus = 1; + var res = await _ShopService.AddOrUpdateShop(modal); return SUCCESS(res); }