diff --git a/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs b/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs
index 7d04610..102ce43 100644
--- a/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs
+++ b/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs
@@ -18,13 +18,11 @@ namespace ARW.Model.Dto.Business.GoodsManager.ShopGoodsCategorys
public long ShopGoodsCategoryGuid { get; set; }
- [Required(ErrorMessage = "店铺guid不能为空")]
public long ShopGuid { get; set; }
- [Required(ErrorMessage = "父级guid不能为空")]
+ [Required(ErrorMessage = "上级类目不能为空")]
public long ShopGoodsCategoryParentGuid { get; set; }
- [Required(ErrorMessage = "祖级guid不能为空")]
public string ShopGoodsCategoryAncestralGuid { get; set; }
[Required(ErrorMessage = "名称不能为空")]
@@ -51,7 +49,8 @@ namespace ARW.Model.Dto.Business.GoodsManager.ShopGoodsCategorys
///
public class ShopGoodsCategoryQueryDto : PagerInfo
{
-
+ public long ShopGuid { get; set;}
+ public string ShopName { get; set; }
public string ShopGoodsCategoryName { get; set; }
public int? ShopGoodsCategoryDisplayStatus { get; set; }
diff --git a/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs b/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs
index 8acd3e7..4b3fa5b 100644
--- a/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs
+++ b/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs
@@ -37,42 +37,60 @@ namespace ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys
/// 描述 :店铺guid
///
[JsonConverter(typeof(ValueToStringConverter))]
- [SugarColumn(IsTreeKey = true)]
- [EpplusTableColumn(Header = "店铺guid")]
+ [EpplusIgnore]
public long ShopGuid { get; set; }
+ ///
+ /// 描述 :店铺名称
+ ///
+ [EpplusTableColumn(Header = "店铺名称")]
+ public string ShopName { get; set; }
+
///
/// 描述 :父级guid
///
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsTreeKey = true)]
- [EpplusTableColumn(Header = "父级guid")]
+ [EpplusIgnore]
public long ShopGoodsCategoryParentGuid { get; set; }
+
+ [EpplusTableColumn(Header = "上级类目")]
+ public string ParentName { get; set; }
+
+
///
/// 描述 :祖级guid
///
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsTreeKey = true)]
- [EpplusTableColumn(Header = "祖级guid")]
+ [EpplusIgnore]
public string ShopGoodsCategoryAncestralGuid { get; set; }
///
/// 描述 :名称
///
- [EpplusTableColumn(Header = "名称")]
+ [EpplusTableColumn(Header = "商品类目名称")]
public string ShopGoodsCategoryName { get; set; }
///
/// 描述 :显示状态
///
- [EpplusTableColumn(Header = "显示状态")]
+ [EpplusIgnore]
public int ShopGoodsCategoryDisplayStatus { get; set; }
+
+ ///
+ /// 描述 :显示状态名称
+ ///
+ [EpplusTableColumn(Header = "显示状态")]
+ public string ShopGoodsCategoryDisplayStatusName { get; set; }
+
+
///
/// 描述 :排序
@@ -80,8 +98,6 @@ namespace ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys
[EpplusTableColumn(Header = "排序")]
public int ShopGoodsCategorySort { get; set; }
- [EpplusIgnore]
- public string ParentName { get; set; }
[EpplusIgnore]
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
diff --git a/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs b/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs
index 864c9c7..e9a5706 100644
--- a/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs
+++ b/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs
@@ -14,6 +14,11 @@ using ARW.Service.Business.IBusinessService.GoodsManager.ShopGoodsCategorys;
using ARW.Model.Dto.Business.GoodsManager.ShopGoodsCategorys;
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
using ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys;
+using ARW.Model.Models.Business.ShopManager.Shops;
+using ARW.Repository.System;
+using ARW.Repository.Business.ShopManager.Shops;
+using Senparc.CO2NET.Extensions;
+using ARW.Model.System;
namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
{
@@ -27,43 +32,51 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
public class ShopGoodsCategoryServiceImpl : BaseService, IShopGoodsCategoryService
{
private readonly ShopGoodsCategoryRepository _ShopGoodsCategoryRepository;
+ private readonly ShopRepository _ShopRepository;
+ private readonly SysDictDataRepository _SysDictDataRepository;
- public ShopGoodsCategoryServiceImpl(ShopGoodsCategoryRepository ShopGoodsCategoryRepository)
+ public ShopGoodsCategoryServiceImpl(ShopGoodsCategoryRepository ShopGoodsCategoryRepository, SysDictDataRepository sysDictDataRepository, ShopRepository shopRepository)
{
this._ShopGoodsCategoryRepository = ShopGoodsCategoryRepository;
+ _SysDictDataRepository = sysDictDataRepository;
+ _ShopRepository = shopRepository;
}
- #region 业务逻辑代码
-
-
- ///
+ #region 业务逻辑代码
+
+
+ ///
/// 查询店铺商品类目树形列表
///
- public async Task> GetShopGoodsCategoryTreeList(ShopGoodsCategoryQueryDto parm)
- {
+ public async Task> GetShopGoodsCategoryTreeList(ShopGoodsCategoryQueryDto parm)
+ {
//开始拼装查询条件
var predicate = Expressionable.Create();
+ predicate = predicate.AndIF(parm.ShopGuid != 0, s => s.ShopGuid == parm.ShopGuid);
predicate = predicate.AndIF(parm.ShopGoodsCategoryDisplayStatus != null, s => s.ShopGoodsCategoryDisplayStatus == parm.ShopGoodsCategoryDisplayStatus);
var query = _ShopGoodsCategoryRepository
.Queryable()
- .LeftJoin((s, c) => s.ShopGoodsCategoryParentGuid == c.ShopGoodsCategoryGuid)
+ .LeftJoin((s, c) => s.ShopGoodsCategoryParentGuid == c.ShopGoodsCategoryGuid)
+ .LeftJoin((s, c, d) => s.ShopGuid == d.ShopGuid)
.Where(predicate.ToExpression())
- .OrderBy(s => s.ShopGoodsCategorySort,OrderByType.Asc)
- .Select((s,c) => new ShopGoodsCategoryVo
+ .WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s, c, d) => d.ShopName.Contains(parm.ShopName))
+ .OrderBy(s => s.ShopGoodsCategorySort, OrderByType.Asc)
+ .Select((s, c, d) => new ShopGoodsCategoryVo
{
- ShopGoodsCategoryId = s.ShopGoodsCategoryId,
- ShopGoodsCategoryGuid = s.ShopGoodsCategoryGuid,
- ShopGuid = s.ShopGuid,
- ShopGoodsCategoryParentGuid = s.ShopGoodsCategoryParentGuid,
- ShopGoodsCategoryAncestralGuid = s.ShopGoodsCategoryAncestralGuid,
- ShopGoodsCategoryName = s.ShopGoodsCategoryName,
- ShopGoodsCategoryDisplayStatus = s.ShopGoodsCategoryDisplayStatus,
- ShopGoodsCategorySort = s.ShopGoodsCategorySort,
- ParentName = c.ShopGoodsCategoryName,
-});
+ ShopGoodsCategoryId = s.ShopGoodsCategoryId,
+ ShopGoodsCategoryGuid = s.ShopGoodsCategoryGuid,
+ ShopGuid = s.ShopGuid,
+ ShopName = d.ShopName,
+ ShopGoodsCategoryParentGuid = s.ShopGoodsCategoryParentGuid,
+ ShopGoodsCategoryAncestralGuid = s.ShopGoodsCategoryAncestralGuid,
+ ShopGoodsCategoryName = s.ShopGoodsCategoryName,
+ ShopGoodsCategoryDisplayStatus = s.ShopGoodsCategoryDisplayStatus,
+ ShopGoodsCategorySort = s.ShopGoodsCategorySort,
+ ParentName = c.ShopGoodsCategoryName,
+ });
- return await query.ToTreeAsync(it => it.Children, it => it.ShopGoodsCategoryParentGuid, 0);
+ return await query.ToTreeAsync(it => it.Children, it => it.ShopGoodsCategoryParentGuid, 0);
}
@@ -75,29 +88,35 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
//开始拼装查询条件d
var predicate = Expressionable.Create();
+ predicate = predicate.AndIF(parm.ShopGuid != 0, s => s.ShopGuid == parm.ShopGuid);
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ShopGoodsCategoryName), s => s.ShopGoodsCategoryName.Contains(parm.ShopGoodsCategoryName));
predicate = predicate.AndIF(parm.ShopGoodsCategoryDisplayStatus != null, s => s.ShopGoodsCategoryDisplayStatus == parm.ShopGoodsCategoryDisplayStatus);
var query = _ShopGoodsCategoryRepository
.Queryable()
+ .LeftJoin((s, c) => s.ShopGoodsCategoryParentGuid == c.ShopGoodsCategoryGuid)
+ .LeftJoin((s, c, d) => s.ShopGuid == d.ShopGuid)
.Where(predicate.ToExpression())
- .OrderBy(s => s.ShopGoodsCategorySort,OrderByType.Asc)
- .Select(s => new ShopGoodsCategoryVo
+ .WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s, c, d) => d.ShopName.Contains(parm.ShopName))
+ .OrderBy(s => s.ShopGoodsCategorySort, OrderByType.Asc)
+ .Select((s, c, d) => new ShopGoodsCategoryVo
{
- ShopGoodsCategoryId = s.ShopGoodsCategoryId,
- ShopGoodsCategoryGuid = s.ShopGoodsCategoryGuid,
- ShopGuid = s.ShopGuid,
- ShopGoodsCategoryParentGuid = s.ShopGoodsCategoryParentGuid,
- ShopGoodsCategoryAncestralGuid = s.ShopGoodsCategoryAncestralGuid,
- ShopGoodsCategoryName = s.ShopGoodsCategoryName,
- ShopGoodsCategoryDisplayStatus = s.ShopGoodsCategoryDisplayStatus,
- ShopGoodsCategorySort = s.ShopGoodsCategorySort,
- });
-
+ ShopGoodsCategoryId = s.ShopGoodsCategoryId,
+ ShopGoodsCategoryGuid = s.ShopGoodsCategoryGuid,
+ ShopGuid = s.ShopGuid,
+ ShopName = d.ShopName,
+ ShopGoodsCategoryParentGuid = s.ShopGoodsCategoryParentGuid,
+ ShopGoodsCategoryAncestralGuid = s.ShopGoodsCategoryAncestralGuid,
+ ShopGoodsCategoryName = s.ShopGoodsCategoryName,
+ ShopGoodsCategoryDisplayStatus = s.ShopGoodsCategoryDisplayStatus,
+ ShopGoodsCategorySort = s.ShopGoodsCategorySort,
+ ParentName = c.ShopGoodsCategoryName,
+ });
- return await query.ToListAsync();
+
+ return await query.ToListAsync();
}
- ///
+ ///
/// 添加或修改店铺商品类目
///
public async Task AddOrUpdateShopGoodsCategory(ShopGoodsCategory model)
@@ -128,30 +147,72 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
}
#region Excel处理
- ///
+ ///
/// 数据导入处理
///
- public async Task HandleImportData(ShopGoodsCategoryVo ShopGoodsCategory)
+ public async Task HandleImportData(ShopGoodsCategoryVo ShopGoodsCategory, long userId, int index)
{
- return ShopGoodsCategory;
+ try
+ {
+ // 店铺名称转Guid
+ var shoper = await _ShopRepository.GetFirstAsync(s => s.ShopName == ShopGoodsCategory.ShopName);
+ if (shoper == null) throw new Exception($"找不到店铺【{ShopGoodsCategory.ShopName}】");
+
+ if (userId != 1)
+ {
+ var shop = await _ShopRepository.GetFirstAsync(s => s.ShopUserId == userId);
+ if (shop == null) throw new Exception("该用户没有店铺");
+ // 店铺是否为自己的
+ if (shop.ShopName != ShopGoodsCategory.ShopName) throw new Exception("只允许添加自己的店铺数据");
+ }
+ ShopGoodsCategory.ShopGuid = shoper.ShopGuid;
+
+
+ // 上级类目名称转guid (本店铺的类目)
+ if (!string.IsNullOrEmpty(ShopGoodsCategory.ParentName))
+ {
+ var category = await _ShopGoodsCategoryRepository.GetFirstAsync(s => s.ShopGoodsCategoryName == ShopGoodsCategory.ParentName && s.ShopGuid == ShopGoodsCategory.ShopGuid);
+ ShopGoodsCategory.ShopGoodsCategoryParentGuid = category.ShopGoodsCategoryGuid;
+ }
+
+ // 显示状态
+ var lable = ShopGoodsCategory.ShopGoodsCategoryDisplayStatusName;
+ ShopGoodsCategory.ShopGoodsCategoryDisplayStatus = Convert.ToInt32(_SysDictDataRepository.GetDictValueByName("display_status", lable));
+
+ return ShopGoodsCategory;
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
}
///
/// Excel导入
///
- public async Task ImportExcel(ShopGoodsCategory ShopGoodsCategory,int index,bool isUpdateSupport,string user)
+ public async Task ImportExcel(ShopGoodsCategoryVo ShopGoodsCategoryVo, int index, bool isUpdateSupport, LoginUser user)
{
try
{
- // 空值判断
- // if (ShopGoodsCategory.ShopGoodsCategoryId == null) throw new CustomException("店铺商品类目不能为空");
+ var category = await HandleImportData(ShopGoodsCategoryVo, user.UserId,index);
+ var ShopGoodsCategory = new ShopGoodsCategory
+ {
+ ShopGoodsCategoryId= category.ShopGoodsCategoryId,
+ ShopGoodsCategoryGuid= category.ShopGoodsCategoryGuid,
+ ShopGuid = category.ShopGuid,
+ ShopGoodsCategoryParentGuid = category.ShopGoodsCategoryParentGuid,
+ ShopGoodsCategoryName = category.ShopGoodsCategoryName,
+ ShopGoodsCategoryDisplayStatus = category.ShopGoodsCategoryDisplayStatus,
+ ShopGoodsCategorySort = category.ShopGoodsCategorySort
+ };
if (isUpdateSupport)
{
// 判断唯一值
var model = await GetFirstAsync(s => s.ShopGoodsCategoryId == ShopGoodsCategory.ShopGoodsCategoryId);
-
+
// 如果为空就新增数据
if (model == null)
{
@@ -160,7 +221,7 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
{
var addRes = await AddOrUpdateShopGoodsCategory(ShopGoodsCategory);
});
- var addStr = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryId}】新增成功!
";
+ var addStr = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryName}】新增成功!
";
return addStr;
}
else
@@ -171,48 +232,53 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
{
ShopGoodsCategory.ShopGoodsCategoryId = model.ShopGoodsCategoryId;
ShopGoodsCategory.ShopGoodsCategoryGuid = model.ShopGoodsCategoryGuid;
- ShopGoodsCategory.Update_by = user;
+ ShopGoodsCategory.Update_by = user.UserName;
ShopGoodsCategory.Update_time = DateTime.Now;
var editRes = await AddOrUpdateShopGoodsCategory(ShopGoodsCategory);
});
- var editStr = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryId}】更新成功!
";
+ var editStr = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryName}】更新成功!
";
return editStr;
}
}
- else{
- // 开启事务
+ else
+ {
+ // 开启事务
var res = await UseTranAsync(async () =>
{
var addRes = await AddOrUpdateShopGoodsCategory(ShopGoodsCategory);
});
//Console.WriteLine(res.IsSuccess);
- var addStr = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryId}】新增成功!
";
+ var addStr = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryName}】新增成功!
";
return addStr;
}
}
catch (Exception ex)
{
- var errorRes = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategory.ShopGoodsCategoryId}】导入失败!{ex.Message}
";
+ var errorRes = $"第 {index} 行 => 店铺商品类目:【{ShopGoodsCategoryVo.ShopGoodsCategoryName}】导入失败!{ex.Message}
";
return errorRes;
throw;
}
}
-
+
///
/// Excel数据导出处理
///
public async Task> HandleExportData(List data)
{
+ foreach (var item in data)
+ {
+ item.ShopGoodsCategoryDisplayStatusName = _SysDictDataRepository.GetDictNameByName("display_status", item.ShopGoodsCategoryDisplayStatus.ToString());
+ }
return data;
}
#endregion
-
-#endregion
+
+ #endregion
}
}
diff --git a/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs b/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs
index f2b3f6c..9231925 100644
--- a/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs
+++ b/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs
@@ -314,6 +314,13 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
}
+ public async Task CheckRepeatShopName(string shopName)
+ {
+ var query = await _ShopRepository.GetFirstAsync(s => s.ShopName == shopName);
+ return query != null ;
+ }
+
+
#endregion
}
diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryService.cs
index a486c6a..e32a015 100644
--- a/ARW.Service/Business/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryService.cs
+++ b/ARW.Service/Business/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryService.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using ARW.Model;
using ARW.Model.Dto.Business.GoodsManager.ShopGoodsCategorys;
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
+using ARW.Model.System;
using ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys;
namespace ARW.Service.Business.IBusinessService.GoodsManager.ShopGoodsCategorys
@@ -46,7 +47,7 @@ namespace ARW.Service.Business.IBusinessService.GoodsManager.ShopGoodsCategorys
///
///
///
- Task HandleImportData(ShopGoodsCategoryVo ShopGoodsCategoryVo);
+ Task HandleImportData(ShopGoodsCategoryVo ShopGoodsCategoryVo,long userId,int index);
///
@@ -54,7 +55,7 @@ namespace ARW.Service.Business.IBusinessService.GoodsManager.ShopGoodsCategorys
///
///
///
- Task ImportExcel(ShopGoodsCategory ShopGoodsCategory,int index,bool isUpdateSupport,string user);
+ Task ImportExcel(ShopGoodsCategoryVo ShopGoodsCategory,int index,bool isUpdateSupport,LoginUser user);
///
/// Excel导出
diff --git a/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs b/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs
index e5d4dbe..5e81889 100644
--- a/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs
+++ b/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs
@@ -78,5 +78,13 @@ namespace ARW.Service.Business.IBusinessService.ShopManager.Shops
///
Task GetShopOperatorDetail(ShopOperatorQueryDto parm);
+
+ ///
+ /// 检查是否有重复商店名称
+ ///
+ ///
+ ///
+ Task CheckRepeatShopName(string shopName);
+
}
}
diff --git a/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs b/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs
index 67320f3..a051853 100644
--- a/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs
+++ b/ARW.WebApi/Controllers/Api/ShopManager/Shops/ShopApiController.cs
@@ -33,14 +33,17 @@ namespace ARW.WebApi.Controllers.Api.ShopManager.Shops
public class ShopApiController : BaseController
{
private readonly IShopServiceApi _ShopServiceApi;
+ private readonly IShopService _ShopService;
///
/// 依赖注入
///
/// 店铺店铺Api服务
- public ShopApiController(IShopServiceApi ShopServiceApi)
+ /// 店铺店铺服务
+ public ShopApiController(IShopServiceApi ShopServiceApi, IShopService ShopService)
{
_ShopServiceApi = ShopServiceApi;
+ _ShopService = ShopService;
}
@@ -80,6 +83,9 @@ namespace ARW.WebApi.Controllers.Api.ShopManager.Shops
{
if (parm == null) { throw new CustomException("请求参数错误"); }
+ var isRepeat = await _ShopService.CheckRepeatShopName(parm.ShopName);
+ if (isRepeat) throw new CustomException("商铺名称已存在");
+
var modal = new Shop();
if (parm.ShopId != 0) modal = parm.Adapt().ToUpdate(HttpContext);
else modal = parm.Adapt().ToCreate(HttpContext);
diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs
index 6974329..ac79545 100644
--- a/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs
+++ b/ARW.WebApi/Controllers/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryController.cs
@@ -15,6 +15,7 @@ using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
using ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys;
using Microsoft.AspNetCore.Authorization;
using ARW.Admin.WebApi.Framework;
+using ARW.Service.Business.IBusinessService.ShopManager.Shops;
namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
@@ -30,14 +31,16 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
public class ShopGoodsCategoryController : BaseController
{
private readonly IShopGoodsCategoryService _ShopGoodsCategoryService;
+ private readonly IShopService _ShopService;
///
/// 依赖注入
///
/// 店铺商品类目服务
- public ShopGoodsCategoryController(IShopGoodsCategoryService ShopGoodsCategoryService)
+ public ShopGoodsCategoryController(IShopGoodsCategoryService ShopGoodsCategoryService, IShopService shopService)
{
_ShopGoodsCategoryService = ShopGoodsCategoryService;
+ _ShopService = shopService;
}
@@ -50,6 +53,14 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
[ActionPermissionFilter(Permission = "business:shopgoodscategory:treelist")]
public async Task GetShopGoodsCategoryList([FromQuery] ShopGoodsCategoryQueryDto parm)
{
+ var user = JwtUtil.GetLoginUser(App.HttpContext);
+ if (user.UserId != 1)
+ {
+ var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId);
+ if (shop == null) throw new Exception("当前用户没有店铺");
+ parm.ShopGuid = shop.ShopGuid;
+ }
+
var res = await _ShopGoodsCategoryService.GetShopGoodsCategoryTreeList(parm);
res ??= new List();
@@ -72,6 +83,14 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
if (parm.ShopGoodsCategoryId != 0) modal = parm.Adapt().ToUpdate(HttpContext);
else modal = parm.Adapt().ToCreate(HttpContext);
+ var user = JwtUtil.GetLoginUser(App.HttpContext);
+ if (user.UserId != 1)
+ {
+ var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId);
+ if (shop == null) throw new Exception("当前用户没有店铺");
+ modal.ShopGuid = shop.ShopGuid;
+ }
+
var res = await _ShopGoodsCategoryService.AddOrUpdateShopGoodsCategory(modal);
return SUCCESS(res);
}
@@ -99,9 +118,10 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
///
[HttpPost("importData")]
[Log(Title = "店铺商品类目导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
- [ActionPermissionFilter(Permission = "business:business:shopgoodscategory:import")]
+ [ActionPermissionFilter(Permission = "business:shopgoodscategory:import")]
public async Task ImportExcel([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
{
+
var isUpdateSupport = updateSupport;
IEnumerable parm = ExcelHelper.ImportData(formFile.OpenReadStream());
@@ -110,10 +130,10 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
foreach (ShopGoodsCategoryVo item in parm)
{
i++;
- var ShopGoodsCategory = await _ShopGoodsCategoryService.HandleImportData(item);
- var modal = ShopGoodsCategory.Adapt().ToCreate(HttpContext);
- var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
- var msg = await _ShopGoodsCategoryService.ImportExcel(modal, i, isUpdateSupport, user);
+ var user = JwtUtil.GetLoginUser(App.HttpContext);
+ //var ShopGoodsCategory = await _ShopGoodsCategoryService.HandleImportData(item,user.UserId,i);
+ //var modal = ShopGoodsCategory.Adapt().ToCreate(HttpContext);
+ var msg = await _ShopGoodsCategoryService.ImportExcel(item, i, isUpdateSupport, user);
msgList.Add(msg);
}
@@ -135,10 +155,16 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
// 示例数据
var allValues = new List>();
- var values = new List() { "111", "222", "333" };
- var values2 = new List() { "444", "555", "666" };
+ var values = new List() { "我的店铺", "", "电脑", "显示", "1" };
+ var values2 = new List() { "我的店铺", "电脑", "商业笔记本", "显示", "1" };
+ var values3 = new List() { "我的店铺", "电脑", "游戏本", "显示", "2" };
+ var values4 = new List() { "我的店铺", "", "外设", "显示", "2" };
+ var values5 = new List() { "我的店铺", "外设", "鼠标", "显示", "1" };
allValues.Add(values);
allValues.Add(values2);
+ allValues.Add(values3);
+ allValues.Add(values4);
+ allValues.Add(values5);
string sFileName = DownloadImportTemplate(ShopGoodsCategory, stream, "店铺商品类目导入模板", allValues);
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
@@ -153,6 +179,13 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.ShopGoodsCategorys
[ActionPermissionFilter(Permission = "business:shopgoodscategory:export")]
public async Task ExportExcel([FromQuery] ShopGoodsCategoryQueryDto parm)
{
+ var user = JwtUtil.GetLoginUser(App.HttpContext);
+ if (user.UserId != 1)
+ {
+ var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId);
+ if (shop == null) throw new Exception("当前用户没有店铺");
+ parm.ShopGuid = shop.ShopGuid;
+ }
var list = await _ShopGoodsCategoryService.GetShopGoodsCategoryList(parm);
var data = list;
diff --git a/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs b/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs
index ca8e434..445752c 100644
--- a/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs
+++ b/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs
@@ -108,6 +108,10 @@ namespace ARW.WebApi.Controllers.Business.ShopManager.Shops
{
if (parm == null) { throw new CustomException("请求参数错误"); }
+ // 检查是否有重复商店名称
+ var isRepeat = await _ShopService.CheckRepeatShopName(parm.ShopName);
+ if (isRepeat) throw new CustomException("商铺名称已存在");
+
var modal = new Shop();
if (parm.ShopId != 0) modal = parm.Adapt().ToUpdate(HttpContext);
else modal = parm.Adapt().ToCreate(HttpContext);
diff --git a/ARW.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ARW.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt
index 2b3ea49..c9d09f0 100644
--- a/ARW.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt
+++ b/ARW.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt
@@ -117,7 +117,7 @@ $if(replaceDto.ShowBtnImport)
///
[HttpPost("importData")]
[Log(Title = "${genTable.FunctionName}导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
- [ActionPermissionFilter(Permission = "business:${replaceDto.PermissionPrefix}:import")]
+ [ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:import")]
public async Task ImportExcel([FromForm(Name = "file")] IFormFile formFile,bool updateSupport)
{
var isUpdateSupport = updateSupport;
diff --git a/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt b/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt
index ae1e9c4..b54fcdc 100644
--- a/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt
+++ b/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt
@@ -98,7 +98,7 @@ $end
$if(replaceDto.ShowBtnImport)
导入
+ v-hasPermi="['${replaceDto.PermissionPrefix}:import']">导入
$end
$if(replaceDto.ShowBtnExport)
@@ -175,7 +175,7 @@ $if(replaceDto.ShowBtnAudit)
@click="handleAudit(scope.row)" v-hasPermi="['${replaceDto.PermissionPrefix}:audit']">审核
$if(replaceDto.ShowBtnEdit)
编辑
+ v-hasPermi="['${replaceDto.PermissionPrefix}:addOrUpdate']">编辑
$end
$if(replaceDto.ShowBtnDelete)
编辑
+ v-hasPermi="['${replaceDto.PermissionPrefix}:addOrUpdate']">编辑
$end
$if(replaceDto.ShowBtnDelete)