parent
32abbd5ad5
commit
561024a571
|
|
@ -0,0 +1,32 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
|
||||
//添加品牌关联
|
||||
export function addCategoryBrandRelation(data) {
|
||||
return request({
|
||||
url: '/mall-product/product/categorybrandrelation/save',
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//删除品牌关联
|
||||
export function delCategoryBrandRelation(ids) {
|
||||
return request({
|
||||
url: '/mall-product/product/categorybrandrelation/delete',
|
||||
method: 'delete',
|
||||
data:ids
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//获取品牌关联
|
||||
export function categoryBrandRelationList(data) {
|
||||
return request({
|
||||
url: '/mall-product/product/categorybrandrelation/catelog/list',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -74,17 +74,18 @@
|
|||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
|
||||
<el-dialog title="关联分类" :visible.sync="cateRelationDialogVisible" width="30%">
|
||||
<el-popover placement="right-end" v-model="popCatelogSelectVisible">
|
||||
<category-cascader :catelogPath.sync="catelogPath"></category-cascader>
|
||||
<div style="text-align: right; margin: 0">
|
||||
<el-button size="mini" type="text" @click="popCatelogSelectVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="addCatelogSelect">确定</el-button>
|
||||
</div>
|
||||
<el-button slot="reference">新增关联</el-button>
|
||||
</el-popover>
|
||||
<el-dialog title="关联分类" :visible.sync="cateRelationDialogVisible" width="30%" @close="closeDialog">
|
||||
<div style="margin-bottom: 10px">
|
||||
<el-popover placement="right-end" v-model="popCatelogSelectVisible">
|
||||
<category-cascader :catelogPath.sync="catelogPath"></category-cascader>
|
||||
<div style="text-align: right; margin: 0">
|
||||
<el-button size="mini" type="text" @click="popCatelogSelectVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="addCatelogSelect">确定</el-button>
|
||||
</div>
|
||||
<el-button slot="reference" icon="el-icon-circle-plus-outline" size="mini">新增关联</el-button>
|
||||
</el-popover>
|
||||
</div>
|
||||
<el-table :data="cateRelationTableData" style="width: 100%">
|
||||
<el-table-column prop="id" label="#"></el-table-column>
|
||||
<el-table-column prop="brandName" label="品牌名"></el-table-column>
|
||||
<el-table-column prop="catelogName" label="分类名"></el-table-column>
|
||||
<el-table-column fixed="right" header-align="center" align="center" label="操作">
|
||||
|
|
@ -109,7 +110,13 @@
|
|||
<script>
|
||||
import AddOrUpdate from "./brand-add-or-update";
|
||||
import {editBrand, getBrandList,delBrand} from "@/api/mall/product/brand";
|
||||
// import CategoryCascader from "../common/category-cascader";
|
||||
import CategoryCascader from "../../components/mall/category-cascader"
|
||||
import {
|
||||
addCategoryBrandRelation,
|
||||
categoryBrandRelationList,
|
||||
delCategoryBrandRelation
|
||||
} from "@/api/mall/product/category-relation"
|
||||
|
||||
export default {
|
||||
name: "Brand",
|
||||
data() {
|
||||
|
|
@ -133,7 +140,7 @@ export default {
|
|||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
// CategoryCascader
|
||||
CategoryCascader
|
||||
},
|
||||
created() {
|
||||
this.getDataList();
|
||||
|
|
@ -141,44 +148,37 @@ export default {
|
|||
methods: {
|
||||
addCatelogSelect() {
|
||||
this.popCatelogSelectVisible = false;
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/product/categorybrandrelation/save"),
|
||||
method: "post",
|
||||
data: this.$http.adornData({
|
||||
brandId: this.brandId,
|
||||
catelogId: this.catelogPath[this.catelogPath.length - 1]
|
||||
}, false)
|
||||
}).then(({data}) => {
|
||||
let data ={
|
||||
brandId: this.brandId,
|
||||
catelogId: this.catelogPath[this.catelogPath.length - 1]
|
||||
}
|
||||
addCategoryBrandRelation(data).then(res =>{
|
||||
this.getCateRelation();
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
deleteCateRelationHandle(id, brandId) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/product/categorybrandrelation/delete"),
|
||||
method: "post",
|
||||
data: this.$http.adornData([id], false)
|
||||
}).then(({data}) => {
|
||||
delCategoryBrandRelation([id]).then(res =>{
|
||||
this.getCateRelation();
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
updateCatelogHandle(brandId) {
|
||||
this.cateRelationDialogVisible = true;
|
||||
this.brandId = brandId;
|
||||
this.getCateRelation();
|
||||
},
|
||||
getCateRelation() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/product/categorybrandrelation/catelog/list"),
|
||||
method: "get",
|
||||
params: this.$http.adornParams({
|
||||
brandId: this.brandId
|
||||
})
|
||||
}).then(({data}) => {
|
||||
this.cateRelationTableData = data.data;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
getCateRelation() {
|
||||
let data ={
|
||||
brandId: this.brandId
|
||||
}
|
||||
categoryBrandRelationList(data).then(res =>{
|
||||
this.cateRelationTableData = res.page;
|
||||
})
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
|
|
@ -246,6 +246,11 @@ export default {
|
|||
this.pageIndex = 1;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
//关闭对话框时清空级联分类
|
||||
closeDialog() {
|
||||
this.catelogPath=[]
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,17 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-input
|
||||
style="width: 400px;margin-bottom: 20px"
|
||||
clearable
|
||||
prefix-icon="el-icon-search"
|
||||
@input="rest"
|
||||
placeholder="输入关键字进行过滤"
|
||||
v-model="filterText">
|
||||
</el-input>
|
||||
|
||||
<el-tree
|
||||
:filter-node-method="filterNode"
|
||||
:data="menus"
|
||||
:props="defaultProps"
|
||||
:expand-on-click-node="false"
|
||||
|
|
@ -130,16 +140,27 @@ export default {
|
|||
productUnit: [
|
||||
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
filterText: '',
|
||||
};
|
||||
},
|
||||
|
||||
//计算属性 类似于data概念
|
||||
computed: {},
|
||||
//监控data中的数据变化
|
||||
watch: {},
|
||||
watch: {
|
||||
filterText(val) {
|
||||
this.$refs.menuTree.filter(val);
|
||||
}
|
||||
},
|
||||
//方法集合
|
||||
methods: {
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.name.indexOf(value) !== -1;
|
||||
},
|
||||
|
||||
// 选择图标
|
||||
selected(name) {
|
||||
this.category.icon = name;
|
||||
|
|
@ -347,6 +368,13 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
//搜索框删除内容后重置
|
||||
rest() {
|
||||
if (!this.filterText) {
|
||||
this.getMenus()
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
//生命周期 - 创建完成(可以访问当前this实例)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class BrandController {
|
|||
@ApiOperation("修改")
|
||||
@Log(title = "品牌管理", businessType = BusinessType.UPDATE)
|
||||
public R update(@Validated(UpdateGroup.class) @RequestBody BrandEntity brand){
|
||||
brandService.updateById(brand);
|
||||
brandService.updateDetail(brand);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
package com.xjs.mall.product.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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 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.CategoryBrandRelationEntity;
|
||||
import com.xjs.mall.product.service.CategoryBrandRelationService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.R;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -22,10 +22,11 @@ import com.xjs.utils.R;
|
|||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 10:16:53
|
||||
* @since 2022-03-15 10:16:53
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("product/categorybrandrelation")
|
||||
@Api(tags = "商城-商品-品牌分类关联")
|
||||
public class CategoryBrandRelationController {
|
||||
@Autowired
|
||||
private CategoryBrandRelationService categoryBrandRelationService;
|
||||
|
|
@ -33,50 +34,40 @@ public class CategoryBrandRelationController {
|
|||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = categoryBrandRelationService.queryPage(params);
|
||||
@GetMapping("/catelog/list")
|
||||
@ApiOperation("列表")
|
||||
public R list(@RequestParam Long brandId) {
|
||||
|
||||
return R.ok().put("page", page);
|
||||
LambdaQueryWrapper<CategoryBrandRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CategoryBrandRelationEntity::getBrandId, brandId);
|
||||
|
||||
List<CategoryBrandRelationEntity> list = categoryBrandRelationService.list(wrapper);
|
||||
|
||||
return R.ok().put("page", list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CategoryBrandRelationEntity categoryBrandRelation = categoryBrandRelationService.getById(id);
|
||||
|
||||
return R.ok().put("categoryBrandRelation", categoryBrandRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody CategoryBrandRelationEntity categoryBrandRelation){
|
||||
categoryBrandRelationService.save(categoryBrandRelation);
|
||||
@PostMapping("/save")
|
||||
@ApiOperation("保存")
|
||||
@Log(title = "品牌分类关联", businessType = BusinessType.INSERT)
|
||||
public R save(@Validated(AddGroup.class) @RequestBody CategoryBrandRelationEntity categoryBrandRelation) {
|
||||
categoryBrandRelationService.saveDetail(categoryBrandRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody CategoryBrandRelationEntity categoryBrandRelation){
|
||||
categoryBrandRelationService.updateById(categoryBrandRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
categoryBrandRelationService.removeByIds(Arrays.asList(ids));
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除")
|
||||
@Log(title = "品牌分类关联", businessType = BusinessType.DELETE)
|
||||
public R delete(@RequestBody Long[] ids) {
|
||||
categoryBrandRelationService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class CategoryController {
|
|||
@ApiOperation("修改")
|
||||
@Log(title = "商品分类", businessType = BusinessType.UPDATE)
|
||||
public R update(@Validated(UpdateGroup.class) @RequestBody CategoryEntity category) {
|
||||
categoryService.updateById(category);
|
||||
categoryService.updateCascade(category);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@ package com.xjs.mall.product.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 品牌分类关联
|
||||
*
|
||||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 10:16:53
|
||||
|
|
@ -20,24 +22,28 @@ public class CategoryBrandRelationEntity implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
@NotNull(groups = {AddGroup.class, UpdateGroup.class})
|
||||
private Long brandId;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
@NotNull(groups = {AddGroup.class, UpdateGroup.class})
|
||||
private Long catelogId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 品牌名称
|
||||
*/
|
||||
private String brandName;
|
||||
|
||||
/**
|
||||
*
|
||||
*分类名称
|
||||
*/
|
||||
private String catelogName;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,11 @@ import java.util.Map;
|
|||
public interface BrandService extends IService<BrandEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 更新所有细节
|
||||
* @param brand 品牌实体类
|
||||
*/
|
||||
void updateDetail(BrandEntity brand);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,36 @@
|
|||
package com.xjs.mall.product.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.mall.product.entity.CategoryBrandRelationEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 品牌分类关联
|
||||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 10:16:53
|
||||
* @since 2022-03-15 10:16:53
|
||||
*/
|
||||
public interface CategoryBrandRelationService extends IService<CategoryBrandRelationEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 保存详情
|
||||
* @param categoryBrandRelation entity
|
||||
*/
|
||||
void saveDetail(CategoryBrandRelationEntity categoryBrandRelation);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param brandId 品牌id
|
||||
* @param name 品牌名称
|
||||
*/
|
||||
void updateBrand(Long brandId, String name);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param catId 分类id
|
||||
* @param name 分类名称
|
||||
*/
|
||||
void updateCategory(Long catId, String name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,5 +36,11 @@ public interface CategoryService extends IService<CategoryEntity> {
|
|||
* @return long s
|
||||
*/
|
||||
Long[] finCatelogPath(Long catelogId);
|
||||
|
||||
/**
|
||||
* 级联更新
|
||||
* @param category 分类实体类
|
||||
*/
|
||||
void updateCascade(CategoryEntity category);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ import com.xjs.utils.PageUtils;
|
|||
import com.xjs.utils.Query;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("attrGroupService")
|
||||
@Transactional
|
||||
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService {
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -6,17 +6,24 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.xjs.mall.product.dao.BrandDao;
|
||||
import com.xjs.mall.product.entity.BrandEntity;
|
||||
import com.xjs.mall.product.service.BrandService;
|
||||
import com.xjs.mall.product.service.CategoryBrandRelationService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("brandService")
|
||||
@Transactional
|
||||
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {
|
||||
|
||||
@Autowired
|
||||
private CategoryBrandRelationService categoryBrandRelationService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String key = (String) params.get(Query.KEY_NAME);
|
||||
|
|
@ -36,4 +43,17 @@ public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> impleme
|
|||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetail(BrandEntity brand) {
|
||||
//保证冗余字段的数据一致性
|
||||
super.updateById(brand);
|
||||
|
||||
if (StringUtils.isNotEmpty(brand.getName())) {
|
||||
//同步更新其他表
|
||||
categoryBrandRelationService.updateBrand(brand.getBrandId(), brand.getName());
|
||||
|
||||
// todo 更新其他关联信息
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,62 @@
|
|||
package com.xjs.mall.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.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
|
||||
import com.xjs.mall.product.dao.BrandDao;
|
||||
import com.xjs.mall.product.dao.CategoryBrandRelationDao;
|
||||
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.CategoryBrandRelationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@Service("categoryBrandRelationService")
|
||||
@Transactional
|
||||
public class CategoryBrandRelationServiceImpl extends ServiceImpl<CategoryBrandRelationDao, CategoryBrandRelationEntity> implements CategoryBrandRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CategoryBrandRelationEntity> page = this.page(
|
||||
new Query<CategoryBrandRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CategoryBrandRelationEntity>()
|
||||
);
|
||||
@Resource
|
||||
private BrandDao brandDao;
|
||||
|
||||
return new PageUtils(page);
|
||||
@Resource
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveDetail(CategoryBrandRelationEntity categoryBrandRelation) {
|
||||
Long brandId = categoryBrandRelation.getBrandId();
|
||||
Long catelogId = categoryBrandRelation.getCatelogId();
|
||||
|
||||
BrandEntity brandEntity = brandDao.selectById(brandId);
|
||||
CategoryEntity categoryEntity = categoryDao.selectById(catelogId);
|
||||
|
||||
categoryBrandRelation.setBrandName(brandEntity.getName());
|
||||
categoryBrandRelation.setCatelogName(categoryEntity.getName());
|
||||
|
||||
super.save(categoryBrandRelation);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void updateBrand(Long brandId, String name) {
|
||||
CategoryBrandRelationEntity entity = new CategoryBrandRelationEntity();
|
||||
entity.setBrandId(brandId);
|
||||
entity.setBrandName(name);
|
||||
|
||||
super.update(entity, new LambdaUpdateWrapper<CategoryBrandRelationEntity>()
|
||||
.eq(CategoryBrandRelationEntity::getBrandId, brandId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCategory(Long catId, String name) {
|
||||
CategoryBrandRelationEntity entity = new CategoryBrandRelationEntity();
|
||||
entity.setCatelogId(catId);
|
||||
entity.setCatelogName(name);
|
||||
|
||||
super.update(entity, new LambdaUpdateWrapper<CategoryBrandRelationEntity>()
|
||||
.eq(CategoryBrandRelationEntity::getCatelogId, catId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xjs.mall.product.dao.CategoryDao;
|
||||
import com.xjs.mall.product.entity.CategoryEntity;
|
||||
import com.xjs.mall.product.service.CategoryBrandRelationService;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
|
@ -16,11 +19,15 @@ import java.util.stream.Collectors;
|
|||
|
||||
|
||||
@Service("categoryService")
|
||||
@Transactional
|
||||
public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService {
|
||||
|
||||
@Resource
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
@Autowired
|
||||
private CategoryBrandRelationService categoryBrandRelationService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CategoryEntity> page = this.page(
|
||||
|
|
@ -63,6 +70,15 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|||
return parentPath.toArray(new Long[parentPath.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCascade(CategoryEntity category) {
|
||||
//更新自己
|
||||
super.updateById(category);
|
||||
|
||||
//更新关联表
|
||||
categoryBrandRelationService.updateCategory(category.getCatId(), category.getName());
|
||||
}
|
||||
|
||||
//225,25,2
|
||||
private List<Long> findParentPath(Long catelogId, List<Long> paths) {
|
||||
//1、收集当前节点id
|
||||
|
|
@ -95,4 +111,4 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue