1、前端icon以图标显示

2、属性分组查出分类名称显示出来
pull/254/head
xjs 4 years ago
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="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="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="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="icon" header-align="center" align="center" label="组图标">
<el-table-column prop="catelogId" header-align="center" align="center" label="所属分类id"></el-table-column> <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 <el-table-column
fixed="right" fixed="right"
header-align="center" header-align="center"

@ -56,7 +56,11 @@
<el-tag v-else></el-tag> <el-tag v-else></el-tag>
</template> </template>
</el-table-column> </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="可选值"> <el-table-column prop="valueSelect" header-align="center" align="center" label="可选值">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip placement="top"> <el-tooltip placement="top">

@ -15,8 +15,6 @@ import java.util.Map;
*/ */
public interface AttrGroupService extends IService<AttrGroupEntity> { public interface AttrGroupService extends IService<AttrGroupEntity> {
PageUtils queryPage(Map<String, Object> params);
/** /**
* *
* @param params * @param params

@ -1,11 +1,9 @@
package com.xjs.mall.product.service; package com.xjs.mall.product.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.utils.PageUtils;
import com.xjs.mall.product.entity.CategoryEntity; import com.xjs.mall.product.entity.CategoryEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@ -16,8 +14,6 @@ import java.util.Map;
*/ */
public interface CategoryService extends IService<CategoryEntity> { public interface CategoryService extends IService<CategoryEntity> {
PageUtils queryPage(Map<String, Object> params);
/** /**
* *
* @return list * @return list

@ -1,60 +1,79 @@
package com.xjs.mall.product.service.impl; package com.xjs.mall.product.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.mall.product.dao.AttrGroupDao; import com.xjs.mall.product.dao.AttrGroupDao;
import com.xjs.mall.product.entity.AttrGroupEntity; 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.AttrGroupService;
import com.xjs.mall.product.service.CategoryService;
import com.xjs.mall.product.vo.AttrGroupResponseVo;
import com.xjs.utils.PageUtils; import com.xjs.utils.PageUtils;
import com.xjs.utils.Query; import com.xjs.utils.Query;
import org.apache.commons.lang3.StringUtils; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Service("attrGroupService") @Service("attrGroupService")
@Transactional @Transactional
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService { public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService {
@Override @Autowired
public PageUtils queryPage(Map<String, Object> params) { private CategoryService categoryService;
IPage<AttrGroupEntity> page = this.page(
new Query<AttrGroupEntity>().getPage(params),
new QueryWrapper<>()
);
return new PageUtils(page);
}
@Override @Override
public PageUtils queryPage(Map<String, Object> params, Long categoryId) { public PageUtils queryPage(Map<String, Object> params, Long categoryId) {
String key = (String) params.get(Query.KEY_NAME); String key = (String) params.get(Query.KEY_NAME);
LambdaQueryWrapper<AttrGroupEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AttrGroupEntity> wrapper = new LambdaQueryWrapper<>();
if(!StringUtils.isEmpty(key)){ if (!StringUtils.isEmpty(key)) {
wrapper.and((obj)->{ wrapper.and((obj) -> {
obj.eq(AttrGroupEntity::getAttrGroupId,key) obj.eq(AttrGroupEntity::getAttrGroupId, key)
.or().like(AttrGroupEntity::getDescript,key) .or().like(AttrGroupEntity::getDescript, key)
.or().like(AttrGroupEntity::getAttrGroupName,key); .or().like(AttrGroupEntity::getAttrGroupName, key);
}); });
} }
if( categoryId == 0){ if (categoryId == 0) {
IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params), IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
wrapper); wrapper);
return new PageUtils(page);
}else { List<AttrGroupResponseVo> responseVoList = this.setList(page.getRecords());
wrapper.eq(AttrGroupEntity::getCatelogId,categoryId); 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), IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
wrapper); wrapper);
return new PageUtils(page);
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; 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.mall.product.dao.CategoryDao; import com.xjs.mall.product.dao.CategoryDao;
import com.xjs.mall.product.entity.CategoryEntity; import com.xjs.mall.product.entity.CategoryEntity;
import com.xjs.mall.product.service.CategoryBrandRelationService; import com.xjs.mall.product.service.CategoryBrandRelationService;
import com.xjs.mall.product.service.CategoryService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -28,15 +24,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
@Autowired @Autowired
private CategoryBrandRelationService categoryBrandRelationService; 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 @Override
public List<CategoryEntity> listWithTree() { 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…
Cancel
Save