Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
travel-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cloud
travel-cloud
Commits
2eb75f4c
提交
2eb75f4c
authored
4月 14, 2025
作者:
hzh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
品牌删除增加限制
上级
3851cee4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
24 行增加
和
0 行删除
+24
-0
ErrorCodeConstants.java
...va/org/dromara/mall/enums/product/ErrorCodeConstants.java
+1
-0
ProductSpuService.java
...a/org/dromara/mall/service/product/ProductSpuService.java
+8
-0
ProductBrandServiceImpl.java
...ra/mall/service/product/impl/ProductBrandServiceImpl.java
+11
-0
ProductSpuServiceImpl.java
...mara/mall/service/product/impl/ProductSpuServiceImpl.java
+4
-0
没有找到文件。
ruoyi-modules/ruoyi-mall/src/main/java/org/dromara/mall/enums/product/ErrorCodeConstants.java
浏览文件 @
2eb75f4c
...
@@ -22,6 +22,7 @@ public interface ErrorCodeConstants {
...
@@ -22,6 +22,7 @@ public interface ErrorCodeConstants {
ErrorCode
BRAND_NOT_EXISTS
=
new
ErrorCode
(
1_008_002_000
,
"品牌不存在"
);
ErrorCode
BRAND_NOT_EXISTS
=
new
ErrorCode
(
1_008_002_000
,
"品牌不存在"
);
ErrorCode
BRAND_DISABLED
=
new
ErrorCode
(
1_008_002_001
,
"品牌已禁用"
);
ErrorCode
BRAND_DISABLED
=
new
ErrorCode
(
1_008_002_001
,
"品牌已禁用"
);
ErrorCode
BRAND_NAME_EXISTS
=
new
ErrorCode
(
1_008_002_002
,
"品牌名称已存在"
);
ErrorCode
BRAND_NAME_EXISTS
=
new
ErrorCode
(
1_008_002_002
,
"品牌名称已存在"
);
ErrorCode
BRAND_HAVE_BIND_SPU
=
new
ErrorCode
(
1_008_001_005
,
"品牌下存在商品,无法删除"
);
// ========== 商品属性项 1-008-003-000 ==========
// ========== 商品属性项 1-008-003-000 ==========
ErrorCode
PROPERTY_NOT_EXISTS
=
new
ErrorCode
(
1_008_003_000
,
"属性项不存在"
);
ErrorCode
PROPERTY_NOT_EXISTS
=
new
ErrorCode
(
1_008_003_000
,
"属性项不存在"
);
...
...
ruoyi-modules/ruoyi-mall/src/main/java/org/dromara/mall/service/product/ProductSpuService.java
浏览文件 @
2eb75f4c
...
@@ -124,6 +124,14 @@ public interface ProductSpuService {
...
@@ -124,6 +124,14 @@ public interface ProductSpuService {
*/
*/
Long
getSpuCountByCategoryId
(
Long
categoryId
);
Long
getSpuCountByCategoryId
(
Long
categoryId
);
/**
* 通过品牌 brandId 查询 SPU 个数
*
* @param brandId 品牌id
* @return SPU 数量
*/
Long
getSpuCountByBrandId
(
Long
brandId
);
/**
/**
* 校验商品是否有效。如下情况,视为无效:
* 校验商品是否有效。如下情况,视为无效:
...
...
ruoyi-modules/ruoyi-mall/src/main/java/org/dromara/mall/service/product/impl/ProductBrandServiceImpl.java
浏览文件 @
2eb75f4c
...
@@ -14,6 +14,8 @@ import org.dromara.mall.controller.product.admin.brand.vo.ProductBrandUpdateReqV
...
@@ -14,6 +14,8 @@ import org.dromara.mall.controller.product.admin.brand.vo.ProductBrandUpdateReqV
import
org.dromara.mall.domain.product.ProductBrandDO
;
import
org.dromara.mall.domain.product.ProductBrandDO
;
import
org.dromara.mall.mapper.product.ProductBrandMapper
;
import
org.dromara.mall.mapper.product.ProductBrandMapper
;
import
org.dromara.mall.service.product.ProductBrandService
;
import
org.dromara.mall.service.product.ProductBrandService
;
import
org.dromara.mall.service.product.ProductSpuService
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -36,6 +38,10 @@ public class ProductBrandServiceImpl implements ProductBrandService {
...
@@ -36,6 +38,10 @@ public class ProductBrandServiceImpl implements ProductBrandService {
@Resource
@Resource
private
ProductBrandMapper
productBrandMapper
;
private
ProductBrandMapper
productBrandMapper
;
@Resource
@Lazy
// 循环依赖,避免报错
private
ProductSpuService
productSpuService
;
@Override
@Override
public
Long
createBrand
(
ProductBrandCreateReqVO
createReqVO
)
{
public
Long
createBrand
(
ProductBrandCreateReqVO
createReqVO
)
{
// 校验
// 校验
...
@@ -62,6 +68,11 @@ public class ProductBrandServiceImpl implements ProductBrandService {
...
@@ -62,6 +68,11 @@ public class ProductBrandServiceImpl implements ProductBrandService {
public
void
deleteBrand
(
Long
id
)
{
public
void
deleteBrand
(
Long
id
)
{
// 校验存在
// 校验存在
validateBrandExists
(
id
);
validateBrandExists
(
id
);
// 校验品牌是否绑定了 SPU
Long
spuCount
=
productSpuService
.
getSpuCountByBrandId
(
id
);
if
(
spuCount
>
0
)
{
throw
exception
(
BRAND_HAVE_BIND_SPU
);
}
// 删除
// 删除
productBrandMapper
.
deleteById
(
id
);
productBrandMapper
.
deleteById
(
id
);
}
}
...
...
ruoyi-modules/ruoyi-mall/src/main/java/org/dromara/mall/service/product/impl/ProductSpuServiceImpl.java
浏览文件 @
2eb75f4c
...
@@ -273,4 +273,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
...
@@ -273,4 +273,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
return
productSpuMapper
.
selectCount
(
ProductSpuDO:
:
getCategoryId
,
categoryId
);
return
productSpuMapper
.
selectCount
(
ProductSpuDO:
:
getCategoryId
,
categoryId
);
}
}
@Override
public
Long
getSpuCountByBrandId
(
Long
brandId
)
{
return
productSpuMapper
.
selectCount
(
ProductSpuDO:
:
getBrandId
,
brandId
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论