产品列表图
parent
e9143a08e8
commit
029d0710a0
|
|
@ -9,9 +9,11 @@ import com.wyh.admin.service.IGoodsService;
|
|||
import com.wyh.admin.validate.commons.PageValidate;
|
||||
import com.wyh.common.config.GlobalConfig;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.entity.GoodsImg;
|
||||
import com.wyh.common.entity.goods.Goods;
|
||||
import com.wyh.common.entity.goods.GoodsCate;
|
||||
import com.wyh.common.entity.goods.GoodsExpand;
|
||||
import com.wyh.common.mapper.GoodsImgMapper;
|
||||
import com.wyh.common.mapper.goods.GoodsCateMapper;
|
||||
import com.wyh.common.mapper.goods.GoodsExpandMapper;
|
||||
import com.wyh.common.mapper.goods.GoodsMapper;
|
||||
|
|
@ -30,6 +32,7 @@ import javax.annotation.Resource;
|
|||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 产品信息实现类
|
||||
|
|
@ -37,7 +40,10 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class GoodsServiceImpl implements IGoodsService {
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
GoodsImgMapper goodsImgMapper;
|
||||
@Resource
|
||||
GoodsMapper goodsMapper;
|
||||
|
||||
|
|
@ -81,12 +87,14 @@ public class GoodsServiceImpl implements IGoodsService {
|
|||
item.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
|
||||
if (item.getCateId() != null) {
|
||||
GoodsCate goodsCate = goodsCateMapper.selectOne(Wrappers.<GoodsCate>lambdaQuery().eq(GoodsCate::getId, item.getCateId()).eq(GoodsCate::getIsDelete, 0));
|
||||
|
||||
GoodsCate goodsCate1 = goodsCateMapper.selectOne(Wrappers.<GoodsCate>lambdaQuery().eq(GoodsCate::getId, (goodsCate.getPid())).eq(GoodsCate::getIsDelete, 0));
|
||||
|
||||
|
||||
item.setCateName(goodsCate1.getName() + "-" + goodsCate.getName());
|
||||
}
|
||||
List<GoodsImg> goodsImgs = goodsImgMapper.selectList(Wrappers.<GoodsImg>lambdaQuery().eq(GoodsImg::getGoodsId, item.getId()));
|
||||
if (CollectionUtils.isNotEmpty(goodsImgs)) {
|
||||
List<String> collect = goodsImgs.stream().map(GoodsImg::getImgUrl).collect(Collectors.toList());
|
||||
item.setGoodsListImg(collect);
|
||||
}
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage);
|
||||
|
|
@ -111,6 +119,9 @@ public class GoodsServiceImpl implements IGoodsService {
|
|||
|
||||
GoodsDetailVo vo = new GoodsDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
List<GoodsImg> goodsImgs = goodsImgMapper.selectList(Wrappers.<GoodsImg>lambdaQuery().eq(GoodsImg::getGoodsId, id));
|
||||
List<String> collect = goodsImgs.stream().map(GoodsImg::getImgUrl).collect(Collectors.toList());
|
||||
vo.setGoodsListImg(collect);
|
||||
LinkedList<GoodsExpand> goodsExpands = new LinkedList<>(goodsExpandMapper.selectList(
|
||||
new QueryWrapper<GoodsExpand>()
|
||||
.eq("goods_id", id)
|
||||
|
|
@ -134,7 +145,6 @@ public class GoodsServiceImpl implements IGoodsService {
|
|||
model.setGoodsName(createValidate.getGoodsName());
|
||||
model.setPrice(createValidate.getPrice());
|
||||
model.setGoodsImg(createValidate.getGoodsImg());
|
||||
model.setGoodsListImg(createValidate.getGoodsListImg());
|
||||
model.setSort(createValidate.getSort());
|
||||
model.setType(createValidate.getType());
|
||||
model.setIsDownload(createValidate.getIsDownload());
|
||||
|
|
@ -142,6 +152,15 @@ public class GoodsServiceImpl implements IGoodsService {
|
|||
model.setCateId(createValidate.getCateId());
|
||||
|
||||
goodsMapper.insert(model);
|
||||
if(CollectionUtils.isNotEmpty(createValidate.getGoodsListImg())){
|
||||
goodsImgMapper.delete(Wrappers.<GoodsImg>lambdaQuery().eq(GoodsImg::getGoodsId, model.getId()));
|
||||
for (String s : createValidate.getGoodsListImg()) {
|
||||
GoodsImg goodsImg = new GoodsImg();
|
||||
goodsImg.setGoodsId(model.getId());
|
||||
goodsImg.setImgUrl(s);
|
||||
goodsImgMapper.insert(goodsImg);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(createValidate.getGoodsExpand())) {
|
||||
for (GoodsExpand item : createValidate.getGoodsExpand()) {
|
||||
GoodsExpand goodsExpand = new GoodsExpand();
|
||||
|
|
@ -174,13 +193,21 @@ public class GoodsServiceImpl implements IGoodsService {
|
|||
model.setGoodsName(updateValidate.getGoodsName());
|
||||
model.setPrice(updateValidate.getPrice());
|
||||
model.setGoodsImg(updateValidate.getGoodsImg());
|
||||
model.setGoodsListImg(updateValidate.getGoodsListImg());
|
||||
model.setSort(updateValidate.getSort());
|
||||
model.setType(updateValidate.getType());
|
||||
model.setIsDownload(updateValidate.getIsDownload());
|
||||
model.setSummary(updateValidate.getSummary());
|
||||
model.setCateId(updateValidate.getCateId());
|
||||
goodsMapper.updateById(model);
|
||||
if(CollectionUtils.isNotEmpty(updateValidate.getGoodsListImg())){
|
||||
goodsImgMapper.delete(Wrappers.<GoodsImg>lambdaQuery().eq(GoodsImg::getGoodsId, model.getId()));
|
||||
for (String s : updateValidate.getGoodsListImg()) {
|
||||
GoodsImg goodsImg = new GoodsImg();
|
||||
goodsImg.setGoodsId(model.getId());
|
||||
goodsImg.setImgUrl(s);
|
||||
goodsImgMapper.insert(goodsImg);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateValidate.getGoodsExpand())) {
|
||||
goodsExpandMapper.delete(Wrappers.<GoodsExpand>lambdaQuery().eq(GoodsExpand::getGoodsId, model.getId()));
|
||||
for (GoodsExpand item : updateValidate.getGoodsExpand()) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.wyh.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("产品列表图信息实体")
|
||||
public class GoodsImg implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty(value = "")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "")
|
||||
private Integer goodsId;
|
||||
|
||||
@ApiModelProperty(value = "")
|
||||
private String imgUrl;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.wyh.common.mapper;
|
||||
|
||||
import com.wyh.common.core.basics.IBaseMapper;
|
||||
import com.wyh.common.entity.GoodsImg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 产品列表图信息Mapper
|
||||
* @author wyh
|
||||
*/
|
||||
@Mapper
|
||||
public interface GoodsImgMapper extends IBaseMapper<GoodsImg> {
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ public class GoodsCreateValidate implements Serializable {
|
|||
|
||||
@NotNull(message = "goodsListImg参数缺失")
|
||||
@ApiModelProperty(value = "产品列表图")
|
||||
private String goodsListImg;
|
||||
private List<String> goodsListImg;
|
||||
|
||||
@NotNull(message = "sort参数缺失")
|
||||
@ApiModelProperty(value = "排序")
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class GoodsUpdateValidate implements Serializable {
|
|||
|
||||
@NotNull(message = "goodsListImg参数缺失")
|
||||
@ApiModelProperty(value = "产品列表图")
|
||||
private String goodsListImg;
|
||||
private List<String> goodsListImg;
|
||||
|
||||
@NotNull(message = "sort参数缺失")
|
||||
@ApiModelProperty(value = "排序")
|
||||
|
|
|
|||
|
|
@ -1,15 +1,23 @@
|
|||
package com.wyh.common.vo;
|
||||
|
||||
import com.wyh.common.entity.goods.Goods;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CartVo {
|
||||
@ApiModel("购物车")
|
||||
public class CartVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "购物车商品列表")
|
||||
private List<Goods> goodsList;
|
||||
@ApiModelProperty(value = "购物车商品总价")
|
||||
private BigDecimal totalPrice;
|
||||
@ApiModelProperty(value = "购物车选中商品总金额")
|
||||
private BigDecimal checkTotalPrice;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class GoodsDetailVo implements Serializable {
|
|||
private String goodsImg;
|
||||
|
||||
@ApiModelProperty(value = "产品列表图")
|
||||
private String goodsListImg;
|
||||
private List<String> goodsListImg;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import lombok.Data;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("产品信息列表Vo")
|
||||
|
|
@ -32,7 +33,7 @@ public class GoodsListedVo implements Serializable {
|
|||
private String goodsImg;
|
||||
|
||||
@ApiModelProperty(value = "产品列表图")
|
||||
private String goodsListImg;
|
||||
private List<String> goodsListImg;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.wyh.common.config.GlobalConfig;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.entity.GoodsImg;
|
||||
import com.wyh.common.entity.goods.Goods;
|
||||
import com.wyh.common.entity.goods.GoodsCate;
|
||||
import com.wyh.common.entity.goods.GoodsExpand;
|
||||
import com.wyh.common.mapper.GoodsImgMapper;
|
||||
import com.wyh.common.mapper.goods.GoodsCateMapper;
|
||||
import com.wyh.common.mapper.goods.GoodsExpandMapper;
|
||||
import com.wyh.common.mapper.goods.GoodsMapper;
|
||||
|
|
@ -31,6 +33,7 @@ import javax.annotation.Resource;
|
|||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class GoodsServiceImpl implements GoodsService {
|
||||
|
|
@ -38,6 +41,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|||
@Resource
|
||||
private GoodsMapper goodsMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsImgMapper goodsImgMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsCateMapper goodsCateMapper;
|
||||
|
||||
|
|
@ -124,6 +130,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|||
|
||||
GoodsDetailVo vo = new GoodsDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
List<GoodsImg> goodsImgs = goodsImgMapper.selectList(Wrappers.<GoodsImg>lambdaQuery().eq(GoodsImg::getGoodsId, id));
|
||||
List<String> collect = goodsImgs.stream().map(GoodsImg::getImgUrl).collect(Collectors.toList());
|
||||
vo.setGoodsListImg(collect);
|
||||
LinkedList<GoodsExpand> goodsExpands = new LinkedList<>(goodsExpandMapper.selectList(
|
||||
new QueryWrapper<GoodsExpand>()
|
||||
.eq("goods_id", id)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<material-picker size="300px" v-model="formData.goodsImg" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品列表图" prop="goodsListImg">
|
||||
<material-picker size="300px" v-model="formData.goodsListImg" />
|
||||
<material-picker size="300px" v-model="formData.goodsListImg" limit="10" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<div>
|
||||
|
|
@ -192,9 +192,6 @@ const { optionsData } = useDictOptions<{
|
|||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
for (let i = 0; i < inputs.value.length; i++) {
|
||||
formData.goodsExpand.push(inputs.value[i]);
|
||||
}
|
||||
mode.value == 'edit' ? await goodsEdit(data) : await goodsAdd(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
|
|
@ -213,6 +210,9 @@ const setFormData = async (data: Record<string, any>) => {
|
|||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < data.goodsExpand.length; i++) {
|
||||
inputs.value.push(data.goodsExpand[i])
|
||||
}
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
|
|
@ -220,9 +220,6 @@ const getDetail = async (row: Record<string, any>) => {
|
|||
id: row.id
|
||||
})
|
||||
setFormData(data)
|
||||
for (let i = 0; i < data.goodsExpand.length; i++) {
|
||||
inputs.value.push(data.goodsExpand[i])
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
|
|
|
|||
|
|
@ -56,18 +56,18 @@
|
|||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品列表图" prop="goodsListImg" min-width="100" >
|
||||
<template #default="{ row }">
|
||||
<image-contain
|
||||
:width="100"
|
||||
:height="60"
|
||||
:src="row.goodsListImg"
|
||||
:preview-src-list="[row.goodsListImg]"
|
||||
preview-teleported
|
||||
hide-on-click-modal
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="产品列表图" prop="goodsListImg" min-width="100" >-->
|
||||
<!-- <template #default="{ row }">-->
|
||||
<!-- <image-contain-->
|
||||
<!-- :width="100"-->
|
||||
<!-- :height="60"-->
|
||||
<!-- :src="row.goodsListImg"-->
|
||||
<!-- :preview-src-list="[row.goodsListImg]"-->
|
||||
<!-- preview-teleported-->
|
||||
<!-- hide-on-click-modal-->
|
||||
<!-- />-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column label="排序" prop="sort" min-width="100" />
|
||||
<el-table-column label="是否上架" prop="type" min-width="100" >
|
||||
<template #default="{ row }">
|
||||
|
|
|
|||
Loading…
Reference in New Issue