feat 初始化店铺接口
This commit is contained in:
parent
f5cbb5b1ce
commit
b5d9841156
34
ARW.Model/Dto/Api/ShopManager/Shops/ShopApiDto.cs
Normal file
34
ARW.Model/Dto/Api/ShopManager/Shops/ShopApiDto.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||
|
||||
namespace ARW.Model.Dto.Api.ShopManager.Shops
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 店铺查询对象Api
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-12
|
||||
/// </summary>
|
||||
public class ShopQueryDtoApi : PagerInfo
|
||||
{
|
||||
public string ShopName { get; set; }
|
||||
public int? ShopAuditStatus { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 店铺详情输入对象Api
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-12
|
||||
/// </summary>
|
||||
public class ShopDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "ShopGuid不能为空")]
|
||||
public long ShopGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
153
ARW.Model/Vo/Api/ShopManager/Shops/ShopApiVo.cs
Normal file
153
ARW.Model/Vo/Api/ShopManager/Shops/ShopApiVo.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Api.ShopManager.Shops
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺展示对象Api
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-12
|
||||
/// </summary>
|
||||
public class ShopVoApi
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :用户id
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int? ShopUserId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :客户guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long? ShopCustomerGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :经营类目guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "经营类目guid")]
|
||||
public long ShopBusinessCategoryGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :图标
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "图标")]
|
||||
public string ShopLogo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :营业执照
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "营业执照")]
|
||||
public string ShopBusinessLicense { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "名称")]
|
||||
public string ShopName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :简介
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "简介")]
|
||||
public string ShopIntro { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int ShopSort { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :销售单量
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "销售单量")]
|
||||
public int ShopSalesOrderCount { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :审核状态
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "审核状态")]
|
||||
public int ShopAuditStatus { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :审核人
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "审核人")]
|
||||
public long ShopAuditUserGuid { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 店铺详情展示对象Api
|
||||
/// </summary>
|
||||
public class ShopApiDetailsVo
|
||||
{
|
||||
[EpplusIgnore]
|
||||
public int ShopId { get; set; }
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long ShopGuid { get; set; }
|
||||
[EpplusIgnore]
|
||||
public int? ShopUserId { get; set; }
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long? ShopCustomerGuid { get; set; }
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "经营类目guid")]
|
||||
public long ShopBusinessCategoryGuid { get; set; }
|
||||
[EpplusTableColumn(Header = "图标")]
|
||||
public string ShopLogo { get; set; }
|
||||
[EpplusTableColumn(Header = "营业执照")]
|
||||
public string ShopBusinessLicense { get; set; }
|
||||
[EpplusTableColumn(Header = "名称")]
|
||||
public string ShopName { get; set; }
|
||||
[EpplusTableColumn(Header = "简介")]
|
||||
public string ShopIntro { get; set; }
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int ShopSort { get; set; }
|
||||
[EpplusTableColumn(Header = "销售单量")]
|
||||
public int ShopSalesOrderCount { get; set; }
|
||||
[EpplusTableColumn(Header = "审核状态")]
|
||||
public int ShopAuditStatus { get; set; }
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "审核人")]
|
||||
public long ShopAuditUserGuid { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
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 ARW.Model;
|
||||
using ARW.Repository;
|
||||
using ARW.Repository.Business.ShopManager.Shops;
|
||||
using ARW.Service.Api.IBusinessService.ShopManager.Shops;
|
||||
using ARW.Model.Dto.Api.ShopManager.Shops;
|
||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||
using ARW.Model.Vo.Api.ShopManager.Shops;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.ShopManager.Shops
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺接口实现类Api
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-12
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IShopServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ShopServiceImplApi : BaseService<Shop>, IShopServiceApi
|
||||
{
|
||||
private readonly ShopRepository _ShopRepository;
|
||||
|
||||
public ShopServiceImplApi(ShopRepository ShopRepository)
|
||||
{
|
||||
this._ShopRepository = ShopRepository;
|
||||
}
|
||||
|
||||
#region Api接口代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询店铺列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedInfo<ShopVoApi>> GetShopListApi(ShopQueryDtoApi parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Shop>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ShopName), it => it.ShopName.Contains(parm.ShopName));
|
||||
predicate = predicate.AndIF(parm.ShopAuditStatus != null, it => it.ShopAuditStatus == parm.ShopAuditStatus);
|
||||
var query = _ShopRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.ShopSort, OrderByType.Desc)
|
||||
.Select(s => new ShopVoApi
|
||||
{
|
||||
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 await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询店铺详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetShopDetails(ShopDtoApi parm)
|
||||
{
|
||||
|
||||
var query = _ShopRepository
|
||||
.Queryable()
|
||||
.Where(s => s.ShopGuid == parm.ShopGuid)
|
||||
.Select(s => new ShopApiDetailsVo
|
||||
{
|
||||
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,
|
||||
}).Take(1);
|
||||
|
||||
|
||||
return query.ToJsonAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改店铺
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateShop(Shop model)
|
||||
{
|
||||
if (model.ShopId != 0)
|
||||
{
|
||||
var response = await _ShopRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.ShopAuditStatus = 1;
|
||||
var response = await _ShopRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.ShopManager.Shops;
|
||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||
using ARW.Model.Vo.Api.ShopManager.Shops;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.ShopManager.Shops
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺接口类Api
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-12
|
||||
/// </summary>
|
||||
public interface IShopServiceApi : IBaseService<Shop>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取店铺分页列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<ShopVoApi>> GetShopListApi(ShopQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取店铺详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetShopDetails(ShopDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改店铺
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateShop(Shop parm);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
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.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Dto.Api.ShopManager.Shops;
|
||||
using ARW.Service.Api.IBusinessService.ShopManager.Shops;
|
||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||
using ARW.Model.Vo.Api.ShopManager.Shops;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
using ARW.Model.Dto.Business.ShopManager.Shops;
|
||||
using ARW.Service.Business.IBusinessService.ShopManager.Shops;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.ShopManager.Shops
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺控制器Api
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-12
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class ShopApiController : BaseController
|
||||
{
|
||||
private readonly IShopServiceApi _ShopServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="ShopServiceApi">店铺店铺Api服务</param>
|
||||
public ShopApiController(IShopServiceApi ShopServiceApi)
|
||||
{
|
||||
_ShopServiceApi = ShopServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取店铺列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getShopList")]
|
||||
public async Task<IActionResult> GetShopListApi([FromQuery] ShopQueryDtoApi parm)
|
||||
{
|
||||
var res = await _ShopServiceApi.GetShopListApi(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改店铺
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateShop")]
|
||||
[Log(Title = "添加或修改店铺", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateShop([FromBody] ShopDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new Shop();
|
||||
if (parm.ShopId != 0) modal = parm.Adapt<Shop>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<Shop>().ToCreate(HttpContext);
|
||||
|
||||
//var res = await _ShopServiceApi.AddOrUpdateShop(modal);
|
||||
//return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Shop详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getShopDetails")]
|
||||
public async Task<IActionResult> GetShopDetails([FromQuery] ShopDtoApi parm)
|
||||
{
|
||||
//if (parm == null) throw new CustomException("参数错误!");
|
||||
|
||||
var res = await _ShopServiceApi.GetShopDetails(parm);
|
||||
|
||||
if (res != "[]")
|
||||
{
|
||||
res = res.Remove(0, 1);
|
||||
res = res.Substring(0, res.Length - 1);
|
||||
var data = res.FromJSON<ShopApiDetailsVo>();
|
||||
return SUCCESS(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUCCESS(res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -110,6 +110,8 @@ namespace ARW.WebApi.Controllers.Business.ShopManager.Shops
|
||||
if (parm.ShopId != 0) modal = parm.Adapt<Shop>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<Shop>().ToCreate(HttpContext);
|
||||
|
||||
modal.ShopAuditStatus = 1;
|
||||
|
||||
var res = await _ShopService.AddOrUpdateShop(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user