init 初始化规格组
This commit is contained in:
parent
52e0233141
commit
aa54d99b47
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组输入对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
public class SpecDto
|
||||
{
|
||||
|
||||
public int SpecId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "规格值名称不能为空")]
|
||||
public string SpecName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 商品规格组查询对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
public class SpecQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组,数据实体对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
[SugarTable("tb_spec")]
|
||||
public class Spec : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "spec_id")]
|
||||
public int SpecId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :规格值名称
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "spec_name")]
|
||||
public string SpecName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.Specs
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组展示对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
public class SpecVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
public int SpecId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :规格值名称
|
||||
/// </summary>
|
||||
public string SpecName { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -34,9 +34,15 @@ namespace ARW.Model.Vo.Business.GoodsManager.Goodss
|
||||
/// 描述 :店铺guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "店铺guid")]
|
||||
[EpplusIgnore]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺名称
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "店铺名称")]
|
||||
public string ShopName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品类目guid
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组仓储
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class SpecRepository : BaseRepository<Spec>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组接口实现类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISpecService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SpecServiceImpl : BaseService<Spec>, ISpecService
|
||||
{
|
||||
private readonly SpecRepository _SpecRepository;
|
||||
|
||||
public SpecServiceImpl(SpecRepository SpecRepository)
|
||||
{
|
||||
this._SpecRepository = SpecRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询商品规格组分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<SpecVo>> GetSpecList(SpecQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Spec>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品规格组
|
||||
/// </summary>
|
||||
public async Task<string> 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
|
||||
|
||||
}
|
||||
}
|
@ -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<Shop>((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,
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组接口类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
public interface ISpecService : IBaseService<Spec>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取商品规格组分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<SpecVo>> GetSpecList(SpecQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品规格组
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateSpec(Spec parm);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品规格组控制器
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-19
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/[controller]")]
|
||||
public class SpecController : BaseController
|
||||
{
|
||||
private readonly ISpecService _SpecService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="SpecService">商品规格组服务</param>
|
||||
public SpecController(ISpecService SpecService)
|
||||
{
|
||||
_SpecService = SpecService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品规格组列表
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getSpecList")]
|
||||
[ActionPermissionFilter(Permission = "business:spec:list")]
|
||||
public async Task<IActionResult> GetSpecList([FromQuery] SpecQueryDto parm)
|
||||
{
|
||||
var res = await _SpecService.GetSpecList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品规格组
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateSpec")]
|
||||
[ActionPermissionFilter(Permission = "business:spec:addOrUpdate")]
|
||||
[Log(Title = "添加或修改商品规格组", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateSpec([FromBody] SpecDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new Spec();
|
||||
if (parm.SpecId != 0) modal = parm.Adapt<Spec>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<Spec>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _SpecService.AddOrUpdateSpec(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除商品规格组
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user