parent
a15ed1f2d1
commit
627af3e26f
|
|
@ -40,8 +40,13 @@
|
|||
<el-table-column prop="attrGroupName" header-align="center" align="center" label="组名"></el-table-column>
|
||||
<el-table-column prop="sort" header-align="center" align="center" label="排序"></el-table-column>
|
||||
<el-table-column prop="descript" header-align="center" align="center" label="描述"></el-table-column>
|
||||
<el-table-column prop="icon" header-align="center" align="center" label="组图标"></el-table-column>
|
||||
<el-table-column prop="catelogId" header-align="center" align="center" label="所属分类id"></el-table-column>
|
||||
<el-table-column prop="icon" header-align="center" align="center" label="组图标">
|
||||
<template slot-scope="scope">
|
||||
<svg-icon :icon-class="scope.row.icon" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="catelogId" header-align="center" align="center" label="分类ID"></el-table-column>
|
||||
<el-table-column prop="categoryName" header-align="center" align="center" label="分类名称"></el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
|
|
|
|||
|
|
@ -56,7 +56,11 @@
|
|||
<el-tag v-else>多选</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="icon" header-align="center" align="center" label="图标"></el-table-column>
|
||||
<el-table-column prop="icon" header-align="center" align="center" label="图标">
|
||||
<template slot-scope="scope">
|
||||
<svg-icon :icon-class="scope.row.icon" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="valueSelect" header-align="center" align="center" label="可选值">
|
||||
<template slot-scope="scope">
|
||||
<el-tooltip placement="top">
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import java.util.Map;
|
|||
*/
|
||||
public interface AttrGroupService extends IService<AttrGroupEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param params 条件
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package com.xjs.mall.product.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.mall.product.entity.CategoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品三级分类
|
||||
|
|
@ -16,8 +14,6 @@ import java.util.Map;
|
|||
*/
|
||||
public interface CategoryService extends IService<CategoryEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询树形结构分类
|
||||
* @return list
|
||||
|
|
|
|||
|
|
@ -1,60 +1,79 @@
|
|||
package com.xjs.mall.product.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xjs.mall.product.dao.AttrGroupDao;
|
||||
import com.xjs.mall.product.entity.AttrGroupEntity;
|
||||
import com.xjs.mall.product.entity.CategoryEntity;
|
||||
import com.xjs.mall.product.service.AttrGroupService;
|
||||
import com.xjs.mall.product.service.CategoryService;
|
||||
import com.xjs.mall.product.vo.AttrGroupResponseVo;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("attrGroupService")
|
||||
@Transactional
|
||||
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<AttrGroupEntity> page = this.page(
|
||||
new Query<AttrGroupEntity>().getPage(params),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params, Long categoryId) {
|
||||
String key = (String) params.get(Query.KEY_NAME);
|
||||
|
||||
LambdaQueryWrapper<AttrGroupEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isEmpty(key)){
|
||||
wrapper.and((obj)->{
|
||||
obj.eq(AttrGroupEntity::getAttrGroupId,key)
|
||||
.or().like(AttrGroupEntity::getDescript,key)
|
||||
.or().like(AttrGroupEntity::getAttrGroupName,key);
|
||||
if (!StringUtils.isEmpty(key)) {
|
||||
wrapper.and((obj) -> {
|
||||
obj.eq(AttrGroupEntity::getAttrGroupId, key)
|
||||
.or().like(AttrGroupEntity::getDescript, key)
|
||||
.or().like(AttrGroupEntity::getAttrGroupName, key);
|
||||
});
|
||||
}
|
||||
|
||||
if( categoryId == 0){
|
||||
if (categoryId == 0) {
|
||||
IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
|
||||
wrapper);
|
||||
return new PageUtils(page);
|
||||
}else {
|
||||
wrapper.eq(AttrGroupEntity::getCatelogId,categoryId);
|
||||
IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
|
||||
wrapper);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
List<AttrGroupResponseVo> responseVoList = this.setList(page.getRecords());
|
||||
PageUtils pageUtils = new PageUtils(page);
|
||||
pageUtils.setList(responseVoList);
|
||||
return pageUtils;
|
||||
} else {
|
||||
wrapper.eq(AttrGroupEntity::getCatelogId, categoryId);
|
||||
IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
|
||||
wrapper);
|
||||
|
||||
List<AttrGroupResponseVo> responseVoList = this.setList(page.getRecords());
|
||||
PageUtils pageUtils = new PageUtils(page);
|
||||
pageUtils.setList(responseVoList);
|
||||
return pageUtils;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<AttrGroupResponseVo> setList(List<AttrGroupEntity> records) {
|
||||
return records.stream().map(attrGroupEntity -> {
|
||||
AttrGroupResponseVo attrGroupResponseVo = new AttrGroupResponseVo();
|
||||
BeanUtils.copyProperties(attrGroupEntity, attrGroupResponseVo);
|
||||
//获取分类实体类,主要为了获取分类名称给vo
|
||||
CategoryEntity categoryEntity = categoryService.getById(attrGroupEntity.getCatelogId());
|
||||
attrGroupResponseVo.setCategoryName(categoryEntity.getName());
|
||||
return attrGroupResponseVo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package com.xjs.mall.product.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xjs.mall.product.dao.CategoryDao;
|
||||
import com.xjs.mall.product.entity.CategoryEntity;
|
||||
import com.xjs.mall.product.service.CategoryBrandRelationService;
|
||||
import com.xjs.mall.product.service.CategoryService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -28,15 +24,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|||
@Autowired
|
||||
private CategoryBrandRelationService categoryBrandRelationService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CategoryEntity> page = this.page(
|
||||
new Query<CategoryEntity>().getPage(params),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CategoryEntity> listWithTree() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.xjs.mall.product.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AttrGroupVo
|
||||
* @author xiejs
|
||||
* @since 2022-03-17
|
||||
*/
|
||||
@Data
|
||||
public class AttrGroupResponseVo {
|
||||
private Long attrGroupId;
|
||||
/**
|
||||
* 组名
|
||||
*/
|
||||
private String attrGroupName;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String descript;
|
||||
/**
|
||||
* 组图标
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 所属分类id
|
||||
*/
|
||||
private Long catelogId;
|
||||
|
||||
/**
|
||||
* 分类id完整路径
|
||||
*/
|
||||
private List<String> catelogPath;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue