From aa54d99b47bf8fb5b6773a7b504d673737e3a57c Mon Sep 17 00:00:00 2001 From: lwh <2679599887@qq.com> Date: Mon, 19 Jun 2023 21:47:38 +0800 Subject: [PATCH] =?UTF-8?q?init=20=E5=88=9D=E5=A7=8B=E5=8C=96=E8=A7=84?= =?UTF-8?q?=E6=A0=BC=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GoodsManager/GoodsSpecs/Specs/SpecDto.cs | 44 +++++++++ .../GoodsManager/GoodsSpecs/Specs/Spec.cs | 40 ++++++++ .../GoodsManager/GoodsSpecs/Specs/SpecVo.cs | 30 ++++++ .../Business/GoodsManager/Goodss/GoodsVo.cs | 8 +- .../GoodsSpecs/Specs/SpecRepository.cs | 20 ++++ .../GoodsSpecs/Specs/SpecService.cs | 89 +++++++++++++++++ .../GoodsManager/Goodss/GoodsService.cs | 5 +- .../GoodsSpecs/Specs/ISpecService.cs | 41 ++++++++ .../GoodsSpecs/Specs/SpecController.cs | 99 +++++++++++++++++++ .../ShopGoodsCategoryController.cs | 1 + 10 files changed, 375 insertions(+), 2 deletions(-) create mode 100644 ARW.Model/Dto/Business/GoodsManager/GoodsSpecs/Specs/SpecDto.cs create mode 100644 ARW.Model/Models/Business/GoodsManager/GoodsSpecs/Specs/Spec.cs create mode 100644 ARW.Model/Vo/Business/GoodsManager/GoodsSpecs/Specs/SpecVo.cs create mode 100644 ARW.Repository/Business/GoodsManager/GoodsSpecs/Specs/SpecRepository.cs create mode 100644 ARW.Service/Business/BusinessService/GoodsManager/GoodsSpecs/Specs/SpecService.cs create mode 100644 ARW.Service/Business/IBusinessService/GoodsManager/GoodsSpecs/Specs/ISpecService.cs create mode 100644 ARW.WebApi/Controllers/Business/GoodsManager/GoodsSpecs/Specs/SpecController.cs diff --git a/ARW.Model/Dto/Business/GoodsManager/GoodsSpecs/Specs/SpecDto.cs b/ARW.Model/Dto/Business/GoodsManager/GoodsSpecs/Specs/SpecDto.cs new file mode 100644 index 0000000..5ec1eae --- /dev/null +++ b/ARW.Model/Dto/Business/GoodsManager/GoodsSpecs/Specs/SpecDto.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.Specs; + +namespace ARW.Model.Dto.Business.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组输入对象 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + public class SpecDto + { + + public int SpecId { get; set; } + + [Required(ErrorMessage = "规格值名称不能为空")] + public string SpecName { get; set; } + + + + + + } + + + /// + /// 商品规格组查询对象 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + public class SpecQueryDto : PagerInfo + { + + public string ids { get; set; } + } + + + + +} diff --git a/ARW.Model/Models/Business/GoodsManager/GoodsSpecs/Specs/Spec.cs b/ARW.Model/Models/Business/GoodsManager/GoodsSpecs/Specs/Spec.cs new file mode 100644 index 0000000..a715ec2 --- /dev/null +++ b/ARW.Model/Models/Business/GoodsManager/GoodsSpecs/Specs/Spec.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; +using Newtonsoft.Json; + +namespace ARW.Model.Models.Business.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组,数据实体对象 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + [SugarTable("tb_spec")] + public class Spec : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "spec_id")] + public int SpecId { get; set; } + + + /// + /// 描述 :规格值名称 + /// 空值 : false + /// + [SugarColumn(ColumnName = "spec_name")] + public string SpecName { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/Vo/Business/GoodsManager/GoodsSpecs/Specs/SpecVo.cs b/ARW.Model/Vo/Business/GoodsManager/GoodsSpecs/Specs/SpecVo.cs new file mode 100644 index 0000000..9af06e2 --- /dev/null +++ b/ARW.Model/Vo/Business/GoodsManager/GoodsSpecs/Specs/SpecVo.cs @@ -0,0 +1,30 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组展示对象 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + public class SpecVo + { + + + /// + /// 描述 : + /// + public int SpecId { get; set; } + + + /// + /// 描述 :规格值名称 + /// + public string SpecName { get; set; } + + } +} diff --git a/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs b/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs index d87a469..42c93ef 100644 --- a/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs +++ b/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs @@ -34,9 +34,15 @@ namespace ARW.Model.Vo.Business.GoodsManager.Goodss /// 描述 :店铺guid /// [JsonConverter(typeof(ValueToStringConverter))] - [EpplusTableColumn(Header = "店铺guid")] + [EpplusIgnore] public long ShopGuid { get; set; } + /// + /// 描述 :店铺名称 + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "店铺名称")] + public string ShopName { get; set; } /// /// 描述 :商品类目guid diff --git a/ARW.Repository/Business/GoodsManager/GoodsSpecs/Specs/SpecRepository.cs b/ARW.Repository/Business/GoodsManager/GoodsSpecs/Specs/SpecRepository.cs new file mode 100644 index 0000000..88c20bb --- /dev/null +++ b/ARW.Repository/Business/GoodsManager/GoodsSpecs/Specs/SpecRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ARW.Repository.System; +using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.Specs; + +namespace ARW.Repository.Business.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组仓储 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class SpecRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Business/BusinessService/GoodsManager/GoodsSpecs/Specs/SpecService.cs b/ARW.Service/Business/BusinessService/GoodsManager/GoodsSpecs/Specs/SpecService.cs new file mode 100644 index 0000000..43f6b49 --- /dev/null +++ b/ARW.Service/Business/BusinessService/GoodsManager/GoodsSpecs/Specs/SpecService.cs @@ -0,0 +1,89 @@ +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.GoodsSpecs.Specs; +using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.Specs; +using ARW.Model.Dto.Business.GoodsManager.GoodsSpecs.Specs; +using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.Specs; +using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.Specs; + +namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组接口实现类 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + [AppService(ServiceType = typeof(ISpecService), ServiceLifetime = LifeTime.Transient)] + public class SpecServiceImpl : BaseService, ISpecService + { + private readonly SpecRepository _SpecRepository; + + public SpecServiceImpl(SpecRepository SpecRepository) + { + this._SpecRepository = SpecRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询商品规格组分页列表 + /// + public async Task> GetSpecList(SpecQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + var query = _SpecRepository + .Queryable() + .Where(predicate.ToExpression()) + .OrderBy(s => s.Create_time,OrderByType.Desc) + .Select(s => new SpecVo + { + SpecId = s.SpecId, + SpecName = s.SpecName, + }); + + + return await query.ToPageAsync(parm); + } + + /// + /// 添加或修改商品规格组 + /// + public async Task AddOrUpdateSpec(Spec model) + { + if (model.SpecId != 0) + { + var response = await _SpecRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + + var response = await _SpecRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + #region Excel处理 + + + #endregion + + + +#endregion + + } +} diff --git a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs index d3602d9..f3e3df4 100644 --- a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs +++ b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs @@ -14,6 +14,7 @@ using ARW.Service.Business.IBusinessService.GoodsManager.Goodss; using ARW.Model.Dto.Business.GoodsManager.Goodss; using ARW.Model.Models.Business.GoodsManager.Goodss; using ARW.Model.Vo.Business.GoodsManager.Goodss; +using ARW.Model.Models.Business.ShopManager.Shops; namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss { @@ -50,13 +51,15 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsCoding), s => s.GoodsCoding.Contains(parm.GoodsCoding)); var query = _GoodsRepository .Queryable() + .LeftJoin((s, c) => s.ShopGuid == c.ShopGuid) .Where(predicate.ToExpression()) .OrderBy(s => s.GoodsSort, OrderByType.Asc) - .Select(s => new GoodsVo + .Select((s,c) => new GoodsVo { GoodsId = s.GoodsId, GoodsGuid = s.GoodsGuid, ShopGuid = s.ShopGuid, + ShopName = c.ShopName, GoodsCategoryGuid = s.GoodsCategoryGuid, GoodsSkuGuid = s.GoodsSkuGuid, DeliveryGuid = s.DeliveryGuid, diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/GoodsSpecs/Specs/ISpecService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/GoodsSpecs/Specs/ISpecService.cs new file mode 100644 index 0000000..8c0f861 --- /dev/null +++ b/ARW.Service/Business/IBusinessService/GoodsManager/GoodsSpecs/Specs/ISpecService.cs @@ -0,0 +1,41 @@ +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.GoodsSpecs.Specs; +using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.Specs; +using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.Specs; + +namespace ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组接口类 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + public interface ISpecService : IBaseService + { + /// + /// 获取商品规格组分页列表 + /// + /// + /// + Task> GetSpecList(SpecQueryDto parm); + + + /// + /// 添加或修改商品规格组 + /// + /// + /// + Task AddOrUpdateSpec(Spec parm); + + + + + + } +} diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/GoodsSpecs/Specs/SpecController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/GoodsSpecs/Specs/SpecController.cs new file mode 100644 index 0000000..329eed1 --- /dev/null +++ b/ARW.WebApi/Controllers/Business/GoodsManager/GoodsSpecs/Specs/SpecController.cs @@ -0,0 +1,99 @@ +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.GoodsSpecs.Specs; +using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.Specs; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.Specs; +using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.Specs; +using Microsoft.AspNetCore.Authorization; +using ARW.Admin.WebApi.Framework; + + +namespace ARW.WebApi.Controllers.Business.GoodsManager.GoodsSpecs.Specs +{ + /// + /// 商品规格组控制器 + /// + /// @author 黎文豪 + /// @date 2023-06-19 + /// + [Verify] + [Route("business/[controller]")] + public class SpecController : BaseController + { + private readonly ISpecService _SpecService; + + /// + /// 依赖注入 + /// + /// 商品规格组服务 + public SpecController(ISpecService SpecService) + { + _SpecService = SpecService; + } + + + /// + /// 获取商品规格组列表 + /// + /// 查询参数 + /// + [HttpGet("getSpecList")] + [ActionPermissionFilter(Permission = "business:spec:list")] + public async Task GetSpecList([FromQuery] SpecQueryDto parm) + { + var res = await _SpecService.GetSpecList(parm); + return SUCCESS(res); + } + + + /// + /// 添加或修改商品规格组 + /// + /// + /// + [HttpPost("addOrUpdateSpec")] + [ActionPermissionFilter(Permission = "business:spec:addOrUpdate")] + [Log(Title = "添加或修改商品规格组", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateSpec([FromBody] SpecDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new Spec(); + if (parm.SpecId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _SpecService.AddOrUpdateSpec(modal); + return SUCCESS(res); + } + + /// + /// 删除商品规格组 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:spec: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 = _SpecService.Delete(idsArr); + return SUCCESS("删除成功!"); + } + + + + + + + } +} diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs index ac79545..2cc8742 100644 --- a/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs +++ b/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs @@ -56,6 +56,7 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys var user = JwtUtil.GetLoginUser(App.HttpContext); if (user.UserId != 1) { + var goodsCategoryList = _ShopService.GetFirstGoodsCategoryList(); var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId); if (shop == null) throw new Exception("当前用户没有店铺"); parm.ShopGuid = shop.ShopGuid;