From 4495fab6d517fa6b12b7f1a1997734f980025a6f Mon Sep 17 00:00:00 2001 From: e Date: Tue, 24 Nov 2020 08:23:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=95=86=E5=93=81=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E5=93=81=E7=89=8C=E7=9A=84=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gulimall-auth-server/gulimall-auth-server.iml | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 gulimall-auth-server/gulimall-auth-server.iml diff --git a/gulimall-auth-server/gulimall-auth-server.iml b/gulimall-auth-server/gulimall-auth-server.iml new file mode 100644 index 0000000..6d36bf9 --- /dev/null +++ b/gulimall-auth-server/gulimall-auth-server.iml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- Gitee From f0ed6ecd96e1bf634e3c39be62bf20ad2c3171c2 Mon Sep 17 00:00:00 2001 From: e Date: Thu, 26 Nov 2020 09:43:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gulimall-auth-server/gulimall-auth-server.iml | 31 +---- .../gulimall/product/app/AttrController.java | 30 +++-- .../gulimall/product/service/AttrService.java | 10 ++ .../service/impl/AttrGroupServiceImpl.java | 17 +-- .../product/service/impl/AttrServiceImpl.java | 123 ++++++++++++++++++ .../yyf/gulimall/product/vo/AttrRespVo.java | 13 ++ .../com/yyf/gulimall/product/vo/attrVo.java | 45 +++++++ renren-fast/renren-fast.iml | 98 +++++++------- 8 files changed, 269 insertions(+), 98 deletions(-) create mode 100644 gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java create mode 100644 gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java diff --git a/gulimall-auth-server/gulimall-auth-server.iml b/gulimall-auth-server/gulimall-auth-server.iml index e25f7fe..28f5da2 100644 --- a/gulimall-auth-server/gulimall-auth-server.iml +++ b/gulimall-auth-server/gulimall-auth-server.iml @@ -25,34 +25,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -97,7 +70,6 @@ - @@ -112,6 +84,7 @@ + @@ -127,6 +100,7 @@ + @@ -183,6 +157,7 @@ + diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java index 1a33b86..1334c50 100644 --- a/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java +++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java @@ -3,13 +3,11 @@ package com.yyf.gulimall.product.app; import java.util.Arrays; import java.util.Map; +import com.yyf.gulimall.product.vo.AttrRespVo; import org.springframework.beans.factory.annotation.Autowired ; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import com.yyf.gulimall.product.vo.attrVo; import com.yyf.gulimall.product.entity.AttrEntity; import com.yyf.gulimall.product.service.AttrService; import com.yyf.common.utils.PageUtils; @@ -30,6 +28,14 @@ public class AttrController { @Autowired private AttrService attrService; + + @GetMapping("base/list/{catelogId}") + public R saveBase(@RequestParam Map params,@PathVariable("catelogId") Long catelogId){ + + PageUtils page = attrService.queryBaseAttrPage(params,catelogId); + return R.ok().put("page",page); + } + /** * 列表 */ @@ -48,9 +54,9 @@ public class AttrController { @RequestMapping("/info/{attrId}") //@RequiresPermissions("product:attr:info") public R info(@PathVariable("attrId") Long attrId){ - AttrEntity attr = attrService.getById(attrId); - - return R.ok().put("attr", attr); + //AttrEntity attr = attrService.getById(attrId); + AttrRespVo attrRespVo = attrService.getAttrInfo(attrId); + return R.ok().put("attr", attrRespVo); } /** @@ -58,8 +64,8 @@ public class AttrController { */ @RequestMapping("/save") //@RequiresPermissions("product:attr:save") - public R save(@RequestBody AttrEntity attr){ - attrService.save(attr); + public R save(@RequestBody attrVo attr){ + attrService.saveAttr(attr); return R.ok(); } @@ -69,8 +75,8 @@ public class AttrController { */ @RequestMapping("/update") //@RequiresPermissions("product:attr:update") - public R update(@RequestBody AttrEntity attr){ - attrService.updateById(attr); + public R update(@RequestBody attrVo attr){ + attrService.updateAttrVo(attr); return R.ok(); } diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java index e553944..046694b 100644 --- a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java +++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java @@ -3,6 +3,8 @@ package com.yyf.gulimall.product.service; import com.baomidou.mybatisplus.extension.service.IService; import com.yyf.common.utils.PageUtils; import com.yyf.gulimall.product.entity.AttrEntity; +import com.yyf.gulimall.product.vo.AttrRespVo; +import com.yyf.gulimall.product.vo.attrVo; import java.util.List; import java.util.Map; @@ -19,5 +21,13 @@ public interface AttrService extends IService { PageUtils queryPage(Map params); List getAttrByGroupId(Integer attrGroupId); + + void saveAttr(attrVo attr); + + PageUtils queryBaseAttrPage(Map params, Long catelogId); + + AttrRespVo getAttrInfo(Long attrId); + + void updateAttrVo(attrVo attr); } diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java index 7f251b1..e8736a3 100644 --- a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java +++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java @@ -46,20 +46,21 @@ public class AttrGroupServiceImpl extends ServiceImpl params, Long catelogId){ System.out.println(params+"................................这是条件"); + String key = (String) params.get("key"); + QueryWrapper wrapper = new QueryWrapper(); + if(!StringUtils.isEmpty(key)){ + wrapper.and((obj) -> { + obj.eq("attr_group_id",key).or().like("attr_group_name",key); + }); + } if (catelogId==0){ IPage page = this.page( new Query().getPage(params), - new QueryWrapper() + wrapper ); return new PageUtils(page); }else{ - String key = (String) params.get("key"); - QueryWrapper wrapper = new QueryWrapper().eq("catelog_id",catelogId); - if(!StringUtils.isEmpty(key)){ - wrapper.and((obj) -> { - obj.eq("attr_group_id",key).or().like("attr_group_name",key); - }); - } + wrapper.eq("catelog_id",catelogId); IPage page = this.page(new Query().getPage(params),wrapper); return new PageUtils(page); } diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java index fb6449d..d8c4007 100644 --- a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java +++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java @@ -1,13 +1,24 @@ package com.yyf.gulimall.product.service.impl; +import com.yyf.gulimall.product.dao.AttrAttrgroupRelationDao; +import com.yyf.gulimall.product.dao.AttrGroupDao; +import com.yyf.gulimall.product.dao.CategoryDao; import com.yyf.gulimall.product.entity.AttrAttrgroupRelationEntity; +import com.yyf.gulimall.product.entity.AttrGroupEntity; +import com.yyf.gulimall.product.entity.CategoryEntity; import com.yyf.gulimall.product.service.AttrAttrgroupRelationService; +import com.yyf.gulimall.product.service.CategoryService; +import com.yyf.gulimall.product.vo.AttrRespVo; +import com.yyf.gulimall.product.vo.attrVo; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -17,6 +28,8 @@ import com.yyf.common.utils.Query; import com.yyf.gulimall.product.dao.AttrDao; import com.yyf.gulimall.product.entity.AttrEntity; import com.yyf.gulimall.product.service.AttrService; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; @Service("attrService") @@ -25,6 +38,18 @@ public class AttrServiceImpl extends ServiceImpl implements @Autowired AttrAttrgroupRelationService attrAttrgroupRelationService; + @Autowired + AttrAttrgroupRelationDao attrAttrgroupRelationDao; + + @Autowired + AttrGroupDao attrGroupDao; + + @Autowired + CategoryDao categoryDao; + + @Autowired + CategoryService categoryService; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -52,4 +77,102 @@ public class AttrServiceImpl extends ServiceImpl implements return attrs; } + @Transactional + @Override + public void saveAttr(attrVo attr) { + AttrEntity attrEntity = new AttrEntity(); + BeanUtils.copyProperties(attr,attrEntity); + this.save(attrEntity);//保存基本信息 + AttrAttrgroupRelationEntity attrgroup = new AttrAttrgroupRelationEntity(); + attrgroup.setAttrGroupId(attr.getAttrGroupId()); + attrgroup.setAttrId(attrEntity.getAttrId()); + attrAttrgroupRelationDao.insert(attrgroup); + } + + @Override + public PageUtils queryBaseAttrPage(Map params, Long catelogId) { + QueryWrapper Wrapper = new QueryWrapper<>(); + + if (catelogId!=0){ + Wrapper.eq("catelog_id",catelogId); + } + String key = (String) params.get("key"); + if (!StringUtils.isEmpty(key)){ + Wrapper.and((wrapper)->{ + wrapper.eq("attr_id",key).or().like("attr_name",key); + }); + + } + IPage page = this.page( + new Query().getPage(params), + Wrapper + ); + PageUtils pageUtils = new PageUtils(page); + List records = page.getRecords(); + List respVos = records.stream().map((attrEntity) -> { + AttrRespVo attrRespVo = new AttrRespVo(); + BeanUtils.copyProperties(attrEntity, attrRespVo); + + //设置分类和分组的名称 + AttrAttrgroupRelationEntity attrId = attrAttrgroupRelationDao.selectOne(new QueryWrapper().eq("attr_id", attrEntity.getAttrId())); + if (attrId != null) { + AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrId.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; + } + + @Override + public AttrRespVo getAttrInfo(Long attrId) { + AttrRespVo respVo = new AttrRespVo(); + AttrEntity attrEntity = this.getById(attrId); + BeanUtils.copyProperties(attrEntity,respVo); + //设置分组信息 + AttrAttrgroupRelationEntity attrgroupRelation = attrAttrgroupRelationDao.selectOne(new QueryWrapper().eq("attr_id", attrId)); + if (attrgroupRelation!=null){ + respVo.setAttrGroupId(attrgroupRelation.getAttrGroupId()); + AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrgroupRelation.getAttrGroupId()); + if (attrGroupEntity!=null){ + respVo.setGroupName(attrGroupEntity.getAttrGroupName()); + } + } + + //设置分类信息 + Long catelogId = attrEntity.getCatelogId(); + Long[] catelogPath = categoryService.findCatelogPath(catelogId); + respVo.setCatelogPath(catelogPath); + CategoryEntity categoryEntity = categoryDao.selectById(catelogId); + if (categoryEntity!=null){ + respVo.setCatelogName(categoryEntity.getName()); + } + return respVo; + } + + @Transactional + @Override + public void updateAttrVo(attrVo attr) { + AttrEntity attrEntity = new AttrEntity(); + BeanUtils.copyProperties(attr,attrEntity); + this.updateById(attrEntity); + + AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity(); + relationEntity.setAttrGroupId(attr.getAttrGroupId()); + relationEntity.setAttrId(attr.getAttrId()); + Integer count = attrAttrgroupRelationDao.selectCount(new QueryWrapper().eq("attr_id", attr.getAttrId())); + if (count>0) { + + attrAttrgroupRelationDao.update(relationEntity,new QueryWrapper().eq("attr_id",attr.getAttrId())); + + }else { + attrAttrgroupRelationDao.insert(relationEntity); + } + } + } \ No newline at end of file diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java new file mode 100644 index 0000000..70c80ae --- /dev/null +++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java @@ -0,0 +1,13 @@ +package com.yyf.gulimall.product.vo; + +import lombok.Data; + +@Data +public class AttrRespVo extends attrVo { + + private String catelogName; + private String groupName; + + private Long[] catelogPath; + +} diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java new file mode 100644 index 0000000..aca3d91 --- /dev/null +++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java @@ -0,0 +1,45 @@ +package com.yyf.gulimall.product.vo; + +import lombok.Data; + +@Data +public class attrVo { + + private Long attrId; + /** + * 属性名 + */ + private String attrName; + /** + * 是否需要检索[0-不需要,1-需要] + */ + private Integer searchType; + /** + * 属性图标 + */ + private String icon; + /** + * 可选值列表[用逗号分隔] + */ + private String valueSelect; + /** + * 属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性] + */ + private Integer attrType; + /** + * 启用状态[0 - 禁用,1 - 启用] + */ + private Long enable; + /** + * 所属分类 + */ + private Long catelogId; + /** + * 快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整 + */ + private Integer showDesc; + /** + * 存 + */ + private Long attrGroupId; +} diff --git a/renren-fast/renren-fast.iml b/renren-fast/renren-fast.iml index abd4a26..a4a4667 100644 --- a/renren-fast/renren-fast.iml +++ b/renren-fast/renren-fast.iml @@ -15,8 +15,8 @@ - - + + @@ -25,50 +25,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -79,7 +35,7 @@ - + @@ -217,6 +173,7 @@ + @@ -226,8 +183,49 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- Gitee From 4c8e74ebf4fc84e59f333e094ce730aefff45a05 Mon Sep 17 00:00:00 2001 From: nijichao666 Date: Thu, 26 Nov 2020 09:51:23 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20guli?= =?UTF-8?q?mall-auth-server/gulimall-auth-server.iml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gulimall-auth-server/gulimall-auth-server.iml | 164 ------------------ 1 file changed, 164 deletions(-) delete mode 100644 gulimall-auth-server/gulimall-auth-server.iml diff --git a/gulimall-auth-server/gulimall-auth-server.iml b/gulimall-auth-server/gulimall-auth-server.iml deleted file mode 100644 index 28f5da2..0000000 --- a/gulimall-auth-server/gulimall-auth-server.iml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- Gitee