diff --git a/ARW.Model/Dto/Business/GoodsManager/GoodsCategorys/GoodsCategoryDto.cs b/ARW.Model/Dto/Business/GoodsManager/GoodsCategorys/GoodsCategoryDto.cs
new file mode 100644
index 0000000..62a7521
--- /dev/null
+++ b/ARW.Model/Dto/Business/GoodsManager/GoodsCategorys/GoodsCategoryDto.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
+
+namespace ARW.Model.Dto.Business.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目输入对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ public class GoodsCategoryDto
+ {
+
+ public int GoodsCategoryId { get; set; }
+
+ public long GoodsCategoryGuid { get; set; }
+
+ [Required(ErrorMessage = "父级guid不能为空")]
+ public long GoodsCategoryParentGuid { get; set; }
+
+ public string GoodsCategoryAncestralGuid { get; set; }
+
+ [Required(ErrorMessage = "名称不能为空")]
+ public string GoodsCategoryName { get; set; }
+
+ public string GoodsCategoryImg { get; set; }
+
+ [Required(ErrorMessage = "显示状态不能为空")]
+ public int GoodsCategoryDisplayStatus { get; set; }
+
+ public int? GoodsCategoryIsPopular { get; set; }
+
+ [Required(ErrorMessage = "排序不能为空")]
+ public int ProductCategorySort { get; set; }
+
+
+
+
+
+ }
+
+
+ ///
+ /// 商品类目查询对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ public class GoodsCategoryQueryDto : PagerInfo
+ {
+
+ public string GoodsCategoryName { get; set; }
+
+ public int? GoodsCategoryDisplayStatus { get; set; }
+
+ public int? GoodsCategoryIsPopular { get; set; }
+
+ public string ids { get; set; }
+ }
+
+
+
+
+}
diff --git a/ARW.Model/Models/Business/GoodsManager/GoodsCategorys/GoodsCategory.cs b/ARW.Model/Models/Business/GoodsManager/GoodsCategorys/GoodsCategory.cs
new file mode 100644
index 0000000..edc7980
--- /dev/null
+++ b/ARW.Model/Models/Business/GoodsManager/GoodsCategorys/GoodsCategory.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using SqlSugar;
+using OfficeOpenXml.Attributes;
+using Newtonsoft.Json;
+
+namespace ARW.Model.Models.Business.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目,数据实体对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ [SugarTable("tb_goods_category")]
+ public class GoodsCategory : BusinessBase
+ {
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "GoodsCategoryId")]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_category_id")]
+ public int GoodsCategoryId { get; set; }
+
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "GoodsCategoryGuid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_category_guid")]
+ public long GoodsCategoryGuid { get; set; }
+
+
+ ///
+ /// 描述 :父级guid
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "父级guid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "goods_category_parent_guid")]
+ public long GoodsCategoryParentGuid { get; set; }
+
+
+ ///
+ /// 描述 :祖级guid
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "祖级guid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "goods_category_ancestral_guid")]
+ public string GoodsCategoryAncestralGuid { get; set; }
+
+
+ ///
+ /// 描述 :名称
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "名称")]
+ [SugarColumn(ColumnName = "goods_category_name")]
+ public string GoodsCategoryName { get; set; }
+
+
+ ///
+ /// 描述 :图片
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "图片")]
+ [SugarColumn(ColumnName = "goods_category_img")]
+ public string GoodsCategoryImg { get; set; }
+
+
+ ///
+ /// 描述 :显示状态
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "显示状态")]
+ [SugarColumn(ColumnName = "goods_category_display_status")]
+ public int GoodsCategoryDisplayStatus { get; set; }
+
+
+ ///
+ /// 描述 :是否为热门
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "是否为热门")]
+ [SugarColumn(ColumnName = "goods_category_is_popular")]
+ public int? GoodsCategoryIsPopular { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ [SugarColumn(ColumnName = "product_category_sort")]
+ public int ProductCategorySort { get; set; }
+
+
+
+
+
+
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ [SugarColumn(IsIgnore = true)]
+ public List Children { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ARW.Model/Vo/Business/GoodsManager/GoodsCategorys/GoodsCategoryVo.cs b/ARW.Model/Vo/Business/GoodsManager/GoodsCategorys/GoodsCategoryVo.cs
new file mode 100644
index 0000000..174d7d6
--- /dev/null
+++ b/ARW.Model/Vo/Business/GoodsManager/GoodsCategorys/GoodsCategoryVo.cs
@@ -0,0 +1,94 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
+using System.Collections.Generic;
+
+namespace ARW.Model.Vo.Business.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目展示对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ public class GoodsCategoryVo
+ {
+
+
+ ///
+ /// 描述 :
+ ///
+ [EpplusIgnore]
+ public int GoodsCategoryId { get; set; }
+
+
+ ///
+ /// 描述 :
+ ///
+ [SugarColumn(IsTreeKey = true)]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusIgnore]
+ public long GoodsCategoryGuid { get; set; }
+
+
+ ///
+ /// 描述 :父级guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusTableColumn(Header = "父级guid")]
+ public long GoodsCategoryParentGuid { get; set; }
+
+
+ ///
+ /// 描述 :祖级guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusTableColumn(Header = "祖级guid")]
+ public string GoodsCategoryAncestralGuid { get; set; }
+
+
+ ///
+ /// 描述 :名称
+ ///
+ [EpplusTableColumn(Header = "名称")]
+ public string GoodsCategoryName { get; set; }
+
+
+ ///
+ /// 描述 :图片
+ ///
+ [EpplusIgnore]
+ public string GoodsCategoryImg { get; set; }
+
+
+ ///
+ /// 描述 :显示状态
+ ///
+ [EpplusTableColumn(Header = "显示状态")]
+ public int GoodsCategoryDisplayStatus { get; set; }
+
+
+ ///
+ /// 描述 :是否为热门
+ ///
+ [EpplusIgnore]
+ public int? GoodsCategoryIsPopular { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ public int ProductCategorySort { get; set; }
+
+ [EpplusIgnore]
+ public string ParentName { get; set; }
+
+ [EpplusIgnore]
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ [SugarColumn(IsIgnore = true)]
+ public List Children { get; set; }
+ }
+}
diff --git a/ARW.Repository/Business/GoodsManager/GoodsCategorys/GoodsCategoryRepository.cs b/ARW.Repository/Business/GoodsManager/GoodsCategorys/GoodsCategoryRepository.cs
new file mode 100644
index 0000000..e495de1
--- /dev/null
+++ b/ARW.Repository/Business/GoodsManager/GoodsCategorys/GoodsCategoryRepository.cs
@@ -0,0 +1,20 @@
+using System;
+using Infrastructure.Attribute;
+using ARW.Repository.System;
+using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
+
+namespace ARW.Repository.Business.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目仓储
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ [AppService(ServiceLifetime = LifeTime.Transient)]
+ public class GoodsCategoryRepository : BaseRepository
+ {
+ #region 业务逻辑代码
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/ARW.Service/Business/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryService.cs b/ARW.Service/Business/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryService.cs
new file mode 100644
index 0000000..9471a07
--- /dev/null
+++ b/ARW.Service/Business/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryService.cs
@@ -0,0 +1,152 @@
+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.GoodsCategorys;
+using ARW.Service.Business.IBusinessService.GoodsManager.GoodsCategorys;
+using ARW.Model.Dto.Business.GoodsManager.GoodsCategorys;
+using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
+using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
+
+namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目接口实现类
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ [AppService(ServiceType = typeof(IGoodsCategoryService), ServiceLifetime = LifeTime.Transient)]
+ public class GoodsCategoryServiceImpl : BaseService, IGoodsCategoryService
+ {
+ private readonly GoodsCategoryRepository _GoodsCategoryRepository;
+
+ public GoodsCategoryServiceImpl(GoodsCategoryRepository GoodsCategoryRepository)
+ {
+ this._GoodsCategoryRepository = GoodsCategoryRepository;
+ }
+
+ #region 业务逻辑代码
+
+
+ ///
+ /// 查询商品类目树形列表
+ ///
+ public async Task> GetGoodsCategoryTreeList(GoodsCategoryQueryDto parm)
+ {
+ //开始拼装查询条件
+ var predicate = Expressionable.Create();
+
+ predicate = predicate.AndIF(parm.GoodsCategoryDisplayStatus != null, s => s.GoodsCategoryDisplayStatus == parm.GoodsCategoryDisplayStatus);
+ predicate = predicate.AndIF(parm.GoodsCategoryIsPopular != null, s => s.GoodsCategoryIsPopular == parm.GoodsCategoryIsPopular);
+ var query = _GoodsCategoryRepository
+ .Queryable()
+ .LeftJoin((s, c) => s.GoodsCategoryParentGuid == c.GoodsCategoryGuid)
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.ProductCategorySort, OrderByType.Asc)
+ .Select((s, c) => new GoodsCategoryVo
+ {
+ GoodsCategoryId = s.GoodsCategoryId,
+ GoodsCategoryGuid = s.GoodsCategoryGuid,
+ GoodsCategoryParentGuid = s.GoodsCategoryParentGuid,
+ GoodsCategoryAncestralGuid = s.GoodsCategoryAncestralGuid,
+ GoodsCategoryName = s.GoodsCategoryName,
+ GoodsCategoryImg = s.GoodsCategoryImg,
+ GoodsCategoryDisplayStatus = s.GoodsCategoryDisplayStatus,
+ GoodsCategoryIsPopular = s.GoodsCategoryIsPopular,
+ ProductCategorySort = s.ProductCategorySort,
+ ParentName = c.GoodsCategoryName,
+ });
+
+ return await query.ToTreeAsync(it => it.Children, it => it.GoodsCategoryParentGuid, 0);
+ }
+
+
+ ///
+ /// 查询商品类目列表
+ ///
+ public Task> GetGoodsCategoryList(GoodsCategoryQueryDto parm)
+ {
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+
+ predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsCategoryName), it => it.GoodsCategoryName.Contains(parm.GoodsCategoryName));
+ predicate = predicate.AndIF(parm.GoodsCategoryDisplayStatus != null, it => it.GoodsCategoryDisplayStatus == parm.GoodsCategoryDisplayStatus);
+ predicate = predicate.AndIF(parm.GoodsCategoryIsPopular != null, it => it.GoodsCategoryIsPopular == parm.GoodsCategoryIsPopular);
+ var query = _GoodsCategoryRepository
+ .Queryable()
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.ProductCategorySort, OrderByType.Asc)
+ .Select(s => new GoodsCategoryVo
+ {
+ GoodsCategoryId = s.GoodsCategoryId,
+ GoodsCategoryGuid = s.GoodsCategoryGuid,
+ GoodsCategoryParentGuid = s.GoodsCategoryParentGuid,
+ GoodsCategoryAncestralGuid = s.GoodsCategoryAncestralGuid,
+ GoodsCategoryName = s.GoodsCategoryName,
+ GoodsCategoryImg = s.GoodsCategoryImg,
+ GoodsCategoryDisplayStatus = s.GoodsCategoryDisplayStatus,
+ GoodsCategoryIsPopular = s.GoodsCategoryIsPopular,
+ ProductCategorySort = s.ProductCategorySort,
+ });
+
+
+ return query.ToListAsync();
+ }
+
+ ///
+ /// 添加或修改商品类目
+ ///
+ public async Task AddOrUpdateGoodsCategory(GoodsCategory model)
+ {
+ if (model.GoodsCategoryId != 0)
+ {
+ var type = await _GoodsCategoryRepository.GetListAsync(s => s.GoodsCategoryParentGuid == model.GoodsCategoryGuid);
+ if (type != null)
+ {
+ foreach (var item in type)
+ {
+ if (model.GoodsCategoryParentGuid == item.GoodsCategoryGuid) throw new CustomException("上级菜单不能选择自己的子级!");
+ }
+ }
+ if (model.GoodsCategoryParentGuid == model.GoodsCategoryGuid) throw new CustomException("上级菜单不能选择与当前菜单一样的!");
+ var response = await _GoodsCategoryRepository.UpdateAsync(model);
+ return "修改成功!";
+ }
+ else
+ {
+ var info = _GoodsCategoryRepository.GetFirst(it => it.GoodsCategoryGuid == model.GoodsCategoryParentGuid);
+ model.GoodsCategoryAncestralGuid = "0";
+ if (info != null) model.GoodsCategoryAncestralGuid = info.GoodsCategoryAncestralGuid + "," + model.GoodsCategoryParentGuid;
+
+ var response = await _GoodsCategoryRepository.InsertReturnSnowflakeIdAsync(model);
+ return "添加成功!";
+ }
+ }
+
+ #region Excel处理
+
+
+ ///
+ /// Excel数据导出处理
+ ///
+ public async Task> HandleExportData(List data)
+ {
+ return data;
+ }
+
+ #endregion
+
+
+
+ #endregion
+
+ }
+}
diff --git a/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs b/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs
index df6f047..78ce3d7 100644
--- a/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs
+++ b/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs
@@ -33,13 +33,13 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
this._ShopRepository = ShopRepository;
}
- #region 业务逻辑代码
-
-
- ///
+ #region 业务逻辑代码
+
+
+ ///
/// 查询店铺分页列表
///
- public Task> GetShopList(ShopQueryDto parm)
+ public Task> GetShopList(ShopQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create();
@@ -49,29 +49,29 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
var query = _ShopRepository
.Queryable()
.Where(predicate.ToExpression())
- .OrderBy(s => s.ShopSort,OrderByType.Asc)
+ .OrderBy(s => s.ShopSort, OrderByType.Asc)
.Select(s => new ShopVo
{
- 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,
- });
-
+ 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 query.ToPageAsync(parm);
+
+ return query.ToPageAsync(parm);
}
- ///
+ ///
/// 添加或修改店铺
///
public async Task AddOrUpdateShop(Shop model)
@@ -91,7 +91,7 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
#region Excel处理
-
+
///
/// Excel数据导出处理
///
@@ -101,7 +101,7 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
}
#endregion
-
+
///
/// 审核
@@ -138,7 +138,7 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
}
}
-#endregion
+ #endregion
}
}
diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryService.cs
new file mode 100644
index 0000000..bd055c4
--- /dev/null
+++ b/ARW.Service/Business/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryService.cs
@@ -0,0 +1,52 @@
+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.GoodsCategorys;
+using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
+using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
+
+namespace ARW.Service.Business.IBusinessService.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目接口类
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ public interface IGoodsCategoryService : IBaseService
+ {
+ ///
+ /// 获取商品类目树形列表
+ ///
+ ///
+ ///
+ Task> GetGoodsCategoryTreeList(GoodsCategoryQueryDto parm);
+
+ ///
+ /// 获取商品类目列表
+ ///
+ ///
+ ///
+ Task> GetGoodsCategoryList(GoodsCategoryQueryDto parm);
+
+
+ ///
+ /// 添加或修改商品类目
+ ///
+ ///
+ ///
+ Task AddOrUpdateGoodsCategory(GoodsCategory parm);
+
+
+
+ ///
+ /// Excel导出
+ ///
+ Task> HandleExportData(List data);
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/GoodsCategorys/GoodsCategoryController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/GoodsCategorys/GoodsCategoryController.cs
new file mode 100644
index 0000000..94099fe
--- /dev/null
+++ b/ARW.WebApi/Controllers/Business/GoodsManager/GoodsCategorys/GoodsCategoryController.cs
@@ -0,0 +1,143 @@
+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.GoodsCategorys;
+using ARW.Service.Business.IBusinessService.GoodsManager.GoodsCategorys;
+using ARW.Admin.WebApi.Controllers;
+using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
+using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
+using Microsoft.AspNetCore.Authorization;
+using ARW.Admin.WebApi.Framework;
+
+
+namespace ARW.WebApi.Controllers.Business.GoodsManager.GoodsCategorys
+{
+ ///
+ /// 商品类目控制器
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-12
+ ///
+ [Verify]
+ [Route("business/[controller]")]
+ public class GoodsCategoryController : BaseController
+ {
+ private readonly IGoodsCategoryService _GoodsCategoryService;
+
+ ///
+ /// 依赖注入
+ ///
+ /// 商品类目服务
+ public GoodsCategoryController(IGoodsCategoryService GoodsCategoryService)
+ {
+ _GoodsCategoryService = GoodsCategoryService;
+ }
+
+
+ ///
+ /// 获取商品类目树形列表
+ ///
+ /// 查询参数
+ ///
+ [HttpGet("getGoodsCategoryTreeList")]
+ [ActionPermissionFilter(Permission = "business:goodscategory:treelist")]
+ public async Task GetGoodsCategoryList([FromQuery] GoodsCategoryQueryDto parm)
+ {
+ var res = await _GoodsCategoryService.GetGoodsCategoryTreeList(parm);
+ res ??= new List();
+
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 添加或修改商品类目
+ ///
+ ///
+ ///
+ [HttpPost("addOrUpdateGoodsCategory")]
+ [ActionPermissionFilter(Permission = "business:goodscategory:addOrUpdate")]
+ [Log(Title = "添加或修改商品类目", BusinessType = BusinessType.ADDORUPDATE)]
+ public async Task AddOrUpdateGoodsCategory([FromBody] GoodsCategoryDto parm)
+ {
+ if (parm == null) { throw new CustomException("请求参数错误"); }
+
+ var modal = new GoodsCategory();
+ if (parm.GoodsCategoryId != 0) modal = parm.Adapt().ToUpdate(HttpContext);
+ else modal = parm.Adapt().ToCreate(HttpContext);
+
+ var res = await _GoodsCategoryService.AddOrUpdateGoodsCategory(modal);
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 删除商品类目
+ ///
+ ///
+ [HttpDelete("{ids}")]
+ [ActionPermissionFilter(Permission = "business:goodscategory: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 = _GoodsCategoryService.Delete(idsArr);
+ return SUCCESS("删除成功!");
+ }
+
+
+ ///
+ /// 导出商品类目
+ ///
+ ///
+ [Log(Title = "商品类目导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
+ [HttpGet("exportGoodsCategory")]
+ [ActionPermissionFilter(Permission = "business:goodscategory:export")]
+ public async Task ExportExcel([FromQuery] GoodsCategoryQueryDto parm)
+ {
+ var list = await _GoodsCategoryService.GetGoodsCategoryList(parm);
+ var data = list;
+
+ // 选中数据
+ 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.GoodsCategoryId == item).First();
+ selectDataList.Add(select_data);
+
+ // 查看当前数据有没有子级
+ var newGoodsCategorys = data.FindAll(delegate (GoodsCategoryVo goodsCategory)
+ {
+ string[] parentGoodsCategoryId = goodsCategory.GoodsCategoryAncestralGuid.Split(",", StringSplitOptions.RemoveEmptyEntries);
+ return parentGoodsCategoryId.Contains(select_data.GoodsCategoryGuid.ToString());
+ });
+ string[] goodsCategoryArr = newGoodsCategorys.Select(x => x.GoodsCategoryGuid.ToString()).ToArray();
+ var ancestorArr = data.Where(s => goodsCategoryArr.Contains(s.GoodsCategoryGuid.ToString())).ToList();
+ selectDataList.AddRange(ancestorArr);
+ }
+ data = selectDataList;
+ }
+
+
+
+ // 导出数据处理
+ var handleData = await _GoodsCategoryService.HandleExportData(data);
+
+ string sFileName = ExportExcel(handleData, "GoodsCategory", "商品类目列表");
+ return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
+ }
+
+
+
+
+ }
+}
diff --git a/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt b/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt
index dff3701..1943dba 100644
--- a/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt
+++ b/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt
@@ -394,6 +394,7 @@ function getList() {
}
});
}
+$end
// 多选框选中数据