init 初始化规格值
This commit is contained in:
parent
aa54d99b47
commit
88e0b69c5a
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
|
||||||
|
namespace ARW.Model.Dto.Business.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值输入对象
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
public class SpecValueDto
|
||||||
|
{
|
||||||
|
|
||||||
|
public int SpecValueId { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "规格组ID不能为空")]
|
||||||
|
public int SpecId { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "规格值名称不能为空")]
|
||||||
|
public string SpecName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值查询对象
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
public class SpecValueQueryDto : PagerInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
public string ids { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using SqlSugar;
|
||||||
|
using OfficeOpenXml.Attributes;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值,数据实体对象
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("tb_spec_value")]
|
||||||
|
public class SpecValue : BusinessBase
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// 空值 : false
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "spec_value_id")]
|
||||||
|
public int SpecValueId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :规格组ID
|
||||||
|
/// 空值 : false
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "spec_id")]
|
||||||
|
public int SpecId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :规格值名称
|
||||||
|
/// 空值 : false
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "spec_name")]
|
||||||
|
public string SpecName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using OfficeOpenXml.Attributes;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值展示对象
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
public class SpecValueVo
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// </summary>
|
||||||
|
public int SpecValueId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :规格组ID
|
||||||
|
/// </summary>
|
||||||
|
public int SpecId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :规格值名称
|
||||||
|
/// </summary>
|
||||||
|
public string SpecName { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using ARW.Repository.System;
|
||||||
|
using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
|
||||||
|
namespace ARW.Repository.Business.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值仓储
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class SpecValueRepository : BaseRepository<SpecValue>
|
||||||
|
{
|
||||||
|
#region 业务逻辑代码
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
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.SpecValues;
|
||||||
|
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using ARW.Model.Dto.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
|
||||||
|
namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值接口实现类
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(ISpecValueService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class SpecValueServiceImpl : BaseService<SpecValue>, ISpecValueService
|
||||||
|
{
|
||||||
|
private readonly SpecValueRepository _SpecValueRepository;
|
||||||
|
|
||||||
|
public SpecValueServiceImpl(SpecValueRepository SpecValueRepository)
|
||||||
|
{
|
||||||
|
this._SpecValueRepository = SpecValueRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 业务逻辑代码
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询商品规格值分页列表
|
||||||
|
/// </summary>
|
||||||
|
public async Task<PagedInfo<SpecValueVo>> GetSpecValueList(SpecValueQueryDto parm)
|
||||||
|
{
|
||||||
|
//开始拼装查询条件d
|
||||||
|
var predicate = Expressionable.Create<SpecValue>();
|
||||||
|
|
||||||
|
var query = _SpecValueRepository
|
||||||
|
.Queryable()
|
||||||
|
.Where(predicate.ToExpression())
|
||||||
|
.OrderBy(s => s.Create_time,OrderByType.Desc)
|
||||||
|
.Select(s => new SpecValueVo
|
||||||
|
{
|
||||||
|
SpecValueId = s.SpecValueId,
|
||||||
|
SpecId = s.SpecId,
|
||||||
|
SpecName = s.SpecName,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return await query.ToPageAsync(parm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品规格值
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string> AddOrUpdateSpecValue(SpecValue model)
|
||||||
|
{
|
||||||
|
if (model.SpecValueId != 0)
|
||||||
|
{
|
||||||
|
var response = await _SpecValueRepository.UpdateAsync(model);
|
||||||
|
return "修改成功!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var response = await _SpecValueRepository.InsertReturnSnowflakeIdAsync(model);
|
||||||
|
return "添加成功!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Excel处理
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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.SpecValues;
|
||||||
|
using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
|
||||||
|
namespace ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值接口类
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
public interface ISpecValueService : IBaseService<SpecValue>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商品规格值分页列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<PagedInfo<SpecValueVo>> GetSpecValueList(SpecValueQueryDto parm);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品规格值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> AddOrUpdateSpecValue(SpecValue parm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
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.SpecValues;
|
||||||
|
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using ARW.Admin.WebApi.Controllers;
|
||||||
|
using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.SpecValues;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using ARW.Admin.WebApi.Framework;
|
||||||
|
|
||||||
|
|
||||||
|
namespace ARW.WebApi.Controllers.Business.GoodsManager.GoodsSpecs.SpecValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格值控制器
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-19
|
||||||
|
/// </summary>
|
||||||
|
[Verify]
|
||||||
|
[Route("business/[controller]")]
|
||||||
|
public class SpecValueController : BaseController
|
||||||
|
{
|
||||||
|
private readonly ISpecValueService _SpecValueService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 依赖注入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SpecValueService">商品规格值服务</param>
|
||||||
|
public SpecValueController(ISpecValueService SpecValueService)
|
||||||
|
{
|
||||||
|
_SpecValueService = SpecValueService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商品规格值列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">查询参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getSpecValueList")]
|
||||||
|
[ActionPermissionFilter(Permission = "business:specvalue:list")]
|
||||||
|
public async Task<IActionResult> GetSpecValueList([FromQuery] SpecValueQueryDto parm)
|
||||||
|
{
|
||||||
|
var res = await _SpecValueService.GetSpecValueList(parm);
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品规格值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("addOrUpdateSpecValue")]
|
||||||
|
[ActionPermissionFilter(Permission = "business:specvalue:addOrUpdate")]
|
||||||
|
[Log(Title = "添加或修改商品规格值", BusinessType = BusinessType.ADDORUPDATE)]
|
||||||
|
public async Task<IActionResult> AddOrUpdateSpecValue([FromBody] SpecValueDto parm)
|
||||||
|
{
|
||||||
|
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||||
|
|
||||||
|
var modal = new SpecValue();
|
||||||
|
if (parm.SpecValueId != 0) modal = parm.Adapt<SpecValue>().ToUpdate(HttpContext);
|
||||||
|
else modal = parm.Adapt<SpecValue>().ToCreate(HttpContext);
|
||||||
|
|
||||||
|
var res = await _SpecValueService.AddOrUpdateSpecValue(modal);
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除商品规格值
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("{ids}")]
|
||||||
|
[ActionPermissionFilter(Permission = "business:specvalue: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 = _SpecValueService.Delete(idsArr);
|
||||||
|
return SUCCESS("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user