1、新增分类id获取品牌信息接口
This commit is contained in:
parent
383ca913d5
commit
2c6d3e6942
|
|
@ -32,7 +32,7 @@ public class MemberLevelController {
|
|||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("列表")
|
||||
public R list(@RequestParam Map<String, Object> 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) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class AttrGroupController {
|
|||
* @return r
|
||||
*/
|
||||
@GetMapping("/{attrgroupId}/attr/relation")
|
||||
@ApiOperation("获取关联信息")
|
||||
public R attrRelation(@PathVariable("attrgroupId") Long attrgroupId) {
|
||||
List<AttrEntity> 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<String, Object> params) {
|
||||
PageUtils page=attrService.getAttrNoRelation(params, attrgroupId);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
@PostMapping("/attr/relation")
|
||||
@ApiOperation("添加属性分组与规格关联")
|
||||
public R addRelation(@RequestBody List<AttrGroupRelationVo> vos) {
|
||||
|
||||
attrAttrgroupRelationService.saveBatch(vos);
|
||||
|
|
|
|||
|
|
@ -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<BrandEntity> brandEntities=categoryBrandRelationService.getBrandsByCatId(catId);
|
||||
|
||||
List<BrandVo> 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<CategoryBrandRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
|
|
|||
|
|
@ -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<CategoryBrandRela
|
|||
* @param name 分类名称
|
||||
*/
|
||||
void updateCategory(Long catId, String name);
|
||||
|
||||
/**
|
||||
* 查询指定分类的品牌信息
|
||||
* @param catId 分类id
|
||||
* @return list
|
||||
*/
|
||||
List<BrandEntity> getBrandsByCatId(Long catId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<CategoryBrandR
|
|||
@Resource
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
@Autowired
|
||||
private BrandService brandService;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveDetail(CategoryBrandRelationEntity categoryBrandRelation) {
|
||||
|
|
@ -59,4 +67,13 @@ public class CategoryBrandRelationServiceImpl extends ServiceImpl<CategoryBrandR
|
|||
super.update(entity, new LambdaUpdateWrapper<CategoryBrandRelationEntity>()
|
||||
.eq(CategoryBrandRelationEntity::getCatelogId, catId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrandEntity> getBrandsByCatId(Long catId) {
|
||||
List<CategoryBrandRelationEntity> categoryBrandRelationEntities = super.baseMapper.selectList(
|
||||
new LambdaQueryWrapper<CategoryBrandRelationEntity>().eq(CategoryBrandRelationEntity::getCatelogId, catId)
|
||||
);
|
||||
return categoryBrandRelationEntities.stream()
|
||||
.map(item -> brandService.getById(item.getBrandId())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
Loading…
Reference in New Issue