当前位置:网站首页>Goods and services - platform properties
Goods and services - platform properties
2022-06-30 12:59:00 【Leo&&Eva】
Small problem solving
Add paging component , The official documents are as follows : Plug in body | MyBatis-Plus
MybatisConfig
package com.example.gulimall.product.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement// Turn on use
@MapperScan("com.example.gulimall.product.dao")
public class MybatisConfig {
// Introduce paging plug-ins
@Bean
public PaginationInterceptor paginationInterceptor(){
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// Set the requested page to be larger than the maximum page after operation ,true Go back to the home page ,false Continue request Default false
paginationInterceptor.setOverflow(false);
// Set the maximum single page limit data , Default 500 strip , -1 There is no limit on the
paginationInterceptor.setLimit(500);
return paginationInterceptor;
}
}
Next, modify the fuzzy query of the brand
BrandServiceImpl
package com.example.gulimall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
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.example.common.utils.PageUtils;
import com.example.common.utils.Query;
import com.example.gulimall.product.dao.BrandDao;
import com.example.gulimall.product.entity.BrandEntity;
import com.example.gulimall.product.service.BrandService;
import org.springframework.util.StringUtils;
@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
// obtain key
String key = (String) params.get("key");
QueryWrapper<BrandEntity> queryWrapper = new QueryWrapper<>();
if (!StringUtils.isEmpty(key)){
queryWrapper.eq("brand_id", key).or().like("name", key);
IPage<BrandEntity> page = this.page(
new Query<BrandEntity>().getPage(params),
queryWrapper
);
}
IPage<BrandEntity> page = this.page(
new Query<BrandEntity>().getPage(params),
queryWrapper
);
return new PageUtils(page);
}
}
Brand classification relationship Association
Get the classification of Brand Association
/**
* Get the classification of Brand Association
*/
@GetMapping("/catelog/list")
public R list(@RequestParam("brandId")Long brandId){
List<CategoryBrandRelationEntity> data = categoryBrandRelationService.list(
new QueryWrapper<CategoryBrandRelationEntity>().eq("brand_id", brandId));
return R.ok().put("data", data);
}
New category of brand association
/**
* New category of brand association
* product/categorybrandrelation/save
*/
@RequestMapping("/save")
public R save(@RequestBody CategoryBrandRelationEntity categoryBrandRelation){
categoryBrandRelationService.saveDetail(categoryBrandRelation);
return R.ok();
}
package com.example.gulimall.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.common.utils.PageUtils;
import com.example.gulimall.product.entity.CategoryBrandRelationEntity;
import java.util.Map;
/**
* Brand classification association
*
* @author leohams
* @email [email protected]
* @date 2022-06-14 21:22:44
*/
public interface CategoryBrandRelationService extends IService<CategoryBrandRelationEntity> {
PageUtils queryPage(Map<String, Object> params);
void saveDetail(CategoryBrandRelationEntity categoryBrandRelation);
}
package com.example.gulimall.product.service.impl;
import com.example.gulimall.product.dao.BrandDao;
import com.example.gulimall.product.dao.CategoryDao;
import com.example.gulimall.product.entity.BrandEntity;
import com.example.gulimall.product.entity.CategoryEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
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.example.common.utils.PageUtils;
import com.example.common.utils.Query;
import com.example.gulimall.product.dao.CategoryBrandRelationDao;
import com.example.gulimall.product.entity.CategoryBrandRelationEntity;
import com.example.gulimall.product.service.CategoryBrandRelationService;
@Service("categoryBrandRelationService")
public class CategoryBrandRelationServiceImpl extends ServiceImpl<CategoryBrandRelationDao, CategoryBrandRelationEntity> implements CategoryBrandRelationService {
@Autowired
private BrandDao brandDao;
@Autowired
private CategoryDao categoryDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<CategoryBrandRelationEntity> page = this.page(
new Query<CategoryBrandRelationEntity>().getPage(params),
new QueryWrapper<CategoryBrandRelationEntity>()
);
return new PageUtils(page);
}
@Override
public void saveDetail(CategoryBrandRelationEntity categoryBrandRelation) {
Long brandId = categoryBrandRelation.getBrandId();
Long catelogId = categoryBrandRelation.getCatelogId();
BrandEntity brandEntity = brandDao.selectById(brandId);
String brandName = brandEntity.getName();
CategoryEntity categoryEntity = categoryDao.selectById(catelogId);
String categoryEntityName = categoryEntity.getName();
categoryBrandRelation.setBrandName(brandName);
categoryBrandRelation.setCatelogName(categoryEntityName);
this.save(categoryBrandRelation);
}
}
Cascade update data
When the brand name or category name is modified, it needs to be updated in the relationship table in real time
When the brand information is updated
BrandController
Pay attention to adding transaction annotations
@Transactional
/**
* modify
*/
@Transactional
@RequestMapping("/update")
public R update(@Validated(UpdateGroup.class) @RequestBody BrandEntity brand){
brandService.updateDetail(brand);
return R.ok();
}
BrandServiceImpl
@Override
public void updateDetail(BrandEntity brand) {
this.updateById(brand);
if (!StringUtils.isEmpty(brand.getName())){
categoryBrandRelationService.updateBrand(brand.getBrandId(), brand.getName());
//TODO
}
}
CategoryBrandRelationServiceImpl
@Override
public void updateBrand(Long brandId, String name) {
CategoryBrandRelationEntity categoryBrandRelationEntity = new CategoryBrandRelationEntity();
categoryBrandRelationEntity.setBrandId(brandId);
categoryBrandRelationEntity.setBrandName(name);
this.update(categoryBrandRelationEntity, new UpdateWrapper<CategoryBrandRelationEntity>().eq("brand_id", brandId));
}
When the classification data is updated
CategoryController
/**
* modify
*/
@Transactional
@RequestMapping("/update")
public R update(@RequestBody CategoryEntity category){
categoryService.updateCascade(category);
return R.ok();
}
CategoryServiceImpl
@Override
public void updateCascade(CategoryEntity category) {
this.updateById(category);
categoryBrandRelationService.updateCategory(category.getCatId(), category.getName());
}
CategoryBrandRelationServiceImpl
@Override
public void updateCategory(Long catId, String name) {
this.baseMapper.updateCategory(catId, name);
}
CategoryBrandRelationDao
package com.example.gulimall.product.dao;
import com.example.gulimall.product.entity.CategoryBrandRelationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* Brand classification association
*
* @author leohams
* @email [email protected]
* @date 2022-06-14 21:22:44
*/
@Mapper
public interface CategoryBrandRelationDao extends BaseMapper<CategoryBrandRelationEntity> {
void updateCategory(@Param("catId") Long catId, @Param("name") String name);
}
CategoryBrandRelationDao.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.gulimall.product.dao.CategoryBrandRelationDao">
<!-- According to their own needs , Do you want to use -->
<resultMap type="com.example.gulimall.product.entity.CategoryBrandRelationEntity" id="categoryBrandRelationMap">
<result property="id" column="id"/>
<result property="brandId" column="brand_id"/>
<result property="catelogId" column="catelog_id"/>
<result property="brandName" column="brand_name"/>
<result property="catelogName" column="catelog_name"/>
</resultMap>
<update id="updateCategory">
UPDATE 'pms_category_brand_relation' SET catelog_name=#{name} WHERE catelog_id=#{catId}?;
</update>
</mapper>
Platform properties - Specifications and parameters are added VO
package com.example.gulimall.product.vo;
import lombok.Data;
@Data
public class AttrVo {
/**
* attribute id
*/
private Long attrId;
/**
* Property name
*/
private String attrName;
/**
* Need to retrieve [0- Unwanted ,1- need ]
*/
private Integer searchType;
/**
* Attribute icon
*/
private String icon;
/**
* List of optional values [ Separate with commas ]
*/
private String valueSelect;
/**
* Attribute types [0- Sales attributes ,1- Basic attributes ,2- It is both a sales attribute and a basic attribute ]
*/
private Integer attrType;
/**
* Enable state [0 - Ban ,1 - Enable ]
*/
private Long enable;
/**
* Classification
*/
private Long catelogId;
/**
* Quick show 【 Whether to show it on the introduction ;0- no 1- yes 】, stay sku Can still be adjusted
*/
private Integer showDesc;
private Long attrGroupId;
}
modify attr Of save Method
/**
* preservation
*/
@RequestMapping("/save")
public R save(@RequestBody AttrVo attr){
attrService.saveAttr(attr);
return R.ok();
}
@Transactional
@Override
public void saveAttr(AttrVo attr) {
AttrEntity attrEntity = new AttrEntity();
BeanUtils.copyProperties(attr, attrEntity);
this.save(attrEntity);
if (attr.getAttrType() == ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode() && attr.getAttrGroupId()!=null){
AttrAttrgroupRelationEntity attrAttrgroupRelationEntity = new AttrAttrgroupRelationEntity();
Long attrGroupId = attr.getAttrGroupId();
attrAttrgroupRelationEntity.setAttrGroupId(attrGroupId);
attrAttrgroupRelationEntity.setAttrId(attrEntity.getAttrId());
attrAttrgroupRelationDao.insert(attrAttrgroupRelationEntity);
}
Platform properties - Specification parameter list
AttrRespVo
package com.example.gulimall.product.vo;
import lombok.Data;
@Data
public class AttrRespVo extends AttrVo{
// "catelogName": " mobile phone / Digital / mobile phone ", // Category name
// "groupName": " The main body ", // Group name
private String catelogName;
private String groupName;
}
AttrController
// /product/attr/base/list/{catelogId}
@GetMapping("/base/list/{catelogId")
public R baseAttrList(@RequestParam Map<String, Object> params,
@PathVariable("catelogId") Long catelogId){
PageUtils page = attrService.queryBaseAttrPage(params, catelogId);
return R.ok().put("page", page);
}
@Override
public PageUtils queryBaseAttrPage(Map<String, Object> params, Long catelogId) {
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
String key = (String) params.get("key");
if (catelogId != 0){
wrapper.eq("catelog_id", catelogId);
}
if (!StringUtils.isEmpty(key)){
wrapper.and((queryWrapper)->{
queryWrapper.eq("attr_id", key).or().like("attr_name", key);
});
// wrapper.eq("attr_id", key).or().like("attr_name", key);
}
IPage<AttrEntity> page = this.page(
new Query<AttrEntity>().getPage(params),
wrapper
);
PageUtils pageUtils = new PageUtils(page);
List<AttrEntity> records = page.getRecords();
List<AttrRespVo> respVos = records.stream().map((attrEntity) -> {
AttrRespVo attrRespVo = new AttrRespVo();
BeanUtils.copyProperties(attrEntity, attrRespVo);
// Set the names of categories and groups
AttrAttrgroupRelationEntity attr_id = attrAttrgroupRelationDao.selectOne(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrEntity.getAttrId()));
if (attr_id != null) {
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attr_id.getAttrGroupId());
attrRespVo.setGroupName(attrGroupEntity.getAttrGroupName());
}
CategoryEntity categoryEntity = categoryDao.selectById(attrEntity.getCatelogId());
if (categoryEntity != null) {
attrRespVo.setCatelogName(categoryEntity.getName());
}
return attrRespVo;
}).collect(Collectors.toList());
pageUtils.setList(respVos);
return pageUtils;
}
Platform properties - Specification modification
Echo data
AttrController
/**
* Information
*/
// /product/attr/info/{attrId}
@RequestMapping("/info/{attrId}")
public R info(@PathVariable("attrId") Long attrId){
// AttrEntity attr = attrService.getById(attrId);
AttrRespVo attrRespVo = attrService.getAttrInfo(attrId);
return R.ok().put("attr", attrRespVo);
}
AttrRespVo
package com.example.gulimall.product.vo;
import lombok.Data;
import java.util.List;
@Data
public class AttrRespVo extends AttrVo{
// "catelogName": " mobile phone / Digital / mobile phone ", // Category name
// "groupName": " The main body ", // Group name
private String catelogName;
private String groupName;
private Long[] catelogPath;
}
AttrServiceImpl
@Override
public AttrRespVo getAttrInfo(Long attrId) {
AttrRespVo respVo = new AttrRespVo();
AttrEntity attrEntity = this.getById(attrId);
BeanUtils.copyProperties(attrEntity, respVo);
// Set the grouping information
AttrAttrgroupRelationEntity attr_id = attrAttrgroupRelationDao.selectOne(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrEntity.getAttrId()));
if (attr_id != null) {
respVo.setAttrGroupId(attr_id.getAttrGroupId());
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attr_id.getAttrGroupId());
if (attrGroupEntity != null){
respVo.setGroupName(attrGroupEntity.getAttrGroupName());
}
}
// Set classification information
Long catelogId = attrEntity.getCatelogId();
List<Long> paths = new ArrayList<>();
Long[] catelogPath = categoryService.findCatelogPath(catelogId);
respVo.setCatelogPath(catelogPath);
CategoryEntity categoryEntity = categoryDao.selectById(catelogId);
if (categoryEntity!= null){
respVo.setCatelogName(categoryEntity.getName());
}
return respVo;
}
Modifying data
AttrController
// /product/attr/update
@RequestMapping("/update")
public R update(@RequestBody AttrVo attr){
attrService.updateAttr(attr);
return R.ok();
}
AttrServiceImpl
@Transactional
@Override
public void updateAttr(AttrVo attr) {
AttrEntity attrEntity = new AttrEntity();
BeanUtils.copyProperties(attr, attrEntity);
this.updateById(attrEntity);
// Modify group association
AttrAttrgroupRelationEntity attrAttrgroupRelationEntity = new AttrAttrgroupRelationEntity();
attrAttrgroupRelationEntity.setAttrGroupId(attr.getAttrGroupId());
attrAttrgroupRelationEntity.setAttrId(attr.getAttrId());
Integer count = attrAttrgroupRelationDao.selectCount(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attr.getAttrId()));
if (count>0){
attrAttrgroupRelationDao.update(attrAttrgroupRelationEntity, new UpdateWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attr.getAttrId()));
}else {
attrAttrgroupRelationDao.insert(attrAttrgroupRelationEntity);
}
}
Platform properties - Sales attribute maintenance
AttrController
/**
* list
*/
// /product/attr/base/list/{catelogId}
// /product/attr/sale/list/{catelogId}
@GetMapping("/{attrType}/list/{catelogId}")
public R baseAttrList(@RequestParam Map<String, Object> params,
@PathVariable("catelogId") Long catelogId,
@PathVariable("attrType") String type){
PageUtils page = attrService.queryBaseAttrPage(params, catelogId, type);
return R.ok().put("page", page);
}
queryBaseAttrPage
@Override
public PageUtils queryBaseAttrPage(Map<String, Object> params, Long catelogId, String type) {
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<AttrEntity>().eq("attr_type", "base".equalsIgnoreCase(type)?1:0);
String key = (String) params.get("key");
if (catelogId != 0){
wrapper.eq("catelog_id", catelogId);
}
if (!StringUtils.isEmpty(key)){
wrapper.and((queryWrapper)->{
queryWrapper.eq("attr_id", key).or().like("attr_name", key);
});
// wrapper.eq("attr_id", key).or().like("attr_name", key);
}
IPage<AttrEntity> page = this.page(
new Query<AttrEntity>().getPage(params),
wrapper
);
PageUtils pageUtils = new PageUtils(page);
List<AttrEntity> records = page.getRecords();
List<AttrRespVo> respVos = records.stream().map((attrEntity) -> {
AttrRespVo attrRespVo = new AttrRespVo();
BeanUtils.copyProperties(attrEntity, attrRespVo);
// Set the names of categories and groups
// Set the names of categories and groups
if ("base".equalsIgnoreCase(type)){
AttrAttrgroupRelationEntity attr_id = attrAttrgroupRelationDao.selectOne(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrEntity.getAttrId()));
if (attr_id != null) {
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attr_id.getAttrGroupId());
attrRespVo.setGroupName(attrGroupEntity.getAttrGroupName());
}
}
CategoryEntity categoryEntity = categoryDao.selectById(attrEntity.getCatelogId());
if (categoryEntity != null) {
attrRespVo.setCatelogName(categoryEntity.getName());
}
return attrRespVo;
}).collect(Collectors.toList());
pageUtils.setList(respVos);
return pageUtils;
}
stay common Create an enumeration class in the folder ProductConstant , Used in place of 1 or 0, And determine whether it is a basic attribute each time you set the grouping information .
package com.example.common.constant;
public class ProductConstant {
public enum AttrEnum{
ATTR_TYPE_BASE(1, " Basic attributes "), ATTR_TYPE_SALE(0, " Sales attributes ");
private int code;
private String msg;
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
AttrEnum(int code, String msg){
this.code = code;
this.msg = msg;
}
}
}
Platform properties - Query group association properties & Delete Association
AttrController
/**
* list
*/
// /product/attr/base/list/{catelogId}
// /product/attr/sale/list/{catelogId}
@GetMapping("/{attrType}/list/{catelogId}")
public R baseAttrList(@RequestParam Map<String, Object> params,
@PathVariable("catelogId") Long catelogId,
@PathVariable("attrType") String type){
PageUtils page = attrService.queryBaseAttrPage(params, catelogId, type);
return R.ok().put("page", page);
}
AttrServiceImpl
@Override
public List<AttrEntity> getRelationAttr(Long attrgroupId) {
List<AttrAttrgroupRelationEntity> entities = attrAttrgroupRelationDao.selectList(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_group_id", attrgroupId));
List<Long> attrIds = entities.stream().map((attr) -> {
return attr.getAttrId();
}).collect(Collectors.toList());
List<AttrEntity> attrEntities = this.listByIds(attrIds);
return attrEntities;
}
Delete Association
AttrGroupController
/**
* Delete
*/
// /product/attrgroup/attr/relation/delete
@PostMapping("/attr/relation/delete")
public R deleteRelation(@RequestBody AttrGroupRelationVo[] vos){
attrService.deleteRelation(vos);
return R.ok();
}
Create a receiver Vo
AttrGroupRelationVo
package com.example.gulimall.product.vo;
import lombok.Data;
@Data
public class AttrGroupRelationVo {
// [{"attrId":1,"attrGroupId":2}]
private Long attrId;
private Long attrGroupId;
}
AttrServiceImpl
@Override
public void deleteRelation(AttrGroupRelationVo[] vos) {
// attrAttrgroupRelationDao.delete(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", 1L).eq("attr_group_id", 1L));
List<AttrAttrgroupRelationEntity> relationEntityList = Arrays.asList(vos).stream().map((item) -> {
AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
BeanUtils.copyProperties(item, relationEntity);
return relationEntity;
}).collect(Collectors.toList());
attrAttrgroupRelationDao.deleteBatchRelation(relationEntityList);
}
AttrAttrgroupRelationDao
package com.example.gulimall.product.dao;
import com.example.gulimall.product.entity.AttrAttrgroupRelationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
/**
* attribute & Attribute grouping Association
*
* @author leohams
* @email [email protected]
* @date 2022-06-14 21:22:44
*/
@Mapper
public interface AttrAttrgroupRelationDao extends BaseMapper<AttrAttrgroupRelationEntity> {
void deleteBatchRelation(@Param("relationEntityList") List<AttrAttrgroupRelationEntity> relationEntityList);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.gulimall.product.dao.AttrAttrgroupRelationDao">
<!-- According to their own needs , Do you want to use -->
<resultMap type="com.example.gulimall.product.entity.AttrAttrgroupRelationEntity" id="attrAttrgroupRelationMap">
<result property="id" column="id"/>
<result property="attrId" column="attr_id"/>
<result property="attrGroupId" column="attr_group_id"/>
<result property="attrSort" column="attr_sort"/>
</resultMap>
<delete id="deleteBatchRelation">
DELETE FROM 'pms_attr_attrgroup_relation' WHERE
<foreach collection="relationEntityList" separator=" OR " item="item">
attr_id=#{item.attrId} AND attr_group_id=#{item.attrGroupId}
</foreach>
</delete>
</mapper>
Platform properties - Query the properties not associated with the group
AttrGroupController
// /product/attrgroup/{attrgroupId}/noattr/relation
@GetMapping("/{attrgroupId}/noattr/relation")
public R attrNoRelation(@RequestParam Map<String, Object> params,
@PathVariable("attrgroupId") Long attrgroupId){
PageUtils page = attrService.getNoRelationAttr(params, attrgroupId);
return R.ok().put("data", page);
}
AttrServiceImpl
/**
* Get properties that are not associated with the current group
* @param params
* @param attrgroupId
* @return
*/
@Override
public PageUtils getNoRelationAttr(Map<String, Object> params, Long attrgroupId) {
//1、 The current group can only be associated with all attributes in the category to which it belongs
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrgroupId);
Long catelogId = attrGroupEntity.getCatelogId();
//2、 The current group can only be associated with attributes not introduced by other groups
//2.1、 Other groups under the current category
List<AttrGroupEntity> group = attrGroupDao.selectList(
new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));
List<Long> groupIds = group.stream().map((item) -> {
Long attrGroupId = item.getAttrGroupId();
return attrGroupId;
}).collect(Collectors.toList());
//2.2、 Properties associated with these groups
List<AttrAttrgroupRelationEntity> entities = attrAttrgroupRelationDao.selectList(new QueryWrapper<AttrAttrgroupRelationEntity>().in("attr_group_id", groupIds));
List<Long> attrIds = entities.stream().map((item) -> {
return item.getAttrId();
}).collect(Collectors.toList());
//2.3、 Remove these attributes from all attributes of the current classification
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<AttrEntity>().eq("catelog_id", catelogId).eq("attr_type", ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode());
if (attrIds != null && attrIds.size()>0){
wrapper.notIn("attr_id", attrIds);
}
String key = (String) params.get("key");
if (!StringUtils.isEmpty(key)){
wrapper.and((w)->{
w.eq("attr_id", key).or().like("attr_name", key);
});
}
IPage<AttrEntity> page = this.page(new Query<AttrEntity>().getPage(params), wrapper);
PageUtils pageUtils = new PageUtils(page);
return pageUtils;
}
Platform properties - Add grouping and attribute Association
AttrGroupController
// /product/attrgroup/attr/relation
@PostMapping("/attr/relation")
public R addRelation(@RequestBody List<AttrGroupRelationVo> vos){
relationService.saveBatch(vos);
return R.ok();
}
AttrAttrgroupRelationServiceImpl
@Override
public void saveBatch(List<AttrGroupRelationVo> vos) {
List<AttrAttrgroupRelationEntity> relationEntities = vos.stream().map((item) -> {
AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
BeanUtils.copyProperties(item, relationEntity);
return relationEntity;
}).collect(Collectors.toList());
this.saveBatch(relationEntities);
}
边栏推荐
- Unity的脚本的基础语法(2)-Unity中记录时间
- elementui中清除tinymce富文本缓存
- [surprised] the download speed of Xunlei is not as fast as that of the virtual machine
- Introduction to the novelty of substrat source code: indexing of call calls and fully completing the materialization of storage layer
- 【C语言深度解剖】float变量在内存中存储原理&&指针变量与“零值”比较
- Today in history: Microsoft acquires PowerPoint developers; SGI and MIPS merge
- Resource realization applet opening traffic main tutorial
- Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年6月29日21:59:34
- ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately
- 【驚了】迅雷下載速度竟然比不上虛擬機中的下載速度
猜你喜欢
RK356x U-Boot研究所(命令篇)3.3 env相关命令的用法
IDEA 2021.3 执行 golang 报错:RNING: undefined behavior version of Delve is too old for Go version 1.18
Wechat launched the picture big bang function; Apple's self-developed 5g chip may have failed; Microsoft solves the bug that causes edge to stop responding | geek headlines
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (II)
你想要的异常知识点都在这里了
Q-learning notes
【OpenGL】OpenGL Examples
Idea 2021.3 golang error: rning: undefined behavior version of delve is too old for go version 1.18
写信宝小程序开源
Postman automatically generates curl code snippets
随机推荐
[surprised] the download speed of Xunlei is not as fast as that of the virtual machine
Introduction to the novelty of substrate source code: comprehensive update of Boca system Boca weight calculation, optimization and adjustment of governance version 2.0
Solve numpy core._ exceptions. Ufunctypeerror: UFUNC 'Add' did not contain a loop with signature matching
Substrate 源码追新导读: Pallet Alliance 并入主线,
Postman automatically generates curl code snippets
Ffmpeg miscellaneous
FlinkSQL自定义UDTF使用的四种方式
JS 二维数组变一维数组的方法
[qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external
ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately
Efficient elliptic curve point addition and multiplication in scrypt
[learn awk in one day] operator
Unity的脚本的基础语法(2)-Unity中记录时间
FlinkSQL自定义UDATF实现TopN
postman 自動生成 curl 代碼片段
Substrate 源码追新导读: 修复BEEFY的gossip引擎内存泄漏问题, 智能合约删除队列优化
今日睡眠质量记录80分
Event handling in QT
When MySQL judges that the execution condition is null, it returns 0. Correct parameter count in the call to native function 'isnull',
zabbix-server启动失败处理方式