spu、skus数据测试
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
@@ -34,5 +35,80 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
return Result.Success().SetData(await _iSkuService.SelctPageList(eneity, page));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//数据测试
|
||||
[HttpGet]
|
||||
public async Task<Result> Test(OperEnum operEnum)
|
||||
{
|
||||
switch (operEnum)
|
||||
{
|
||||
case OperEnum.Insert:
|
||||
List<SkuEntity> spus = new();
|
||||
var sku1 = new SkuEntity()
|
||||
{
|
||||
Id = 1,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 1,
|
||||
Price = 1000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="1GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "红" } },
|
||||
};
|
||||
var sku2 = new SkuEntity()
|
||||
{
|
||||
Id = 2,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 1,
|
||||
Price = 4000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="2GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "绿" } },
|
||||
};
|
||||
|
||||
|
||||
var sku3 = new SkuEntity()
|
||||
{
|
||||
Id = 3,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 2,
|
||||
Price = 2000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="3GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "红" } },
|
||||
};
|
||||
var sku4 = new SkuEntity()
|
||||
{
|
||||
Id = 4,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 2,
|
||||
Price = 1000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="2GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "蓝" } },
|
||||
};
|
||||
spus.Add(sku1);
|
||||
spus.Add(sku2);
|
||||
spus.Add(sku3);
|
||||
spus.Add(sku4);
|
||||
await _iSkuService._repository.InsertRangeAsync(spus);
|
||||
break;
|
||||
|
||||
case OperEnum.Delete:
|
||||
await _iSkuService._repository.DeleteAsync((u)=>true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
@@ -34,5 +35,54 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
return Result.Success().SetData(await _iSpuService.SelctPageList(eneity, page));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//数据测试
|
||||
[HttpGet]
|
||||
public async Task<Result> Test(OperEnum operEnum)
|
||||
{
|
||||
switch (operEnum)
|
||||
{
|
||||
case OperEnum.Insert:
|
||||
List<SpuEntity> spus = new();
|
||||
var spu1 = new SpuEntity()
|
||||
{
|
||||
Id = 1,
|
||||
SpuName = "华为mate40 5G手机",
|
||||
IsDeleted = false,
|
||||
Details = "华为手机就是牛",
|
||||
Price = "1000-2000",
|
||||
SpecsSpuAllInfo = new List<SpecsSpuAllInfoModel> {
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="内存",SpecsNames=new List<string> { "1GB","2GB","3GB"} } ,
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="颜色",SpecsNames=new List<string> { "红","蓝","绿"} } },
|
||||
};
|
||||
var spu2 = new SpuEntity()
|
||||
{
|
||||
Id = 2,
|
||||
SpuName = "小米888 8G手机",
|
||||
IsDeleted = false,
|
||||
Details = "小米手机就是牛",
|
||||
Price = "2000-3000",
|
||||
SpecsSpuAllInfo = new List<SpecsSpuAllInfoModel> {
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="内存",SpecsNames=new List<string> { "1GB","2GB","3GB"} } ,
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="颜色",SpecsNames=new List<string> { "红","蓝","绿"} } },
|
||||
};
|
||||
spus.Add(spu1);
|
||||
spus.Add(spu2);
|
||||
await _iSpuService._repository.InsertRangeAsync(spus);
|
||||
break;
|
||||
|
||||
case OperEnum.Delete:
|
||||
await _iSpuService._repository.DeleteAsync((u) => true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -14,7 +14,7 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var data = await _repository._DbQueryable
|
||||
|
||||
.Includes(spu=>spu.Skus)
|
||||
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime)
|
||||
.WhereIF(enetity.IsDeleted is not null, u => u.IsDeleted == enetity.IsDeleted)
|
||||
.OrderBy(u => u.CreateTime, OrderByType.Desc)
|
||||
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.WebCore.BuilderExtend
|
||||
@@ -13,11 +14,14 @@ namespace Yi.Framework.WebCore.BuilderExtend
|
||||
{
|
||||
public static void AddJsonFileService(this IMvcBuilder builder)
|
||||
{
|
||||
builder.AddJsonOptions(options =>
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
|
||||
|
||||
builder.AddNewtonsoftJson(options =>
|
||||
{
|
||||
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm";
|
||||
|
||||
|
||||
//options.SerializerSettings.Converters.Add(new ValueToStringConverter());
|
||||
});
|
||||
|
||||
|
||||
18
Yi.Vue3.x.Vant/src/api/skuApi.ts
Normal file
18
Yi.Vue3.x.Vant/src/api/skuApi.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import myaxios from '@/utils/myaxios'
|
||||
|
||||
export default {
|
||||
add(data:any) {
|
||||
return myaxios({
|
||||
url: `/sku/add`,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
},
|
||||
pageList(data:any) {
|
||||
return myaxios({
|
||||
url: '/sku/pageList',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
}
|
||||
18
Yi.Vue3.x.Vant/src/api/spuApi.ts
Normal file
18
Yi.Vue3.x.Vant/src/api/spuApi.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import myaxios from '@/utils/myaxios'
|
||||
|
||||
export default {
|
||||
add(data:any) {
|
||||
return myaxios({
|
||||
url: `/spu/add`,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
},
|
||||
pageList(data:any) {
|
||||
return myaxios({
|
||||
url: '/spu/pageList',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,34 @@
|
||||
<router-link to="/shopDetails">点击进入商品详情</router-link>
|
||||
<br>
|
||||
<router-link to="/shopIndex">返回商品首页</router-link>
|
||||
</template>
|
||||
这个是spu:
|
||||
<div v-for="item in spuList" :key="item.id">商品名称:{{item.spuName}}
|
||||
<div v-for="spec in item.specsSpuAllInfo" :key="spec">规格组: {{spec.specsGroupName}}
|
||||
<div v-for="name in spec.specsNames" :key="name">规格值: {{name}}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {ref,reactive,toRefs} from 'vue'
|
||||
import spuApi from "@/api/spuApi";
|
||||
const data = reactive({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
// dictName: undefined,
|
||||
// dictType: undefined,
|
||||
isDeleted: false,
|
||||
},
|
||||
});
|
||||
const spuList = ref<any[]>([]);
|
||||
const { queryParams } = toRefs(data);
|
||||
spuApi.pageList(queryParams.value).then((response:any)=>{
|
||||
spuList.value=response.data.data;
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user