产品信息完成
parent
41aaca4378
commit
db54a23466
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.wyh.admin.controller.goods;
|
||||||
|
|
||||||
|
import com.wyh.admin.aop.Log;
|
||||||
|
import com.wyh.admin.service.IGoodsService;
|
||||||
|
import com.wyh.admin.validate.commons.IdValidate;
|
||||||
|
import com.wyh.admin.validate.commons.PageValidate;
|
||||||
|
import com.wyh.common.core.AjaxResult;
|
||||||
|
import com.wyh.common.core.PageResult;
|
||||||
|
import com.wyh.common.validator.annotation.IDMust;
|
||||||
|
import com.wyh.common.validator.goods.GoodsCreateValidate;
|
||||||
|
import com.wyh.common.validator.goods.GoodsSearchValidate;
|
||||||
|
import com.wyh.common.validator.goods.GoodsUpdateValidate;
|
||||||
|
import com.wyh.common.vo.goods.GoodsDetailVo;
|
||||||
|
import com.wyh.common.vo.goods.GoodsListedVo;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/goods")
|
||||||
|
@Api(tags = "产品信息管理")
|
||||||
|
public class GoodsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IGoodsService iGoodsService;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation(value="产品信息列表")
|
||||||
|
public AjaxResult<PageResult<GoodsListedVo>> list(@Validated PageValidate pageValidate,
|
||||||
|
@Validated GoodsSearchValidate searchValidate) {
|
||||||
|
PageResult<GoodsListedVo> list = iGoodsService.list(pageValidate, searchValidate);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/detail")
|
||||||
|
@ApiOperation(value="产品信息详情")
|
||||||
|
public AjaxResult<GoodsDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||||
|
GoodsDetailVo detail = iGoodsService.detail(id);
|
||||||
|
return AjaxResult.success(detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "产品信息新增")
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation(value="产品信息新增")
|
||||||
|
public AjaxResult<Object> add(@Validated @RequestBody GoodsCreateValidate createValidate) {
|
||||||
|
iGoodsService.add(createValidate);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "产品信息编辑")
|
||||||
|
@PostMapping("/edit")
|
||||||
|
@ApiOperation(value="产品信息编辑")
|
||||||
|
public AjaxResult<Object> edit(@Validated @RequestBody GoodsUpdateValidate updateValidate) {
|
||||||
|
iGoodsService.edit(updateValidate);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "产品信息删除")
|
||||||
|
@PostMapping("/del")
|
||||||
|
@ApiOperation(value="产品信息删除")
|
||||||
|
public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
|
||||||
|
iGoodsService.del(idValidate.getId());
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.wyh.admin.service;
|
||||||
|
|
||||||
|
import com.wyh.admin.validate.commons.PageValidate;
|
||||||
|
import com.wyh.common.core.PageResult;
|
||||||
|
import com.wyh.common.validator.goods.GoodsCreateValidate;
|
||||||
|
import com.wyh.common.validator.goods.GoodsSearchValidate;
|
||||||
|
import com.wyh.common.validator.goods.GoodsUpdateValidate;
|
||||||
|
import com.wyh.common.vo.goods.GoodsDetailVo;
|
||||||
|
import com.wyh.common.vo.goods.GoodsListedVo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息服务接口类
|
||||||
|
* @author LikeAdmin
|
||||||
|
*/
|
||||||
|
public interface IGoodsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息列表
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param pageValidate 分页参数
|
||||||
|
* @param searchValidate 搜索参数
|
||||||
|
* @return PageResult<GoodsListedVo>
|
||||||
|
*/
|
||||||
|
PageResult<GoodsListedVo> list(PageValidate pageValidate, GoodsSearchValidate searchValidate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息详情
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param id 主键ID
|
||||||
|
* @return GoodsDetailVo
|
||||||
|
*/
|
||||||
|
GoodsDetailVo detail(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息新增
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param createValidate 参数
|
||||||
|
*/
|
||||||
|
void add(GoodsCreateValidate createValidate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息编辑
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param updateValidate 参数
|
||||||
|
*/
|
||||||
|
void edit(GoodsUpdateValidate updateValidate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息删除
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param id 主键ID
|
||||||
|
*/
|
||||||
|
void del(Integer id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
package com.wyh.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.yulichang.query.MPJQueryWrapper;
|
||||||
|
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.goods.Goods;
|
||||||
|
import com.wyh.common.entity.goods.GoodsCate;
|
||||||
|
import com.wyh.common.mapper.goods.GoodsCateMapper;
|
||||||
|
import com.wyh.common.mapper.goods.GoodsMapper;
|
||||||
|
import com.wyh.common.util.TimeUtils;
|
||||||
|
import com.wyh.common.validator.goods.GoodsCreateValidate;
|
||||||
|
import com.wyh.common.validator.goods.GoodsSearchValidate;
|
||||||
|
import com.wyh.common.validator.goods.GoodsUpdateValidate;
|
||||||
|
import com.wyh.common.vo.goods.GoodsDetailVo;
|
||||||
|
import com.wyh.common.vo.goods.GoodsListedVo;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息实现类
|
||||||
|
* @author wyh
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GoodsServiceImpl implements IGoodsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsMapper goodsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsCateMapper goodsCateMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息列表
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param pageValidate 分页参数
|
||||||
|
* @param searchValidate 搜索参数
|
||||||
|
* @return PageResult<GoodsListedVo>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<GoodsListedVo> list(PageValidate pageValidate, GoodsSearchValidate searchValidate) {
|
||||||
|
Integer page = pageValidate.getPageNo();
|
||||||
|
Integer limit = pageValidate.getPageSize();
|
||||||
|
|
||||||
|
MPJQueryWrapper<Goods> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||||
|
mpjQueryWrapper.selectAll(Goods.class);
|
||||||
|
mpjQueryWrapper.innerJoin("?_goods_cate gc ON gc.id=t.cate_id".replace("?_", GlobalConfig.tablePrefix));
|
||||||
|
mpjQueryWrapper.eq("t.is_delete", 0);
|
||||||
|
mpjQueryWrapper.orderByDesc(Arrays.asList("t.sort", "t.id"));
|
||||||
|
|
||||||
|
goodsMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{
|
||||||
|
"like:goodsName@goods_name:str",
|
||||||
|
"=:cateId@cate_id:int",
|
||||||
|
});
|
||||||
|
|
||||||
|
IPage<GoodsListedVo> iPage = goodsMapper.selectJoinPage(
|
||||||
|
new Page<>(page, limit),
|
||||||
|
GoodsListedVo.class,
|
||||||
|
mpjQueryWrapper);
|
||||||
|
|
||||||
|
for(GoodsListedVo item : iPage.getRecords()) {
|
||||||
|
item.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageResult.iPageHandle(iPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息详情
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param id 主键参数
|
||||||
|
* @return Goods
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public GoodsDetailVo detail(Integer id) {
|
||||||
|
Goods model = goodsMapper.selectOne(
|
||||||
|
new QueryWrapper<Goods>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
GoodsDetailVo vo = new GoodsDetailVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息新增
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param createValidate 参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void add(GoodsCreateValidate createValidate) {
|
||||||
|
Goods model = new Goods();
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
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());
|
||||||
|
model.setSummary(createValidate.getSummary());
|
||||||
|
model.setCateId(createValidate.getCateId());
|
||||||
|
goodsMapper.insert(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息编辑
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param updateValidate 参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void edit(GoodsUpdateValidate updateValidate) {
|
||||||
|
Goods model = goodsMapper.selectOne(
|
||||||
|
new QueryWrapper<Goods>()
|
||||||
|
.eq("id", updateValidate.getId())
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
model.setId(updateValidate.getId());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息删除
|
||||||
|
*
|
||||||
|
* @author LikeAdmin
|
||||||
|
* @param id 主键ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void del(Integer id) {
|
||||||
|
Goods model = goodsMapper.selectOne(
|
||||||
|
new QueryWrapper<Goods>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
model.setIsDelete(1);
|
||||||
|
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||||
|
goodsMapper.updateById(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,6 @@ spring:
|
||||||
database: 14 # 数据库索引
|
database: 14 # 数据库索引
|
||||||
|
|
||||||
# Mybatis-plus配置 【是否开启SQL日志输出】
|
# Mybatis-plus配置 【是否开启SQL日志输出】
|
||||||
#mybatis-plus:
|
mybatis-plus:
|
||||||
# configuration:
|
configuration:
|
||||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.wyh.common.entity.goods;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品信息实体")
|
||||||
|
public class Goods implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value="id", type= IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否删除: 0=否, 1=是")
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Long createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private Long updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "删除时间")
|
||||||
|
private Long deleteTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String goodsName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品主图")
|
||||||
|
private String goodsImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品列表图")
|
||||||
|
private String goodsListImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否上架0:否,1:是")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否下载")
|
||||||
|
private Integer isDownload;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "实验室说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类")
|
||||||
|
private Integer cateId;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.wyh.common.mapper.goods;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wyh.common.core.basics.IBaseMapper;
|
||||||
|
import com.wyh.common.entity.goods.Goods;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息Mapper
|
||||||
|
* @author LikeAdmin
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface GoodsMapper extends IBaseMapper<Goods> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.wyh.common.validator.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品分类创建参数")
|
||||||
|
public class GoodsCateCreateValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "name参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品分类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@NotNull(message = "pid参数缺失")
|
||||||
|
@ApiModelProperty(value = "上级菜单")
|
||||||
|
private Integer pid;
|
||||||
|
|
||||||
|
@NotNull(message = "sort参数缺失")
|
||||||
|
@ApiModelProperty(value = "排序编号")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@NotNull(message = "isShow参数缺失")
|
||||||
|
@ApiModelProperty(value = "是否显示: 0=否, 1=是")
|
||||||
|
private Integer isShow;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.wyh.common.validator.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品分类搜素参数")
|
||||||
|
public class GoodsCateSearchValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上级菜单")
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序编号")
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否显示: 0=否, 1=是")
|
||||||
|
private String isShow;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.wyh.common.validator.goods;
|
||||||
|
|
||||||
|
import com.wyh.common.validator.annotation.IDMust;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类参数
|
||||||
|
* @author LikeAdmin
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品分类更新参数")
|
||||||
|
public class GoodsCateUpdateValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@IDMust(message = "id参数必传且需大于0")
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@NotNull(message = "name参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品分类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@NotNull(message = "pid参数缺失")
|
||||||
|
@ApiModelProperty(value = "上级菜单")
|
||||||
|
private Integer pid;
|
||||||
|
|
||||||
|
@NotNull(message = "sort参数缺失")
|
||||||
|
@ApiModelProperty(value = "排序编号")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@NotNull(message = "isShow参数缺失")
|
||||||
|
@ApiModelProperty(value = "是否显示: 0=否, 1=是")
|
||||||
|
private Integer isShow;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.wyh.common.validator.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品信息创建参数")
|
||||||
|
public class GoodsCreateValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsName参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String goodsName;
|
||||||
|
|
||||||
|
@NotNull(message = "price参数缺失")
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsImg参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品主图")
|
||||||
|
private String goodsImg;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsListImg参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品列表图")
|
||||||
|
private String goodsListImg;
|
||||||
|
|
||||||
|
@NotNull(message = "sort参数缺失")
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@NotNull(message = "type参数缺失")
|
||||||
|
@ApiModelProperty(value = "是否上架0:否,1:是")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@NotNull(message = "isDownload参数缺失")
|
||||||
|
@ApiModelProperty(value = "是否下载")
|
||||||
|
private Integer isDownload;
|
||||||
|
|
||||||
|
@NotNull(message = "summary参数缺失")
|
||||||
|
@ApiModelProperty(value = "实验室说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@NotNull(message = "cateId参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品分类")
|
||||||
|
private Integer cateId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.wyh.common.validator.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品信息搜素参数")
|
||||||
|
public class GoodsSearchValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String goodsName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品主图")
|
||||||
|
private String goodsImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品列表图")
|
||||||
|
private String goodsListImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否上架0:否,1:是")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否下载")
|
||||||
|
private Integer isDownload;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "实验室说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类")
|
||||||
|
private Integer cateId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.wyh.common.validator.goods;
|
||||||
|
|
||||||
|
import com.wyh.common.validator.annotation.IDMust;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品信息参数
|
||||||
|
* @author LikeAdmin
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品信息更新参数")
|
||||||
|
public class GoodsUpdateValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@IDMust(message = "id参数必传且需大于0")
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsName参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String goodsName;
|
||||||
|
|
||||||
|
@NotNull(message = "price参数缺失")
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsImg参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品主图")
|
||||||
|
private String goodsImg;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsListImg参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品列表图")
|
||||||
|
private String goodsListImg;
|
||||||
|
|
||||||
|
@NotNull(message = "sort参数缺失")
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@NotNull(message = "type参数缺失")
|
||||||
|
@ApiModelProperty(value = "是否上架0:否,1:是")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@NotNull(message = "isDownload参数缺失")
|
||||||
|
@ApiModelProperty(value = "是否下载")
|
||||||
|
private Integer isDownload;
|
||||||
|
|
||||||
|
@NotNull(message = "summary参数缺失")
|
||||||
|
@ApiModelProperty(value = "实验室说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@NotNull(message = "cateId参数缺失")
|
||||||
|
@ApiModelProperty(value = "产品分类")
|
||||||
|
private Integer cateId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.wyh.common.vo.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品分类详情Vo")
|
||||||
|
public class GoodsCateDetailVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上级菜单")
|
||||||
|
private Integer pid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序编号")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否显示: 0=否, 1=是")
|
||||||
|
private Integer isShow;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.wyh.common.vo.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品分类列表Vo")
|
||||||
|
public class GoodsCateListedVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上级菜单")
|
||||||
|
private Integer pid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private String updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序编号")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否显示: 0=否, 1=是")
|
||||||
|
private Integer isShow;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.wyh.common.vo.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品信息详情Vo")
|
||||||
|
public class GoodsDetailVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String goodsName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品主图")
|
||||||
|
private String goodsImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品列表图")
|
||||||
|
private String goodsListImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否上架0:否,1:是")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否下载")
|
||||||
|
private Integer isDownload;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "实验室说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类")
|
||||||
|
private Integer cateId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.wyh.common.vo.goods;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("产品信息列表Vo")
|
||||||
|
public class GoodsListedVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private String updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String goodsName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品主图")
|
||||||
|
private String goodsImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品列表图")
|
||||||
|
private String goodsListImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否上架0:否,1:是")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否下载")
|
||||||
|
private Integer isDownload;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "实验室说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类")
|
||||||
|
private Integer cateId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品分类名称")
|
||||||
|
private String cateName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.wyh.front.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.wyh.common.aop.NotLogin;
|
||||||
|
import com.wyh.common.core.AjaxResult;
|
||||||
|
import com.wyh.common.validator.goods.GoodsCateSearchValidate;
|
||||||
|
import com.wyh.front.service.GoodsService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("front/goods")
|
||||||
|
@Api(tags = "产品信息")
|
||||||
|
public class GoodsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoodsService goodsService;
|
||||||
|
|
||||||
|
@NotLogin
|
||||||
|
@RequestMapping("/cate/tree")
|
||||||
|
@ApiOperation(value = "产品分类树", httpMethod = "GET" )
|
||||||
|
public AjaxResult<JSONArray> cateTree(@Validated GoodsCateSearchValidate searchValidate) {
|
||||||
|
JSONArray list = goodsService.cateTree(searchValidate);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,25 +2,22 @@ package com.wyh.front.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.wyh.common.aop.NotLogin;
|
import com.wyh.common.aop.NotLogin;
|
||||||
import com.wyh.common.aop.NotPower;
|
|
||||||
import com.wyh.common.core.AjaxResult;
|
import com.wyh.common.core.AjaxResult;
|
||||||
import com.wyh.common.core.PageResult;
|
import com.wyh.common.core.PageResult;
|
||||||
import com.wyh.common.validator.annotation.IDMust;
|
import com.wyh.common.validator.annotation.IDMust;
|
||||||
import com.wyh.common.validator.news.NewsCreateValidate;
|
|
||||||
import com.wyh.common.validator.news.NewsSearchValidate;
|
import com.wyh.common.validator.news.NewsSearchValidate;
|
||||||
import com.wyh.common.validator.news.NewsUpdateValidate;
|
|
||||||
import com.wyh.common.vo.news.NewsCateListedVo;
|
import com.wyh.common.vo.news.NewsCateListedVo;
|
||||||
import com.wyh.common.vo.news.NewsDetailVo;
|
import com.wyh.common.vo.news.NewsDetailVo;
|
||||||
import com.wyh.common.vo.news.NewsListedVo;
|
import com.wyh.common.vo.news.NewsListedVo;
|
||||||
import com.wyh.front.service.INewsService;
|
import com.wyh.front.service.INewsService;
|
||||||
import com.wyh.front.validate.common.IdValidate;
|
|
||||||
import com.wyh.front.validate.common.PageValidate;
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.java.Log;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.wyh.front.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.wyh.common.validator.goods.GoodsCateSearchValidate;
|
||||||
|
|
||||||
|
public interface GoodsService {
|
||||||
|
JSONArray cateTree( GoodsCateSearchValidate searchValidate);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.wyh.front.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.github.yulichang.query.MPJQueryWrapper;
|
||||||
|
import com.wyh.common.entity.goods.GoodsCate;
|
||||||
|
import com.wyh.common.mapper.goods.GoodsCateMapper;
|
||||||
|
import com.wyh.common.mapper.goods.GoodsMapper;
|
||||||
|
import com.wyh.common.util.ListUtils;
|
||||||
|
import com.wyh.common.util.TimeUtils;
|
||||||
|
import com.wyh.common.validator.goods.GoodsCateSearchValidate;
|
||||||
|
import com.wyh.common.vo.goods.GoodsCateListedVo;
|
||||||
|
import com.wyh.front.service.GoodsService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GoodsServiceImpl implements GoodsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoodsMapper goodsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoodsCateMapper goodsCateMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONArray cateTree(GoodsCateSearchValidate searchValidate) {
|
||||||
|
MPJQueryWrapper<GoodsCate> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||||
|
mpjQueryWrapper.selectAll(GoodsCate.class);
|
||||||
|
mpjQueryWrapper.eq("is_delete", 0);
|
||||||
|
mpjQueryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
|
||||||
|
goodsCateMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{
|
||||||
|
"like:name:str",
|
||||||
|
"=:pid:str",
|
||||||
|
"=:sort:str",
|
||||||
|
"=:isShow@is_show:int",
|
||||||
|
});
|
||||||
|
|
||||||
|
List<GoodsCateListedVo> array = goodsCateMapper.selectJoinList(
|
||||||
|
GoodsCateListedVo.class,
|
||||||
|
mpjQueryWrapper);
|
||||||
|
|
||||||
|
for(GoodsCateListedVo item : array) {
|
||||||
|
item.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
|
||||||
|
item.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(array));
|
||||||
|
return ListUtils.listToTree(jsonArray, "id", "pid", "children");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 产品信息列表
|
||||||
|
export function goodsLists(params?: Record<string, any>) {
|
||||||
|
return request.get({ url: '/goods/list', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 产品信息详情
|
||||||
|
export function goodsDetail(params: Record<string, any>) {
|
||||||
|
return request.get({ url: '/goods/detail', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 产品信息新增
|
||||||
|
export function goodsAdd(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/goods/add', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 产品信息编辑
|
||||||
|
export function goodsEdit(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/goods/edit', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 产品信息删除
|
||||||
|
export function goodsDelete(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/goods/del', params })
|
||||||
|
}
|
||||||
|
|
@ -1,31 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="index-tree">
|
<div class="index-tree">
|
||||||
<el-card class="!border-none mb-4" shadow="never">
|
|
||||||
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
|
|
||||||
<el-form-item label="产品分类名称" prop="name">
|
|
||||||
<el-input class="w-[280px]" v-model="queryParams.name" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否显示" prop="status">
|
|
||||||
<el-select
|
|
||||||
v-model="queryParams.isShow"
|
|
||||||
class="w-[280px]"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option label="全部" value="" />
|
|
||||||
<el-option
|
|
||||||
v-for="(item, index) in dictData.Integer"
|
|
||||||
:key="index"
|
|
||||||
:label="item.name"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getLists">查询</el-button>
|
|
||||||
<el-button @click="resetParams">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
<el-card class="!border-none" shadow="never">
|
<el-card class="!border-none" shadow="never">
|
||||||
<div>
|
<div>
|
||||||
<el-button v-perms="['cate:add']" type="primary" @click="handleAdd()">
|
<el-button v-perms="['cate:add']" type="primary" @click="handleAdd()">
|
||||||
|
|
@ -46,12 +21,10 @@
|
||||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||||
>
|
>
|
||||||
<el-table-column label="产品分类名称" prop="name" min-width="100" />
|
<el-table-column label="产品分类名称" prop="name" min-width="100" />
|
||||||
<el-table-column label="上级菜单" prop="pid" min-width="100" />
|
|
||||||
<el-table-column label="创建时间" prop="createTime" min-width="100" />
|
<el-table-column label="创建时间" prop="createTime" min-width="100" />
|
||||||
<el-table-column label="更新时间" prop="updateTime" min-width="100" />
|
<el-table-column label="更新时间" prop="updateTime" min-width="100" />
|
||||||
<el-table-column label="排序编号" prop="sort" min-width="100" />
|
<el-table-column label="排序编号" prop="sort" min-width="100" />
|
||||||
<el-table-column label="是否显示" prop="isShow" min-width="100">
|
<el-table-column label="是否显示" prop="isShow" min-width="100">
|
||||||
|
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<dict-value :options="dictData.Integer" :value="row.isShow" />
|
<dict-value :options="dictData.Integer" :value="row.isShow" />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,234 @@
|
||||||
|
<template>
|
||||||
|
<div class="edit-popup">
|
||||||
|
<popup
|
||||||
|
ref="popupRef"
|
||||||
|
:title="popupTitle"
|
||||||
|
:async="true"
|
||||||
|
width="1000px"
|
||||||
|
:clickModalClose="true"
|
||||||
|
@confirm="handleSubmit"
|
||||||
|
@close="handleClose"
|
||||||
|
>
|
||||||
|
<el-form ref="formRef" :model="formData" label-width="110px" style="width: 800px" :rules="formRules">
|
||||||
|
<el-form-item label="产品分类" prop="cateId">
|
||||||
|
<el-tree-select
|
||||||
|
class="flex-1"
|
||||||
|
v-model="formData.cateId"
|
||||||
|
:data="optionsData.cate"
|
||||||
|
clearable
|
||||||
|
node-key="id"
|
||||||
|
:props="{
|
||||||
|
label: 'name'
|
||||||
|
}"
|
||||||
|
:default-expand-all="true"
|
||||||
|
placeholder="请选择产品分类"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品名称" prop="goodsName">
|
||||||
|
<el-input v-model="formData.goodsName" placeholder="请输入产品名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="价格" prop="price" style = "width: 300px">
|
||||||
|
<el-input v-model="formData.price" placeholder="请输入价格" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品主图" prop="goodsImg">
|
||||||
|
<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" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" prop="sort">
|
||||||
|
<div>
|
||||||
|
<el-input-number v-model="formData.sort" :max="9999" />
|
||||||
|
<div class="form-tips">数值越大越排前</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否上架" prop="type">
|
||||||
|
<el-radio-group class="flex-1" v-model="formData.type" placeholder="请选择是否上架0:否,1:是">
|
||||||
|
<el-radio :label="1">上架</el-radio>
|
||||||
|
<el-radio :label="0">下架</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否下载" prop="isDownload">
|
||||||
|
<el-radio-group v-model="formData.isDownload" placeholder="请输入是否下载" >
|
||||||
|
<el-radio :label="1">是</el-radio>
|
||||||
|
<el-radio :label="0">否</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="实验室说明" prop="summary">
|
||||||
|
<editor v-model="formData.summary" :height="500" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</popup>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormInstance } from 'element-plus'
|
||||||
|
import { goodsEdit, goodsAdd, goodsDetail } from '@/api/goods'
|
||||||
|
import { cateLists} from '@/api/cate'
|
||||||
|
import Popup from '@/components/popup/index.vue'
|
||||||
|
import feedback from '@/utils/feedback'
|
||||||
|
import type { PropType } from 'vue'
|
||||||
|
import {arrayToTree, treeToArray} from "@/utils/util";
|
||||||
|
import {MenuEnum} from "@/enums/appEnums";
|
||||||
|
import {reactive} from "vue";
|
||||||
|
import {useDictOptions} from "@/hooks/useDictOptions";
|
||||||
|
import {deptLists} from "@/api/org/department";
|
||||||
|
defineProps({
|
||||||
|
dictData: {
|
||||||
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
|
default: () => ({})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['success', 'close'])
|
||||||
|
const formRef = shallowRef<FormInstance>()
|
||||||
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
|
const mode = ref('add')
|
||||||
|
const popupTitle = computed(() => {
|
||||||
|
return mode.value == 'edit' ? '编辑产品信息' : '新增产品信息'
|
||||||
|
})
|
||||||
|
|
||||||
|
const formData = reactive({
|
||||||
|
id: '',
|
||||||
|
goodsName: '',
|
||||||
|
price: '',
|
||||||
|
goodsImg: '',
|
||||||
|
goodsListImg: '',
|
||||||
|
sort: '',
|
||||||
|
type: '',
|
||||||
|
isDownload: '',
|
||||||
|
summary: '',
|
||||||
|
cateId :''
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRules = {
|
||||||
|
id: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入主键',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
goodsName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入产品名称',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
price: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入价格',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
goodsImg: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入产品主图',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
goodsListImg: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入产品列表图',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
sort: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入排序',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
type: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择是否上架0:否,1:是',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
isDownload: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入是否下载',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
summary: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入实验室说明',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
const { optionsData } = useDictOptions<{
|
||||||
|
cate: any[]
|
||||||
|
}>({
|
||||||
|
cate: {
|
||||||
|
api: cateLists
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const getCate = async () => {
|
||||||
|
// optionsData = await cateLists()
|
||||||
|
// console.log( " ++++++++++++++",optionsData)
|
||||||
|
// const cate: any = {
|
||||||
|
// id: 0,
|
||||||
|
// name: '顶级分类',
|
||||||
|
// children: []
|
||||||
|
// }
|
||||||
|
// cate.children = arrayToTree(
|
||||||
|
// treeToArray(data)
|
||||||
|
// )
|
||||||
|
// cateOptions.value.push(cate)
|
||||||
|
// cateOptions.value.filter((item) => item.id != 0)
|
||||||
|
// console.log(cateOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
const data: any = { ...formData }
|
||||||
|
mode.value == 'edit' ? await goodsEdit(data) : await goodsAdd(data)
|
||||||
|
popupRef.value?.close()
|
||||||
|
feedback.msgSuccess('操作成功')
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
|
|
||||||
|
const open = (type = 'add') => {
|
||||||
|
mode.value = type
|
||||||
|
popupRef.value?.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
const setFormData = async (data: Record<string, any>) => {
|
||||||
|
for (const key in formData) {
|
||||||
|
if (data[key] != null && data[key] != undefined) {
|
||||||
|
//@ts-ignore
|
||||||
|
formData[key] = data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDetail = async (row: Record<string, any>) => {
|
||||||
|
const data = await goodsDetail({
|
||||||
|
id: row.id
|
||||||
|
})
|
||||||
|
setFormData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
getCate()
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
setFormData,
|
||||||
|
getDetail
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,170 @@
|
||||||
|
<template>
|
||||||
|
<div class="index-lists">
|
||||||
|
<el-card class="!border-none" shadow="never">
|
||||||
|
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
|
||||||
|
<el-form-item label="产品名称" prop="goodsName">
|
||||||
|
<el-input class="w-[280px]" v-model="queryParams.goodsName" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品分类" prop="cateId">
|
||||||
|
<el-tree-select
|
||||||
|
class="flex-1"
|
||||||
|
v-model="queryParams.cateId"
|
||||||
|
:data="optionsData.cate"
|
||||||
|
clearable
|
||||||
|
node-key="id"
|
||||||
|
:props="{
|
||||||
|
label: 'name'
|
||||||
|
}"
|
||||||
|
:default-expand-all="true"
|
||||||
|
placeholder="请选择产品分类"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||||
|
<el-button @click="resetParams">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="!border-none mt-4" shadow="never">
|
||||||
|
<div>
|
||||||
|
<el-button v-perms="['goods:add']" type="primary" @click="handleAdd()">
|
||||||
|
<template #icon>
|
||||||
|
<icon name="el-icon-Plus" />
|
||||||
|
</template>
|
||||||
|
新增
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
class="mt-4"
|
||||||
|
size="large"
|
||||||
|
v-loading="pager.loading"
|
||||||
|
:data="pager.lists"
|
||||||
|
>
|
||||||
|
<el-table-column label="产品名称" prop="goodsName" width="250" />
|
||||||
|
<el-table-column label="产品分类" prop="cateName" min-width="100" />
|
||||||
|
<el-table-column label="价格" prop="price" min-width="100" />
|
||||||
|
<el-table-column label="产品主图" prop="goodsImg" min-width="100" >
|
||||||
|
<template #default="{ row }">
|
||||||
|
<image-contain
|
||||||
|
:width="100"
|
||||||
|
:height="60"
|
||||||
|
:src="row.goodsImg"
|
||||||
|
:preview-src-list="[row.goodsImg]"
|
||||||
|
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 }">
|
||||||
|
<dict-value :options="dictData.Integer" :value="row.type" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="是否下载" prop="isDownload" min-width="100" >
|
||||||
|
<template #default="{ row }">
|
||||||
|
<dict-value :options="dictData.Integer" :value="row.isDownload" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="120" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button
|
||||||
|
v-perms="['goods:edit']"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
@click="handleEdit(row)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-perms="['goods:del']"
|
||||||
|
type="danger"
|
||||||
|
link
|
||||||
|
@click="handleDelete(row.id)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="flex justify-end mt-4">
|
||||||
|
<pagination v-model="pager" @change="getLists" />
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
<edit-popup
|
||||||
|
v-if="showEdit"
|
||||||
|
ref="editRef"
|
||||||
|
@success="getLists"
|
||||||
|
@close="showEdit = false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup name="goods">
|
||||||
|
import { goodsDelete, goodsLists } from '@/api/goods'
|
||||||
|
import { usePaging } from '@/hooks/usePaging'
|
||||||
|
import feedback from '@/utils/feedback'
|
||||||
|
import EditPopup from './edit.vue'
|
||||||
|
import {useDictData, useDictOptions} from "@/hooks/useDictOptions";
|
||||||
|
import {cateLists} from "@/api/cate";
|
||||||
|
|
||||||
|
|
||||||
|
const { dictData } = useDictData<{
|
||||||
|
Integer: any[]
|
||||||
|
}>(['Integer'])
|
||||||
|
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||||
|
const showEdit = ref(false)
|
||||||
|
const queryParams = reactive({
|
||||||
|
goodsName: '',
|
||||||
|
cateId: '',
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||||
|
fetchFun: goodsLists,
|
||||||
|
params: queryParams
|
||||||
|
})
|
||||||
|
|
||||||
|
const { optionsData } = useDictOptions<{
|
||||||
|
cate: any[]
|
||||||
|
}>({
|
||||||
|
cate: {
|
||||||
|
api: cateLists
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const handleAdd = async () => {
|
||||||
|
showEdit.value = true
|
||||||
|
await nextTick()
|
||||||
|
editRef.value?.open('add')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEdit = async (data: any) => {
|
||||||
|
showEdit.value = true
|
||||||
|
await nextTick()
|
||||||
|
editRef.value?.open('edit')
|
||||||
|
editRef.value?.getDetail(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
await feedback.confirm('确定要删除?')
|
||||||
|
await goodsDelete({ id })
|
||||||
|
feedback.msgSuccess('删除成功')
|
||||||
|
getLists()
|
||||||
|
}
|
||||||
|
|
||||||
|
getLists()
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue