|
|
|
@ -0,0 +1,69 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* https://www.mall4j.com/
|
|
|
|
|
*
|
|
|
|
|
* 未经允许,不可做商业用途!
|
|
|
|
|
*
|
|
|
|
|
* 版权所有,侵权必究!
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package com.yami.shop.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.yami.shop.bean.model.Brand;
|
|
|
|
|
import com.yami.shop.dao.BrandMapper;
|
|
|
|
|
import com.yami.shop.dao.CategoryBrandMapper;
|
|
|
|
|
import com.yami.shop.service.BrandService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 品牌服务实现类,提供品牌相关的业务逻辑
|
|
|
|
|
*
|
|
|
|
|
* @author lanhai
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {
|
|
|
|
|
|
|
|
|
|
// 自动注入BrandMapper,用于操作品牌数据
|
|
|
|
|
@Autowired
|
|
|
|
|
private BrandMapper brandMapper;
|
|
|
|
|
|
|
|
|
|
// 自动注入CategoryBrandMapper,用于操作品牌与分类关系的数据
|
|
|
|
|
@Autowired
|
|
|
|
|
private CategoryBrandMapper categoryBrandMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据品牌名称查询品牌信息
|
|
|
|
|
* @param brandName 品牌名称
|
|
|
|
|
* @return 品牌对象
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Brand getByBrandName(String brandName) {
|
|
|
|
|
return brandMapper.getByBrandName(brandName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据品牌ID删除品牌以及其与分类的关系
|
|
|
|
|
* @param brandId 品牌ID
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteByBrand(Long brandId) {
|
|
|
|
|
brandMapper.deleteById(brandId);
|
|
|
|
|
categoryBrandMapper.deleteByBrandId(brandId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据分类ID查询品牌列表
|
|
|
|
|
* @param categoryId 分类ID
|
|
|
|
|
* @return 品牌列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Brand> listByCategoryId(Long categoryId) {
|
|
|
|
|
return brandMapper.listByCategoryId(categoryId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|