From 494238f351cc9fe2aeca63f5c895bf43e617d884 Mon Sep 17 00:00:00 2001 From: lwh <2679599887@qq.com> Date: Sun, 18 Jun 2023 16:34:30 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=88=9D=E5=A7=8B=E5=8C=96=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=9C=8D=E5=8A=A1=E4=B8=8E=E6=89=BF=E8=AF=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GoodsServicess/GoodsServicesDto.cs | 67 +++++++++ .../GoodsServicess/GoodsServices.cs | 98 +++++++++++++ .../GoodsServicess/GoodsServicesVo.cs | 83 +++++++++++ .../GoodsServicess/GoodsServicesRepository.cs | 20 +++ .../GoodsServicess/GoodsServicesService.cs | 110 +++++++++++++++ .../GoodsServicess/IGoodsServicesService.cs | 45 ++++++ .../GoodsServicess/GoodsServicesController.cs | 132 ++++++++++++++++++ 7 files changed, 555 insertions(+) create mode 100644 ARW.Model/Dto/Business/GoodsManager/GoodsServicess/GoodsServicesDto.cs create mode 100644 ARW.Model/Models/Business/GoodsManager/GoodsServicess/GoodsServices.cs create mode 100644 ARW.Model/Vo/Business/GoodsManager/GoodsServicess/GoodsServicesVo.cs create mode 100644 ARW.Repository/Business/GoodsManager/GoodsServicess/GoodsServicesRepository.cs create mode 100644 ARW.Service/Business/BusinessService/GoodsManager/GoodsServicess/GoodsServicesService.cs create mode 100644 ARW.Service/Business/IBusinessService/GoodsManager/GoodsServicess/IGoodsServicesService.cs create mode 100644 ARW.WebApi/Controllers/Business/GoodsManager/GoodsServicess/GoodsServicesController.cs diff --git a/ARW.Model/Dto/Business/GoodsManager/GoodsServicess/GoodsServicesDto.cs b/ARW.Model/Dto/Business/GoodsManager/GoodsServicess/GoodsServicesDto.cs new file mode 100644 index 0000000..646a8db --- /dev/null +++ b/ARW.Model/Dto/Business/GoodsManager/GoodsServicess/GoodsServicesDto.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.GoodsManager.GoodsServicess; + +namespace ARW.Model.Dto.Business.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺输入对象 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + public class GoodsServicesDto + { + + public int GoodsServicesId { get; set; } + + public long GoodsServicesGuid { get; set; } + + [Required(ErrorMessage = "店铺guid不能为空")] + public long ShopGuid { get; set; } + + [Required(ErrorMessage = "服务名称不能为空")] + public string GoodsServicesName { get; set; } + + public string GoodsServicesSummary { get; set; } + + [Required(ErrorMessage = "是否默认不能为空")] + public int GoodsServicesIsDefault { get; set; } + + [Required(ErrorMessage = "显示状态不能为空")] + public int GoodsServicesDisplayStatus { get; set; } + + [Required(ErrorMessage = "排序不能为空")] + public int GoodsServicesSort { get; set; } + + + + + + } + + + /// + /// 商品服务与承诺查询对象 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + public class GoodsServicesQueryDto : PagerInfo + { + + public string ShopName { get; set; } + public string GoodsServicesName { get; set; } + + public int? GoodsServicesIsDefault { get; set; } + + public int? GoodsServicesDisplayStatus { get; set; } + + public string ids { get; set; } + } + + + + +} diff --git a/ARW.Model/Models/Business/GoodsManager/GoodsServicess/GoodsServices.cs b/ARW.Model/Models/Business/GoodsManager/GoodsServicess/GoodsServices.cs new file mode 100644 index 0000000..083746e --- /dev/null +++ b/ARW.Model/Models/Business/GoodsManager/GoodsServicess/GoodsServices.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; +using Newtonsoft.Json; + +namespace ARW.Model.Models.Business.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺,数据实体对象 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + [SugarTable("tb_goods_services")] + public class GoodsServices : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "GoodsServicesId")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_services_id")] + public int GoodsServicesId { get; set; } + + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "GoodsServicesGuid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_services_guid")] + public long GoodsServicesGuid { get; set; } + + + /// + /// 描述 :店铺guid + /// 空值 : false + /// + [EpplusTableColumn(Header = "店铺guid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "shop_guid")] + public long ShopGuid { get; set; } + + + /// + /// 描述 :服务名称 + /// 空值 : false + /// + [EpplusTableColumn(Header = "服务名称")] + [SugarColumn(ColumnName = "goods_services_name")] + public string GoodsServicesName { get; set; } + + + /// + /// 描述 :概述 + /// 空值 : true + /// + [EpplusTableColumn(Header = "概述")] + [SugarColumn(ColumnName = "goods_services_summary")] + public string GoodsServicesSummary { get; set; } + + + /// + /// 描述 :是否默认 + /// 空值 : false + /// + [EpplusTableColumn(Header = "是否默认")] + [SugarColumn(ColumnName = "goods_services_is_default")] + public int GoodsServicesIsDefault { get; set; } + + + /// + /// 描述 :显示状态 + /// 空值 : false + /// + [EpplusTableColumn(Header = "显示状态")] + [SugarColumn(ColumnName = "goods_services_display_status")] + public int GoodsServicesDisplayStatus { get; set; } + + + /// + /// 描述 :排序 + /// 空值 : false + /// + [EpplusTableColumn(Header = "排序")] + [SugarColumn(ColumnName = "goods_services_sort")] + public int GoodsServicesSort { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/Vo/Business/GoodsManager/GoodsServicess/GoodsServicesVo.cs b/ARW.Model/Vo/Business/GoodsManager/GoodsServicess/GoodsServicesVo.cs new file mode 100644 index 0000000..f8515fd --- /dev/null +++ b/ARW.Model/Vo/Business/GoodsManager/GoodsServicess/GoodsServicesVo.cs @@ -0,0 +1,83 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺展示对象 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + public class GoodsServicesVo + { + + + /// + /// 描述 : + /// + [EpplusIgnore] + public int GoodsServicesId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long GoodsServicesGuid { get; set; } + + + /// + /// 描述 :店铺 + /// + [EpplusTableColumn(Header = "店铺")] + public string ShopName { get; set; } + + /// + /// 描述 :店铺guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long ShopGuid { get; set; } + + + /// + /// 描述 :服务名称 + /// + [EpplusTableColumn(Header = "服务名称")] + public string GoodsServicesName { get; set; } + + + /// + /// 描述 :概述 + /// + [EpplusIgnore] + [EpplusTableColumn(Header = "服务概述")] + public string GoodsServicesSummary { get; set; } + + + /// + /// 描述 :是否默认 + /// + [EpplusTableColumn(Header = "是否默认")] + public int GoodsServicesIsDefault { get; set; } + + + /// + /// 描述 :显示状态 + /// + [EpplusTableColumn(Header = "显示状态")] + public int GoodsServicesDisplayStatus { get; set; } + + + /// + /// 描述 :排序 + /// + [EpplusTableColumn(Header = "排序")] + public int GoodsServicesSort { get; set; } + + } +} diff --git a/ARW.Repository/Business/GoodsManager/GoodsServicess/GoodsServicesRepository.cs b/ARW.Repository/Business/GoodsManager/GoodsServicess/GoodsServicesRepository.cs new file mode 100644 index 0000000..3d12456 --- /dev/null +++ b/ARW.Repository/Business/GoodsManager/GoodsServicess/GoodsServicesRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ARW.Repository.System; +using ARW.Model.Models.Business.GoodsManager.GoodsServicess; + +namespace ARW.Repository.Business.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺仓储 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class GoodsServicesRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Business/BusinessService/GoodsManager/GoodsServicess/GoodsServicesService.cs b/ARW.Service/Business/BusinessService/GoodsManager/GoodsServicess/GoodsServicesService.cs new file mode 100644 index 0000000..9273afc --- /dev/null +++ b/ARW.Service/Business/BusinessService/GoodsManager/GoodsServicess/GoodsServicesService.cs @@ -0,0 +1,110 @@ +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.GoodsManager.GoodsServicess; +using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess; +using ARW.Model.Dto.Business.GoodsManager.GoodsServicess; +using ARW.Model.Models.Business.GoodsManager.GoodsServicess; +using ARW.Model.Vo.Business.GoodsManager.GoodsServicess; +using ARW.Model.Models.Business.ShopManager.Shops; + +namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺接口实现类 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + [AppService(ServiceType = typeof(IGoodsServicesService), ServiceLifetime = LifeTime.Transient)] + public class GoodsServicesServiceImpl : BaseService, IGoodsServicesService + { + private readonly GoodsServicesRepository _GoodsServicesRepository; + + public GoodsServicesServiceImpl(GoodsServicesRepository GoodsServicesRepository) + { + this._GoodsServicesRepository = GoodsServicesRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询商品服务与承诺分页列表 + /// + public async Task> GetGoodsServicesList(GoodsServicesQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsServicesName), s => s.GoodsServicesName.Contains(parm.GoodsServicesName)); + predicate = predicate.AndIF(parm.GoodsServicesIsDefault != null, s => s.GoodsServicesIsDefault == parm.GoodsServicesIsDefault); + predicate = predicate.AndIF(parm.GoodsServicesDisplayStatus != null, s => s.GoodsServicesDisplayStatus == parm.GoodsServicesDisplayStatus); + var query = _GoodsServicesRepository + .Queryable() + .LeftJoin((s,c) => s.ShopGuid == c.ShopGuid) + .Where(predicate.ToExpression()) + .WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s,c) => c.ShopName.Contains(parm.ShopName)) + .OrderBy(s => s.GoodsServicesSort, OrderByType.Asc) + .Select((s,c) => new GoodsServicesVo + { + ShopName = c.ShopName, + GoodsServicesId = s.GoodsServicesId, + GoodsServicesGuid = s.GoodsServicesGuid, + ShopGuid = s.ShopGuid, + GoodsServicesName = s.GoodsServicesName, + GoodsServicesSummary = s.GoodsServicesSummary, + GoodsServicesIsDefault = s.GoodsServicesIsDefault, + GoodsServicesDisplayStatus = s.GoodsServicesDisplayStatus, + GoodsServicesSort = s.GoodsServicesSort, + }); + + + return await query.ToPageAsync(parm); + } + + /// + /// 添加或修改商品服务与承诺 + /// + public async Task AddOrUpdateGoodsServices(GoodsServices model) + { + if (model.GoodsServicesId != 0) + { + var response = await _GoodsServicesRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + + var response = await _GoodsServicesRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + #region Excel处理 + + + /// + /// Excel数据导出处理 + /// + public async Task> HandleExportData(List data) + { + return data; + } + + #endregion + + + + #endregion + + } +} diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/GoodsServicess/IGoodsServicesService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/GoodsServicess/IGoodsServicesService.cs new file mode 100644 index 0000000..351c8fd --- /dev/null +++ b/ARW.Service/Business/IBusinessService/GoodsManager/GoodsServicess/IGoodsServicesService.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Business.GoodsManager.GoodsServicess; +using ARW.Model.Models.Business.GoodsManager.GoodsServicess; +using ARW.Model.Vo.Business.GoodsManager.GoodsServicess; + +namespace ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺接口类 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + public interface IGoodsServicesService : IBaseService + { + /// + /// 获取商品服务与承诺分页列表 + /// + /// + /// + Task> GetGoodsServicesList(GoodsServicesQueryDto parm); + + + /// + /// 添加或修改商品服务与承诺 + /// + /// + /// + Task AddOrUpdateGoodsServices(GoodsServices parm); + + + + /// + /// Excel导出 + /// + Task> HandleExportData(List data); + + + } +} diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/GoodsServicess/GoodsServicesController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/GoodsServicess/GoodsServicesController.cs new file mode 100644 index 0000000..ed093a5 --- /dev/null +++ b/ARW.WebApi/Controllers/Business/GoodsManager/GoodsServicess/GoodsServicesController.cs @@ -0,0 +1,132 @@ +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.Model.Dto.Business.GoodsManager.GoodsServicess; +using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Models.Business.GoodsManager.GoodsServicess; +using ARW.Model.Vo.Business.GoodsManager.GoodsServicess; +using Microsoft.AspNetCore.Authorization; +using ARW.Admin.WebApi.Framework; + + +namespace ARW.WebApi.Controllers.Business.GoodsManager.GoodsServicess +{ + /// + /// 商品服务与承诺控制器 + /// + /// @author 黎文豪 + /// @date 2023-06-18 + /// + [Verify] + [Route("business/[controller]")] + public class GoodsServicesController : BaseController + { + private readonly IGoodsServicesService _GoodsServicesService; + + /// + /// 依赖注入 + /// + /// 商品服务与承诺服务 + public GoodsServicesController(IGoodsServicesService GoodsServicesService) + { + _GoodsServicesService = GoodsServicesService; + } + + + /// + /// 获取商品服务与承诺列表 + /// + /// 查询参数 + /// + [HttpGet("getGoodsServicesList")] + [ActionPermissionFilter(Permission = "business:goodsservices:list")] + public async Task GetGoodsServicesList([FromQuery] GoodsServicesQueryDto parm) + { + var res = await _GoodsServicesService.GetGoodsServicesList(parm); + return SUCCESS(res); + } + + /// + /// 添加或修改商品服务与承诺 + /// + /// + /// + [HttpPost("addOrUpdateGoodsServices")] + [ActionPermissionFilter(Permission = "business:goodsservices:addOrUpdate")] + [Log(Title = "添加或修改商品服务与承诺", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateGoodsServices([FromBody] GoodsServicesDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new GoodsServices(); + if (parm.GoodsServicesId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _GoodsServicesService.AddOrUpdateGoodsServices(modal); + return SUCCESS(res); + } + + /// + /// 删除商品服务与承诺 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:goodsservices:delete")] + [Log(Title = "商品服务与承诺删除", BusinessType = BusinessType.DELETE)] + public IActionResult Delete(string ids) + { + long[] idsArr = Tools.SpitLongArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + var response = _GoodsServicesService.Delete(idsArr); + return SUCCESS("删除成功!"); + } + + + /// + /// 导出商品服务与承诺 + /// + /// + [Log(Title = "商品服务与承诺导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [HttpGet("exportGoodsServices")] + [ActionPermissionFilter(Permission = "business:goodsservices:export")] + public async Task ExportExcel([FromQuery] GoodsServicesQueryDto parm) + { + parm.PageSize = 10000; + var list = await _GoodsServicesService.GetGoodsServicesList(parm); + var data = list.Result; + + // 选中数据 + if (!string.IsNullOrEmpty(parm.ids)) + { + int[] idsArr = Tools.SpitIntArrary(parm.ids); + var selectDataList = new List(); + foreach (var item in idsArr) + { + var select_data = data.Where(s => s.GoodsServicesId == item).First(); + selectDataList.Add(select_data); + } + data = selectDataList; + } + + + + // 导出数据处理 + var handleData = await _GoodsServicesService.HandleExportData(data); + + string sFileName = ExportExcel(handleData, "GoodsServices", "商品服务与承诺列表"); + return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); + } + + + + + } +}