1、sku管理功能实现
This commit is contained in:
parent
0a234db339
commit
fcd49fcc1c
|
|
@ -0,0 +1,10 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 获取分页列表
|
||||||
|
export function getSkuList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/mall-product/product/skuinfo/list',
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<div>
|
<div>
|
||||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-input v-model="dataForm.key" placeholder="请输入属性名、可选值等" clearable></el-input>
|
<el-input v-model="dataForm.key" maxlength="100" placeholder="请输入属性名、可选值等" clearable></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button @click="getDataList()">查询</el-button>
|
<el-button @click="getDataList()">查询</el-button>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<div class="mod-config">
|
<div class="mod-config">
|
||||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-input v-model="dataForm.key" placeholder="请输入组名、描述、分类id等" style="width: 300px" clearable></el-input>
|
<el-input v-model="dataForm.key" maxlength="100" placeholder="请输入组名、描述、分类id等" style="width: 300px" clearable></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button-group>
|
<el-button-group>
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,17 @@
|
||||||
<brand-select style="width:160px"></brand-select>
|
<brand-select style="width:160px"></brand-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="价格">
|
<el-form-item label="价格">
|
||||||
<el-input-number style="width:160px" v-model="dataForm.price.min" :min="0"></el-input-number>-
|
<el-input-number style="width:140px" v-model="dataForm.price.min" :min="0"></el-input-number>
|
||||||
<el-input-number style="width:160px" v-model="dataForm.price.max" :min="0"></el-input-number>
|
-
|
||||||
|
<el-input-number style="width:140px" v-model="dataForm.price.max" :min="0"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="检索">
|
<el-form-item label="检索">
|
||||||
<el-input style="width:160px" v-model="dataForm.key" clearable></el-input>
|
<el-input maxlength="100" style="width:300px" v-model="dataForm.key" clearable
|
||||||
|
placeholder="请输入sku名称或描述、标题、副标题等"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="searchSkuInfo">查询</el-button>
|
<el-button size="mini" type="primary" @click="searchSkuInfo">查询</el-button>
|
||||||
|
<el-button size="mini" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
@ -30,26 +33,50 @@
|
||||||
>
|
>
|
||||||
<el-table-column type="expand">
|
<el-table-column type="expand">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
商品标题:{{scope.row.skuTitle}}
|
<el-form label-position="left" class="demo-table-expand">
|
||||||
<br />
|
<el-row :gutter="20">
|
||||||
商品副标题:{{scope.row.skuSubtitle}}
|
<el-col :span="8">
|
||||||
<br />
|
<el-form-item label="商品标题">
|
||||||
商品描述:{{scope.row.skuDesc}}
|
<span>{{ scope.row.skuTitle }}</span>
|
||||||
<br />
|
</el-form-item>
|
||||||
分类ID:{{scope.row.catalogId}}
|
</el-col>
|
||||||
<br />
|
<el-col :span="8">
|
||||||
SpuID:{{scope.row.spuId}}
|
<el-form-item label="商品副标题">
|
||||||
<br />
|
<span>{{ scope.row.skuSubtitle }}</span>
|
||||||
品牌ID:{{scope.row.brandId}}
|
</el-form-item>
|
||||||
<br />
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="商品描述">
|
||||||
|
<span>{{ scope.row.skuDesc }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="分类名称">
|
||||||
|
<span>{{ scope.row.catalogName }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="spu名称">
|
||||||
|
<span>{{ scope.row.spuName }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="品牌名称">
|
||||||
|
<span>{{ scope.row.brandName }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||||
<el-table-column prop="skuId" header-align="center" align="center" label="skuId"></el-table-column>
|
|
||||||
<el-table-column prop="skuName" header-align="center" align="center" label="名称"></el-table-column>
|
<el-table-column prop="skuName" header-align="center" align="center" label="名称"></el-table-column>
|
||||||
<el-table-column prop="skuDefaultImg" header-align="center" align="center" label="默认图片">
|
<el-table-column prop="skuDefaultImg" header-align="center" align="center" label="默认图片">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<img :src="scope.row.skuDefaultImg" style="width:80px;height:80px;" />
|
<img :src="scope.row.skuDefaultImg" style="width:80px;height:80px;"/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="price" header-align="center" align="center" label="价格"></el-table-column>
|
<el-table-column prop="price" header-align="center" align="center" label="价格"></el-table-column>
|
||||||
|
|
@ -93,6 +120,8 @@
|
||||||
<script>
|
<script>
|
||||||
import CategoryCascader from '../../../components/mall/category-cascader'
|
import CategoryCascader from '../../../components/mall/category-cascader'
|
||||||
import BrandSelect from "../../../components/mall/brand-select";
|
import BrandSelect from "../../../components/mall/brand-select";
|
||||||
|
import {getSkuList} from "@/api/mall/product/sku-info";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -121,7 +150,7 @@ export default {
|
||||||
CategoryCascader,
|
CategoryCascader,
|
||||||
BrandSelect
|
BrandSelect
|
||||||
},
|
},
|
||||||
activated() {
|
created() {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -132,7 +161,7 @@ export default {
|
||||||
//处理更多指令
|
//处理更多指令
|
||||||
handleCommand(row, command) {
|
handleCommand(row, command) {
|
||||||
if ("stockSettings" === command) {
|
if ("stockSettings" === command) {
|
||||||
this.$router.push({ path: "/ware-sku", query: { skuId: row.skuId } });
|
this.$router.push({path: "/ware-sku", query: {skuId: row.skuId}});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -142,45 +171,57 @@ export default {
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
this.$http({
|
let params = {
|
||||||
url: this.$http.adornUrl("/product/skuinfo/list"),
|
page: this.pageIndex,
|
||||||
method: "get",
|
limit: this.pageSize,
|
||||||
params: this.$http.adornParams({
|
key: this.dataForm.key,
|
||||||
page: this.pageIndex,
|
catelogId: this.dataForm.catelogId,
|
||||||
limit: this.pageSize,
|
brandId: this.dataForm.brandId,
|
||||||
key: this.dataForm.key,
|
min: this.dataForm.price.min,
|
||||||
catelogId: this.dataForm.catelogId,
|
max: this.dataForm.price.max
|
||||||
brandId: this.dataForm.brandId,
|
}
|
||||||
min: this.dataForm.price.min,
|
getSkuList(params).then(res => {
|
||||||
max: this.dataForm.price.max
|
this.dataList = res.page.list;
|
||||||
})
|
this.totalPage = res.page.totalCount;
|
||||||
}).then(({ data }) => {
|
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.dataList = data.page.list;
|
|
||||||
this.totalPage = data.page.totalCount;
|
|
||||||
} else {
|
|
||||||
this.dataList = [];
|
|
||||||
this.totalPage = 0;
|
|
||||||
}
|
|
||||||
this.dataListLoading = false;
|
this.dataListLoading = false;
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 每页数
|
// 每页数
|
||||||
sizeChangeHandle(val) {
|
sizeChangeHandle(val) {
|
||||||
this.pageSize = val;
|
this.pageSize = val;
|
||||||
this.pageIndex = 1;
|
this.pageIndex = 1;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
|
|
||||||
// 当前页
|
// 当前页
|
||||||
currentChangeHandle(val) {
|
currentChangeHandle(val) {
|
||||||
this.pageIndex = val;
|
this.pageIndex = val;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
|
|
||||||
// 多选
|
// 多选
|
||||||
selectionChangeHandle(val) {
|
selectionChangeHandle(val) {
|
||||||
this.dataListSelections = val;
|
this.dataListSelections = val;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dataForm = {
|
||||||
|
price: {
|
||||||
|
min: 0,
|
||||||
|
max: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$bus.$emit('clearCategoryCascader', [])
|
||||||
|
this.$bus.$emit('clearBrandSelect', [])
|
||||||
|
|
||||||
|
this.pageIndex = 1
|
||||||
|
this.getDataList()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.catPathSub = PubSub.subscribe("catPath", (msg, val) => {
|
this.catPathSub = PubSub.subscribe("catPath", (msg, val) => {
|
||||||
this.dataForm.catelogId = val[val.length - 1];
|
this.dataForm.catelogId = val[val.length - 1];
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,13 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="检索">
|
<el-form-item label="检索">
|
||||||
<el-input style="width:200px" v-model="dataForm.key" clearable placeholder="请输入spu名称或描述"></el-input>
|
<el-input style="width:200px" maxlength="100" v-model="dataForm.key" clearable
|
||||||
|
placeholder="请输入spu名称或描述"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button-group>
|
<el-button-group>
|
||||||
<el-button type="primary" @click="searchSpuInfo" size="mini">查询</el-button>
|
<el-button type="primary" @click="searchSpuInfo" size="mini">查询</el-button>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-button-group>
|
</el-button-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
@ -70,10 +71,10 @@ export default {
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.dataForm={}
|
this.dataForm = {}
|
||||||
// this.catelogPath= []
|
// this.catelogPath= []
|
||||||
this.$bus.$emit('clearCategoryCascader',[])
|
this.$bus.$emit('clearCategoryCascader', [])
|
||||||
this.$bus.$emit('clearBrandSelect',[])
|
this.$bus.$emit('clearBrandSelect', [])
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.page.PageDomain;
|
import com.ruoyi.common.core.web.page.PageDomain;
|
||||||
import com.ruoyi.common.core.web.page.TableSupport;
|
import com.ruoyi.common.core.web.page.TableSupport;
|
||||||
|
import com.xjs.utils.Query;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义通用controller
|
* 自定义通用controller
|
||||||
|
|
@ -45,4 +48,18 @@ public class MyBaseController<T> extends BaseController {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验入参值
|
||||||
|
* @param params 入参值
|
||||||
|
*/
|
||||||
|
protected void checkParams(Map<String, Object> params) {
|
||||||
|
String key = (String) params.get(Query.KEY_NAME);
|
||||||
|
if (StringUtils.isNotEmpty(key)) {
|
||||||
|
if (key.length() > 100) {
|
||||||
|
throw new IllegalArgumentException("key长度超过 100 ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.xjs.mall.product.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.xjs.mall.product.entity.AttrEntity;
|
||||||
import com.xjs.mall.product.service.AttrService;
|
import com.xjs.mall.product.service.AttrService;
|
||||||
import com.xjs.mall.product.vo.AttrGroupRelationVo;
|
import com.xjs.mall.product.vo.AttrGroupRelationVo;
|
||||||
import com.xjs.mall.product.vo.AttrResponseVo;
|
import com.xjs.mall.product.vo.AttrResponseVo;
|
||||||
|
|
@ -10,6 +11,7 @@ import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.mall.other.R;
|
import com.xjs.mall.other.R;
|
||||||
import com.xjs.validation.group.AddGroup;
|
import com.xjs.validation.group.AddGroup;
|
||||||
import com.xjs.validation.group.UpdateGroup;
|
import com.xjs.validation.group.UpdateGroup;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -31,7 +33,7 @@ import java.util.Map;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/attr")
|
@RequestMapping("product/attr")
|
||||||
@Api(tags = "商城-商品-规格参数")
|
@Api(tags = "商城-商品-规格参数")
|
||||||
public class AttrController {
|
public class AttrController extends MyBaseController<AttrEntity> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttrService attrService;
|
private AttrService attrService;
|
||||||
|
|
||||||
|
|
@ -50,6 +52,7 @@ public class AttrController {
|
||||||
public R baseAttrList(@RequestParam Map<String, Object> params,
|
public R baseAttrList(@RequestParam Map<String, Object> params,
|
||||||
@PathVariable("attrType") String attrType,
|
@PathVariable("attrType") String attrType,
|
||||||
@PathVariable("catelogId") Long catelogId) {
|
@PathVariable("catelogId") Long catelogId) {
|
||||||
|
super.checkParams(params);
|
||||||
PageUtils page = attrService.queryBaseAttrPage(params, catelogId, attrType);
|
PageUtils page = attrService.queryBaseAttrPage(params, catelogId, attrType);
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.mall.other.R;
|
import com.xjs.mall.other.R;
|
||||||
import com.xjs.validation.group.AddGroup;
|
import com.xjs.validation.group.AddGroup;
|
||||||
import com.xjs.validation.group.UpdateGroup;
|
import com.xjs.validation.group.UpdateGroup;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -36,7 +37,7 @@ import java.util.stream.Collectors;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/attrgroup")
|
@RequestMapping("product/attrgroup")
|
||||||
@Api(tags = "商城-商品-属性分组")
|
@Api(tags = "商城-商品-属性分组")
|
||||||
public class AttrGroupController {
|
public class AttrGroupController extends MyBaseController<AttrGroupEntity> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttrGroupService attrGroupService;
|
private AttrGroupService attrGroupService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -95,7 +96,7 @@ public class AttrGroupController {
|
||||||
@GetMapping("/list/{catelogId}")
|
@GetMapping("/list/{catelogId}")
|
||||||
@ApiOperation("列表")
|
@ApiOperation("列表")
|
||||||
public R list(@RequestParam Map<String, Object> params, Long catelogId) {
|
public R list(@RequestParam Map<String, Object> params, Long catelogId) {
|
||||||
|
super.checkParams(params);
|
||||||
PageUtils page = attrGroupService.queryPage(params, catelogId);
|
PageUtils page = attrGroupService.queryPage(params, catelogId);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.xjs.mall.other.R;
|
||||||
import com.xjs.validation.group.AddGroup;
|
import com.xjs.validation.group.AddGroup;
|
||||||
import com.xjs.validation.group.SelectGroup;
|
import com.xjs.validation.group.SelectGroup;
|
||||||
import com.xjs.validation.group.UpdateGroup;
|
import com.xjs.validation.group.UpdateGroup;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -30,7 +31,7 @@ import java.util.Map;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/brand")
|
@RequestMapping("product/brand")
|
||||||
@Api(tags = "商城-商品-品牌")
|
@Api(tags = "商城-商品-品牌")
|
||||||
public class BrandController {
|
public class BrandController extends MyBaseController<BrandEntity> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BrandService brandService;
|
private BrandService brandService;
|
||||||
|
|
||||||
|
|
@ -40,6 +41,7 @@ public class BrandController {
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation("列表")
|
@ApiOperation("列表")
|
||||||
public R list(@Validated(SelectGroup.class) @RequestParam Map<String, Object> params){
|
public R list(@Validated(SelectGroup.class) @RequestParam Map<String, Object> params){
|
||||||
|
super.checkParams(params);
|
||||||
PageUtils page = brandService.queryPage(params);
|
PageUtils page = brandService.queryPage(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ import com.xjs.mall.product.entity.SkuInfoEntity;
|
||||||
import com.xjs.mall.product.service.SkuInfoService;
|
import com.xjs.mall.product.service.SkuInfoService;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.mall.other.R;
|
import com.xjs.mall.other.R;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -23,7 +25,7 @@ import java.util.Map;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/skuinfo")
|
@RequestMapping("product/skuinfo")
|
||||||
@Api(tags = "商城-商品-SKU信息")
|
@Api(tags = "商城-商品-SKU信息")
|
||||||
public class SkuInfoController {
|
public class SkuInfoController extends MyBaseController<SkuInfoEntity> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SkuInfoService skuInfoService;
|
private SkuInfoService skuInfoService;
|
||||||
|
|
||||||
|
|
@ -31,8 +33,10 @@ public class SkuInfoController {
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
|
@ApiOperation("列表")
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestParam Map<String, Object> params){
|
||||||
PageUtils page = skuInfoService.queryPage(params);
|
super.checkParams(params);
|
||||||
|
PageUtils page = skuInfoService.queryPageByCondition(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.xjs.mall.product.service.SpuInfoService;
|
||||||
import com.xjs.mall.product.vo.spu.SpuSaveVo;
|
import com.xjs.mall.product.vo.spu.SpuSaveVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.validation.group.AddGroup;
|
import com.xjs.validation.group.AddGroup;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -26,7 +27,7 @@ import java.util.Map;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/spuinfo")
|
@RequestMapping("product/spuinfo")
|
||||||
@Api(tags = "商城-商品-SPU信息")
|
@Api(tags = "商城-商品-SPU信息")
|
||||||
public class SpuInfoController {
|
public class SpuInfoController extends MyBaseController<SpuInfoEntity> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SpuInfoService spuInfoService;
|
private SpuInfoService spuInfoService;
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ public class SpuInfoController {
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
@ApiOperation("列表")
|
@ApiOperation("列表")
|
||||||
public R list(@RequestParam Map<String, Object> params) {
|
public R list(@RequestParam Map<String, Object> params) {
|
||||||
|
super.checkParams(params);
|
||||||
PageUtils page = spuInfoService.queryPageByCondition(params);
|
PageUtils page = spuInfoService.queryPageByCondition(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,18 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface SkuInfoService extends IService<SkuInfoEntity> {
|
public interface SkuInfoService extends IService<SkuInfoEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存sku信息
|
* 保存sku信息
|
||||||
* @param skuInfoEntity sku实体类
|
* @param skuInfoEntity sku实体类
|
||||||
*/
|
*/
|
||||||
void saveSkuInfo(SkuInfoEntity skuInfoEntity);
|
void saveSkuInfo(SkuInfoEntity skuInfoEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件检索列表
|
||||||
|
* @param params 条件
|
||||||
|
* @return page
|
||||||
|
*/
|
||||||
|
PageUtils queryPageByCondition(Map<String, Object> params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,93 @@
|
||||||
package com.xjs.mall.product.service.impl;
|
package com.xjs.mall.product.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.xjs.mall.product.dao.SkuInfoDao;
|
import com.xjs.mall.product.dao.SkuInfoDao;
|
||||||
|
import com.xjs.mall.product.entity.BrandEntity;
|
||||||
|
import com.xjs.mall.product.entity.CategoryEntity;
|
||||||
import com.xjs.mall.product.entity.SkuInfoEntity;
|
import com.xjs.mall.product.entity.SkuInfoEntity;
|
||||||
|
import com.xjs.mall.product.entity.SpuInfoEntity;
|
||||||
|
import com.xjs.mall.product.service.BrandService;
|
||||||
|
import com.xjs.mall.product.service.CategoryService;
|
||||||
import com.xjs.mall.product.service.SkuInfoService;
|
import com.xjs.mall.product.service.SkuInfoService;
|
||||||
|
import com.xjs.mall.product.service.SpuInfoService;
|
||||||
|
import com.xjs.mall.product.vo.spu.SkuInfoVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.utils.Query;
|
import com.xjs.utils.Query;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("skuInfoService")
|
@Service("skuInfoService")
|
||||||
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> implements SkuInfoService {
|
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> implements SkuInfoService {
|
||||||
|
|
||||||
@Override
|
@Autowired
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
private SpuInfoService spuInfoService;
|
||||||
IPage<SkuInfoEntity> page = this.page(
|
@Autowired
|
||||||
new Query<SkuInfoEntity>().getPage(params),
|
private CategoryService categoryService;
|
||||||
new QueryWrapper<SkuInfoEntity>()
|
@Autowired
|
||||||
);
|
private BrandService brandService;
|
||||||
|
|
||||||
return new PageUtils(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
|
public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
|
||||||
super.baseMapper.insert(skuInfoEntity);
|
super.baseMapper.insert(skuInfoEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageUtils queryPageByCondition(Map<String, Object> params) {
|
||||||
|
LambdaQueryWrapper<SkuInfoEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
String key = (String) params.get(Query.KEY_NAME);
|
||||||
|
String brandId = (String) params.get("brandId");
|
||||||
|
String catelogId = (String) params.get("catelogId");
|
||||||
|
String min = (String) params.get("min");
|
||||||
|
String max = (String) params.get("max");
|
||||||
|
|
||||||
|
wrapper.and(StringUtils.isNotEmpty(key), wr -> {
|
||||||
|
wr.like(SkuInfoEntity::getSkuName, key).or()
|
||||||
|
.like(SkuInfoEntity::getSkuDesc, key).or()
|
||||||
|
.like(SkuInfoEntity::getSkuTitle, key).or()
|
||||||
|
.like(SkuInfoEntity::getSkuSubtitle, key);
|
||||||
|
})
|
||||||
|
.eq(StringUtils.isNotEmpty(brandId) && !"0".equalsIgnoreCase(brandId), SkuInfoEntity::getBrandId, brandId)
|
||||||
|
.eq(StringUtils.isNotEmpty(catelogId) && !"0".equalsIgnoreCase(catelogId), SkuInfoEntity::getCatalogId, catelogId)
|
||||||
|
.ge(StringUtils.isNotEmpty(min) && !"0".equalsIgnoreCase(min), SkuInfoEntity::getPrice, min)
|
||||||
|
.le(StringUtils.isNotEmpty(max) && !"0".equalsIgnoreCase(max), SkuInfoEntity::getPrice, max)
|
||||||
|
.orderByDesc(SkuInfoEntity::getSkuId);
|
||||||
|
|
||||||
|
IPage<SkuInfoEntity> page = this.page(new Query<SkuInfoEntity>().getPage(params), wrapper);
|
||||||
|
|
||||||
|
List<SkuInfoEntity> records = page.getRecords();
|
||||||
|
List<SkuInfoVo> collect = records.stream().map(skuInfoEntity -> {
|
||||||
|
SkuInfoVo skuInfoVo = new SkuInfoVo();
|
||||||
|
BeanUtils.copyProperties(skuInfoEntity, skuInfoVo);
|
||||||
|
|
||||||
|
//获取spu信息
|
||||||
|
SpuInfoEntity spuInfoEntity = spuInfoService.getById(skuInfoVo.getSpuId());
|
||||||
|
skuInfoVo.setSpuName(spuInfoEntity.getSpuName());
|
||||||
|
|
||||||
|
//获取三级分类信息
|
||||||
|
CategoryEntity categoryEntity = categoryService.getById(skuInfoVo.getCatalogId());
|
||||||
|
skuInfoVo.setCatalogName(categoryEntity.getName());
|
||||||
|
|
||||||
|
//获取品牌信息
|
||||||
|
BrandEntity brandEntity = brandService.getById(skuInfoVo.getBrandId());
|
||||||
|
skuInfoVo.setBrandName(brandEntity.getName());
|
||||||
|
|
||||||
|
return skuInfoVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
PageUtils pageUtils = new PageUtils(page);
|
||||||
|
pageUtils.setList(collect);
|
||||||
|
return pageUtils;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> i
|
||||||
skuInfoEntity.setSaleCount(0L); //销量默认0
|
skuInfoEntity.setSaleCount(0L); //销量默认0
|
||||||
skuInfoEntity.setSpuId(spuInfoEntity.getId());
|
skuInfoEntity.setSpuId(spuInfoEntity.getId());
|
||||||
skuInfoEntity.setSkuDefaultImg(defaultImg);
|
skuInfoEntity.setSkuDefaultImg(defaultImg);
|
||||||
|
skuInfoEntity.setSkuDesc(spuInfoEntity.getSpuDescription());
|
||||||
skuInfoService.saveSkuInfo(skuInfoEntity);
|
skuInfoService.saveSkuInfo(skuInfoEntity);
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sku信息展示vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SkuInfoVo {
|
||||||
|
private Long skuId;
|
||||||
|
/**
|
||||||
|
* spuId
|
||||||
|
*/
|
||||||
|
private Long spuId;
|
||||||
|
/**
|
||||||
|
* sku名称
|
||||||
|
*/
|
||||||
|
private String skuName;
|
||||||
|
/**
|
||||||
|
* sku介绍描述
|
||||||
|
*/
|
||||||
|
private String skuDesc;
|
||||||
|
/**
|
||||||
|
* 所属分类id
|
||||||
|
*/
|
||||||
|
private Long catalogId;
|
||||||
|
/**
|
||||||
|
* 品牌id
|
||||||
|
*/
|
||||||
|
private Long brandId;
|
||||||
|
/**
|
||||||
|
* 默认图片
|
||||||
|
*/
|
||||||
|
private String skuDefaultImg;
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String skuTitle;
|
||||||
|
/**
|
||||||
|
* 副标题
|
||||||
|
*/
|
||||||
|
private String skuSubtitle;
|
||||||
|
/**
|
||||||
|
* 价格
|
||||||
|
*/
|
||||||
|
private BigDecimal price;
|
||||||
|
/**
|
||||||
|
* 销量
|
||||||
|
*/
|
||||||
|
private Long saleCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
private String catalogName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spu名
|
||||||
|
*/
|
||||||
|
private String spuName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌名称
|
||||||
|
*/
|
||||||
|
private String brandName;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue