feat 初始化商品服务与承诺
This commit is contained in:
parent
e76d63b2d6
commit
494238f351
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.GoodsManager.GoodsServicess;
|
||||
|
||||
namespace ARW.Model.Dto.Business.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺输入对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public class GoodsServicesDto
|
||||
{
|
||||
|
||||
public int GoodsServicesId { get; set; }
|
||||
|
||||
public long GoodsServicesGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "店铺guid不能为空")]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "服务名称不能为空")]
|
||||
public string GoodsServicesName { get; set; }
|
||||
|
||||
public string GoodsServicesSummary { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "是否默认不能为空")]
|
||||
public int GoodsServicesIsDefault { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "显示状态不能为空")]
|
||||
public int GoodsServicesDisplayStatus { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "排序不能为空")]
|
||||
public int GoodsServicesSort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 商品服务与承诺查询对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public class GoodsServicesQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string ShopName { get; set; }
|
||||
public string GoodsServicesName { get; set; }
|
||||
|
||||
public int? GoodsServicesIsDefault { get; set; }
|
||||
|
||||
public int? GoodsServicesDisplayStatus { get; set; }
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺,数据实体对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[SugarTable("tb_goods_services")]
|
||||
public class GoodsServices : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "GoodsServicesId")]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_services_id")]
|
||||
public int GoodsServicesId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "GoodsServicesGuid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_services_guid")]
|
||||
public long GoodsServicesGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "店铺guid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "shop_guid")]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :服务名称
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "服务名称")]
|
||||
[SugarColumn(ColumnName = "goods_services_name")]
|
||||
public string GoodsServicesName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :概述
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "概述")]
|
||||
[SugarColumn(ColumnName = "goods_services_summary")]
|
||||
public string GoodsServicesSummary { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否默认
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否默认")]
|
||||
[SugarColumn(ColumnName = "goods_services_is_default")]
|
||||
public int GoodsServicesIsDefault { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :显示状态
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "显示状态")]
|
||||
[SugarColumn(ColumnName = "goods_services_display_status")]
|
||||
public int GoodsServicesDisplayStatus { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
[SugarColumn(ColumnName = "goods_services_sort")]
|
||||
public int GoodsServicesSort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺展示对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public class GoodsServicesVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int GoodsServicesId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long GoodsServicesGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "店铺")]
|
||||
public string ShopName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :服务名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "服务名称")]
|
||||
public string GoodsServicesName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :概述
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
[EpplusTableColumn(Header = "服务概述")]
|
||||
public string GoodsServicesSummary { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否默认
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否默认")]
|
||||
public int GoodsServicesIsDefault { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :显示状态
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "显示状态")]
|
||||
public int GoodsServicesDisplayStatus { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int GoodsServicesSort { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.GoodsManager.GoodsServicess;
|
||||
|
||||
namespace ARW.Repository.Business.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺仓储
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class GoodsServicesRepository : BaseRepository<GoodsServices>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
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.GoodsServicess;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess;
|
||||
using ARW.Model.Dto.Business.GoodsManager.GoodsServicess;
|
||||
using ARW.Model.Models.Business.GoodsManager.GoodsServicess;
|
||||
using ARW.Model.Vo.Business.GoodsManager.GoodsServicess;
|
||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺接口实现类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IGoodsServicesService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class GoodsServicesServiceImpl : BaseService<GoodsServices>, IGoodsServicesService
|
||||
{
|
||||
private readonly GoodsServicesRepository _GoodsServicesRepository;
|
||||
|
||||
public GoodsServicesServiceImpl(GoodsServicesRepository GoodsServicesRepository)
|
||||
{
|
||||
this._GoodsServicesRepository = GoodsServicesRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询商品服务与承诺分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<GoodsServicesVo>> GetGoodsServicesList(GoodsServicesQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<GoodsServices>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsServicesName), s => s.GoodsServicesName.Contains(parm.GoodsServicesName));
|
||||
predicate = predicate.AndIF(parm.GoodsServicesIsDefault != null, s => s.GoodsServicesIsDefault == parm.GoodsServicesIsDefault);
|
||||
predicate = predicate.AndIF(parm.GoodsServicesDisplayStatus != null, s => s.GoodsServicesDisplayStatus == parm.GoodsServicesDisplayStatus);
|
||||
var query = _GoodsServicesRepository
|
||||
.Queryable()
|
||||
.LeftJoin<Shop>((s,c) => s.ShopGuid == c.ShopGuid)
|
||||
.Where(predicate.ToExpression())
|
||||
.WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s,c) => c.ShopName.Contains(parm.ShopName))
|
||||
.OrderBy(s => s.GoodsServicesSort, OrderByType.Asc)
|
||||
.Select((s,c) => new GoodsServicesVo
|
||||
{
|
||||
ShopName = c.ShopName,
|
||||
GoodsServicesId = s.GoodsServicesId,
|
||||
GoodsServicesGuid = s.GoodsServicesGuid,
|
||||
ShopGuid = s.ShopGuid,
|
||||
GoodsServicesName = s.GoodsServicesName,
|
||||
GoodsServicesSummary = s.GoodsServicesSummary,
|
||||
GoodsServicesIsDefault = s.GoodsServicesIsDefault,
|
||||
GoodsServicesDisplayStatus = s.GoodsServicesDisplayStatus,
|
||||
GoodsServicesSort = s.GoodsServicesSort,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品服务与承诺
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateGoodsServices(GoodsServices model)
|
||||
{
|
||||
if (model.GoodsServicesId != 0)
|
||||
{
|
||||
var response = await _GoodsServicesRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var response = await _GoodsServicesRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel数据导出处理
|
||||
/// </summary>
|
||||
public async Task<List<GoodsServicesVo>> HandleExportData(List<GoodsServicesVo> data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
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.GoodsServicess;
|
||||
using ARW.Model.Models.Business.GoodsManager.GoodsServicess;
|
||||
using ARW.Model.Vo.Business.GoodsManager.GoodsServicess;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺接口类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
public interface IGoodsServicesService : IBaseService<GoodsServices>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取商品服务与承诺分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<GoodsServicesVo>> GetGoodsServicesList(GoodsServicesQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品服务与承诺
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateGoodsServices(GoodsServices parm);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导出
|
||||
/// </summary>
|
||||
Task<List<GoodsServicesVo>> HandleExportData(List<GoodsServicesVo> data);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
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.GoodsServicess;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Models.Business.GoodsManager.GoodsServicess;
|
||||
using ARW.Model.Vo.Business.GoodsManager.GoodsServicess;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.GoodsManager.GoodsServicess
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品服务与承诺控制器
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-18
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/[controller]")]
|
||||
public class GoodsServicesController : BaseController
|
||||
{
|
||||
private readonly IGoodsServicesService _GoodsServicesService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="GoodsServicesService">商品服务与承诺服务</param>
|
||||
public GoodsServicesController(IGoodsServicesService GoodsServicesService)
|
||||
{
|
||||
_GoodsServicesService = GoodsServicesService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品服务与承诺列表
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getGoodsServicesList")]
|
||||
[ActionPermissionFilter(Permission = "business:goodsservices:list")]
|
||||
public async Task<IActionResult> GetGoodsServicesList([FromQuery] GoodsServicesQueryDto parm)
|
||||
{
|
||||
var res = await _GoodsServicesService.GetGoodsServicesList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品服务与承诺
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateGoodsServices")]
|
||||
[ActionPermissionFilter(Permission = "business:goodsservices:addOrUpdate")]
|
||||
[Log(Title = "添加或修改商品服务与承诺", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateGoodsServices([FromBody] GoodsServicesDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new GoodsServices();
|
||||
if (parm.GoodsServicesId != 0) modal = parm.Adapt<GoodsServices>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<GoodsServices>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _GoodsServicesService.AddOrUpdateGoodsServices(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除商品服务与承诺
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:goodsservices: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 = _GoodsServicesService.Delete(idsArr);
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导出商品服务与承诺
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(Title = "商品服务与承诺导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[HttpGet("exportGoodsServices")]
|
||||
[ActionPermissionFilter(Permission = "business:goodsservices:export")]
|
||||
public async Task<IActionResult> ExportExcel([FromQuery] GoodsServicesQueryDto parm)
|
||||
{
|
||||
parm.PageSize = 10000;
|
||||
var list = await _GoodsServicesService.GetGoodsServicesList(parm);
|
||||
var data = list.Result;
|
||||
|
||||
// 选中数据
|
||||
if (!string.IsNullOrEmpty(parm.ids))
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(parm.ids);
|
||||
var selectDataList = new List<GoodsServicesVo>();
|
||||
foreach (var item in idsArr)
|
||||
{
|
||||
var select_data = data.Where(s => s.GoodsServicesId == item).First();
|
||||
selectDataList.Add(select_data);
|
||||
}
|
||||
data = selectDataList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 导出数据处理
|
||||
var handleData = await _GoodsServicesService.HandleExportData(data);
|
||||
|
||||
string sFileName = ExportExcel(handleData, "GoodsServices", "商品服务与承诺列表");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user