From 2c6d3e6942f47bef8530ad2299ff0ec24e28736a Mon Sep 17 00:00:00 2001 From: xjs <1294405880@qq.com> Date: Sat, 19 Mar 2022 15:23:22 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E5=88=86=E7=B1=BBi?= =?UTF-8?q?d=E8=8E=B7=E5=8F=96=E5=93=81=E7=89=8C=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MemberLevelController.java | 10 +++---- .../controller/AttrGroupController.java | 3 +++ .../CategoryBrandRelationController.java | 27 +++++++++++++++++-- .../service/CategoryBrandRelationService.java | 10 +++++++ .../CategoryBrandRelationServiceImpl.java | 17 ++++++++++++ .../java/com/xjs/mall/product/vo/BrandVo.java | 23 ++++++++++++++++ 6 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/vo/BrandVo.java diff --git a/xjs-business/xjs-project-mall/mall-member/src/main/java/com/xjs/mall/member/controller/MemberLevelController.java b/xjs-business/xjs-project-mall/mall-member/src/main/java/com/xjs/mall/member/controller/MemberLevelController.java index 95f59e8b..956aa3e6 100644 --- a/xjs-business/xjs-project-mall/mall-member/src/main/java/com/xjs/mall/member/controller/MemberLevelController.java +++ b/xjs-business/xjs-project-mall/mall-member/src/main/java/com/xjs/mall/member/controller/MemberLevelController.java @@ -32,7 +32,7 @@ public class MemberLevelController { /** * 列表 */ - @RequestMapping("/list") + @GetMapping("/list") @ApiOperation("列表") public R list(@RequestParam Map params) { PageUtils page = memberLevelService.queryPage(params); @@ -44,7 +44,7 @@ public class MemberLevelController { /** * 信息 */ - @RequestMapping("/info/{id}") + @GetMapping("/info/{id}") @ApiOperation("信息") public R info(@PathVariable("id") Long id) { MemberLevelEntity memberLevel = memberLevelService.getById(id); @@ -55,7 +55,7 @@ public class MemberLevelController { /** * 保存 */ - @RequestMapping("/save") + @PostMapping("/save") @ApiOperation("保存") @Log(title = "会员等级", businessType = BusinessType.INSERT) public R save(@RequestBody MemberLevelEntity memberLevel) { @@ -67,7 +67,7 @@ public class MemberLevelController { /** * 修改 */ - @RequestMapping("/update") + @PutMapping("/update") @ApiOperation("修改") @Log(title = "会员等级", businessType = BusinessType.UPDATE) public R update(@RequestBody MemberLevelEntity memberLevel) { @@ -79,7 +79,7 @@ public class MemberLevelController { /** * 删除 */ - @RequestMapping("/delete") + @DeleteMapping("/delete") @ApiOperation("删除") @Log(title = "会员等级", businessType = BusinessType.DELETE) public R delete(@RequestBody Long[] ids) { diff --git a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/AttrGroupController.java b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/AttrGroupController.java index 20bf1bea..83a68e02 100644 --- a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/AttrGroupController.java +++ b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/AttrGroupController.java @@ -52,6 +52,7 @@ public class AttrGroupController { * @return r */ @GetMapping("/{attrgroupId}/attr/relation") + @ApiOperation("获取关联信息") public R attrRelation(@PathVariable("attrgroupId") Long attrgroupId) { List attrList = attrService.getRelationAttr(attrgroupId); return R.ok().put("data", attrList); @@ -64,12 +65,14 @@ public class AttrGroupController { * @return R */ @GetMapping("/{attrgroupId}/noattr/relation") + @ApiOperation("获取未被关联的信息") public R attrNoRelation(@PathVariable("attrgroupId") Long attrgroupId, @RequestParam Map params) { PageUtils page=attrService.getAttrNoRelation(params, attrgroupId); return R.ok().put("page", page); } @PostMapping("/attr/relation") + @ApiOperation("添加属性分组与规格关联") public R addRelation(@RequestBody List vos) { attrAttrgroupRelationService.saveBatch(vos); diff --git a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/CategoryBrandRelationController.java b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/CategoryBrandRelationController.java index 2d35d311..9c7c303c 100644 --- a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/CategoryBrandRelationController.java +++ b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/controller/CategoryBrandRelationController.java @@ -3,8 +3,10 @@ package com.xjs.mall.product.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; +import com.xjs.mall.product.entity.BrandEntity; import com.xjs.mall.product.entity.CategoryBrandRelationEntity; import com.xjs.mall.product.service.CategoryBrandRelationService; +import com.xjs.mall.product.vo.BrandVo; import com.xjs.utils.R; import com.xjs.validation.group.AddGroup; import io.swagger.annotations.Api; @@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; /** @@ -32,10 +35,30 @@ public class CategoryBrandRelationController { private CategoryBrandRelationService categoryBrandRelationService; /** - * 列表 + *根据分类id找到品牌 + * @param catId 分类 + * @return r + */ + @GetMapping("/brands/list") + @ApiOperation("分类关联品牌列表") + public R catelogList(@RequestParam("brand") Long catId) { + List brandEntities=categoryBrandRelationService.getBrandsByCatId(catId); + + List collect = brandEntities.stream().map(item -> { + BrandVo brandVo = new BrandVo(); + brandVo.setBrandId(item.getBrandId()); + brandVo.setBrandName(item.getName()); + return brandVo; + }).collect(Collectors.toList()); + + return R.ok().put("data", collect); + } + + /** + * 获取当前品牌关联的所有分类列表 */ @GetMapping("/catelog/list") - @ApiOperation("列表") + @ApiOperation("品牌关联分类列表") public R list(@RequestParam Long brandId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/CategoryBrandRelationService.java b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/CategoryBrandRelationService.java index 9208e3ef..13efe570 100644 --- a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/CategoryBrandRelationService.java +++ b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/CategoryBrandRelationService.java @@ -1,8 +1,11 @@ package com.xjs.mall.product.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.xjs.mall.product.entity.BrandEntity; import com.xjs.mall.product.entity.CategoryBrandRelationEntity; +import java.util.List; + /** * 品牌分类关联 * @@ -32,5 +35,12 @@ public interface CategoryBrandRelationService extends IService getBrandsByCatId(Long catId); } diff --git a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/impl/CategoryBrandRelationServiceImpl.java b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/impl/CategoryBrandRelationServiceImpl.java index 06e79898..d24de7eb 100644 --- a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/impl/CategoryBrandRelationServiceImpl.java +++ b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/service/impl/CategoryBrandRelationServiceImpl.java @@ -1,5 +1,6 @@ package com.xjs.mall.product.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xjs.mall.product.dao.BrandDao; @@ -8,11 +9,15 @@ import com.xjs.mall.product.dao.CategoryDao; import com.xjs.mall.product.entity.BrandEntity; import com.xjs.mall.product.entity.CategoryBrandRelationEntity; import com.xjs.mall.product.entity.CategoryEntity; +import com.xjs.mall.product.service.BrandService; import com.xjs.mall.product.service.CategoryBrandRelationService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; @Service("categoryBrandRelationService") @@ -25,6 +30,9 @@ public class CategoryBrandRelationServiceImpl extends ServiceImpl() .eq(CategoryBrandRelationEntity::getCatelogId, catId)); } + + @Override + public List getBrandsByCatId(Long catId) { + List categoryBrandRelationEntities = super.baseMapper.selectList( + new LambdaQueryWrapper().eq(CategoryBrandRelationEntity::getCatelogId, catId) + ); + return categoryBrandRelationEntities.stream() + .map(item -> brandService.getById(item.getBrandId())).collect(Collectors.toList()); + } } diff --git a/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/vo/BrandVo.java b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/vo/BrandVo.java new file mode 100644 index 00000000..be6f0154 --- /dev/null +++ b/xjs-business/xjs-project-mall/mall-product/src/main/java/com/xjs/mall/product/vo/BrandVo.java @@ -0,0 +1,23 @@ +package com.xjs.mall.product.vo; + +import lombok.Data; + +/** + * 品牌vo + * @author xiejs + * @since 2022-03-19 + */ +@Data +public class BrandVo { + + /** + * 品牌id + */ + private Long brandId; + + + /** + * 品牌名称 + */ + private String brandName; +}