修改商品接口数据

This commit is contained in:
zpc 2025-07-23 12:10:33 +08:00
parent 032941a018
commit f39eaf4fc3
3 changed files with 42 additions and 24 deletions

View File

@ -15,6 +15,7 @@ using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.Filter;
using CoreCms.Net.IServices;
@ -26,11 +27,15 @@ using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
using CoreCms.Net.Web.Admin.Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using NPOI.HSSF.UserModel;
using SqlSugar;
using Yitter.IdGenerator;
namespace CoreCms.Net.Web.Admin.Controllers
@ -619,17 +624,17 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
[HttpGet]
[Description("预览数据")]
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
public async Task<AdminUiCallBack> GetDetails([FromQuery] int id)
{
var jm = new AdminUiCallBack();
var model = await _coreCmsGoodsServices.QueryByIdAsync(entity.id);
var model = await _coreCmsGoodsServices.QueryByIdAsync(id);
if (model == null)
{
jm.msg = "不存在此信息";
jm.data = entity.id;
jm.data = id;
return jm;
}

View File

@ -31,6 +31,7 @@ using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using CoreCms.Net.Utility.Helper;
using NetTaste;
namespace CoreCms.Net.Web.WebApi.Controllers
{
@ -94,7 +95,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// 获取所有商品分类栏目数据
/// </summary>
/// <returns></returns>
[HttpPost]
[HttpGet]
public async Task<WebApiCallBack> GetAllCategories()
{
var jm = new WebApiCallBack() { status = true };
@ -145,9 +146,10 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// <summary>
/// 根据查询条件获取分页数据
/// </summary>
/// <param name="entity">where={priceFrom:"最低价格",priceTo:"最高价格",catId:"分类",brandId:"品牌",labelId:"标签id",searchName:"商品名称"}</param>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetGoodsPageList([FromBody] FMPageByWhereOrder entity)
[HttpGet]
public async Task<WebApiCallBack> GetGoodsPageList([FromQuery] FMPageByWhereOrder entity)
{
var jm = new WebApiCallBack();
@ -229,7 +231,17 @@ namespace CoreCms.Net.Web.WebApi.Controllers
where = where.And(p => p.name.Contains(obj.searchName));
}
}
if (string.IsNullOrWhiteSpace(entity.order))
{
if (!string.IsNullOrWhiteSpace(entity.where) && entity.where.StartsWith("catId"))
{
entity.order = "sort desc";
}
else
{
entity.order = "createTime desc";
}
}
//获取数据
var list = await _goodsServices.QueryPageForLinqAsync(where, entity.order, entity.page, entity.limit, false);
if (list.Any())
@ -253,9 +265,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
entity.page,
list.TotalCount,
list.TotalPages,
entity.limit,
entity.where,
entity.order,
//entity.limit,
//entity.where,
//entity.order,
brands
};
jm.msg = "数据调用成功!";
@ -268,10 +280,10 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// <summary>
/// 获取商品详情
/// </summary>
/// <param name="entity"></param>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetDetial([FromBody] FMIntId entity)
[HttpGet]
public async Task<WebApiCallBack> GetDetial([FromQuery] int id)
{
var jm = new WebApiCallBack();
@ -281,7 +293,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
userId = _user.ID;
}
var model = await _goodsServices.GetGoodsDetial(entity.id, userId, false);
var model = await _goodsServices.GetGoodsDetial(id, userId, false);
if (model == null)
{
jm.msg = "商品获取失败";
@ -303,8 +315,8 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetProductInfo([FromBody] FMGetProductInfo entity)
[HttpGet]
public async Task<WebApiCallBack> GetProductInfo([FromQuery] FMGetProductInfo entity)
{
var jm = new WebApiCallBack();
@ -373,8 +385,8 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetGoodsParams([FromBody] FMIntId entity)
[HttpGet]
public async Task<WebApiCallBack> GetGoodsParams([FromQuery] FMIntId entity)
{
var jm = new WebApiCallBack();
@ -424,8 +436,8 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// 获取随机推荐商品
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetGoodsRecommendList([FromBody] FMIntId entity)
[HttpGet]
public async Task<WebApiCallBack> GetGoodsRecommendList([FromQuery] FMIntId entity)
{
if (entity.id <= 0)
{

View File

@ -380,13 +380,14 @@
<summary>
根据查询条件获取分页数据
</summary>
<param name="entity">where={priceFrom:"最低价格",priceTo:"最高价格",catId:"分类",brandId:"品牌",labelId:"标签id",searchName:"商品名称"}</param>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.GoodController.GetDetial(CoreCms.Net.Model.FromBody.FMIntId)">
<member name="M:CoreCms.Net.Web.WebApi.Controllers.GoodController.GetDetial(System.Int32)">
<summary>
获取商品详情
</summary>
<param name="entity"></param>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.GoodController.GetProductInfo(CoreCms.Net.Model.FromBody.FMGetProductInfo)">
@ -467,7 +468,7 @@
<summary>
获取单个公告内容
</summary>
<param name="entity"></param>
<param name="id"></param>
<returns></returns>
</member>
<member name="T:CoreCms.Net.Web.WebApi.Controllers.OrderController">