Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pms
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
pms
Commits
0ebe743e
提交
0ebe743e
authored
7月 25, 2023
作者:
xiaowang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增:商品编辑接口
上级
b5eb8629
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
82 行增加
和
7 行删除
+82
-7
MallGoodsController.java
...java/com/mmc/pms/controller/mall/MallGoodsController.java
+7
-0
MallGoodsDao.java
src/main/java/com/mmc/pms/dao/mall/MallGoodsDao.java
+6
-0
MallGoodsVO.java
src/main/java/com/mmc/pms/model/mall/MallGoodsVO.java
+10
-0
MallGoodsService.java
src/main/java/com/mmc/pms/service/mall/MallGoodsService.java
+2
-0
MallGoodsServiceImpl.java
...a/com/mmc/pms/service/mall/impl/MallGoodsServiceImpl.java
+35
-7
MallGoodsDao.xml
src/main/resources/mapper/mall/MallGoodsDao.xml
+22
-0
没有找到文件。
src/main/java/com/mmc/pms/controller/mall/MallGoodsController.java
浏览文件 @
0ebe743e
...
@@ -37,4 +37,11 @@ public class MallGoodsController extends BaseController {
...
@@ -37,4 +37,11 @@ public class MallGoodsController extends BaseController {
public
ResultBody
<
MallGoodsVO
>
mallGoodsDetails
(
@RequestParam
Long
id
)
{
public
ResultBody
<
MallGoodsVO
>
mallGoodsDetails
(
@RequestParam
Long
id
)
{
return
mallGoodsService
.
mallGoodsDetails
(
id
);
return
mallGoodsService
.
mallGoodsDetails
(
id
);
}
}
@ApiOperation
(
value
=
"编辑商城商品"
)
@PostMapping
(
"editMallGoods"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
editMallGoods
(
@RequestBody
MallGoodsVO
mallGoodsVO
,
HttpServletRequest
request
)
{
return
mallGoodsService
.
editMallGoods
(
mallGoodsVO
,
this
.
getUserLoginInfoFromRedis
(
request
).
getUserAccountId
());
}
}
}
src/main/java/com/mmc/pms/dao/mall/MallGoodsDao.java
浏览文件 @
0ebe743e
...
@@ -35,4 +35,10 @@ public interface MallGoodsDao {
...
@@ -35,4 +35,10 @@ public interface MallGoodsDao {
List
<
GoodsSpecDO
>
getMallGoodsSpec
(
Long
id
);
List
<
GoodsSpecDO
>
getMallGoodsSpec
(
Long
id
);
List
<
GoodsSpecValuesDO
>
getMallGoodsSpecValues
(
List
<
Integer
>
ids
);
List
<
GoodsSpecValuesDO
>
getMallGoodsSpecValues
(
List
<
Integer
>
ids
);
void
updateMallGoods
(
@Param
(
"mallGoodsDO"
)
MallGoodsDO
mallGoodsDO
);
void
deleteMallGoodsResources
(
Long
id
);
void
deleteMallGoodsSpec
(
Long
id
);
}
}
src/main/java/com/mmc/pms/model/mall/MallGoodsVO.java
浏览文件 @
0ebe743e
...
@@ -26,31 +26,41 @@ public class MallGoodsVO {
...
@@ -26,31 +26,41 @@ public class MallGoodsVO {
@ApiModelProperty
(
value
=
"id"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"id"
,
example
=
"1"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
private
Long
id
;
private
Long
id
;
@ApiModelProperty
(
value
=
"商品名称"
,
example
=
"这是商品名称"
,
required
=
true
)
@ApiModelProperty
(
value
=
"商品名称"
,
example
=
"这是商品名称"
,
required
=
true
)
@NotBlank
(
message
=
"商品名称不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"商品名称不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
tradeName
;
private
String
tradeName
;
@ApiModelProperty
(
value
=
"商品描述"
,
example
=
"商品描述"
,
required
=
true
)
@ApiModelProperty
(
value
=
"商品描述"
,
example
=
"商品描述"
,
required
=
true
)
@NotBlank
(
message
=
"商品描述不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"商品描述不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
private
String
description
;
@ApiModelProperty
(
value
=
"商品资源:图片or视频及其他"
)
@ApiModelProperty
(
value
=
"商品资源:图片or视频及其他"
)
@NotEmpty
(
message
=
"图片不能为空"
)
@NotEmpty
(
message
=
"图片不能为空"
)
private
List
<
GoodsResourcesVO
>
resourcesList
;
private
List
<
GoodsResourcesVO
>
resourcesList
;
@ApiModelProperty
(
value
=
"一级分类id"
,
example
=
"1"
,
required
=
true
)
@ApiModelProperty
(
value
=
"一级分类id"
,
example
=
"1"
,
required
=
true
)
@NotNull
(
message
=
"一级分类id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotNull
(
message
=
"一级分类id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
categoryPrimaryId
;
private
Integer
categoryPrimaryId
;
@ApiModelProperty
(
value
=
"二级分类id"
,
example
=
"2"
,
required
=
true
)
@ApiModelProperty
(
value
=
"二级分类id"
,
example
=
"2"
,
required
=
true
)
@NotNull
(
message
=
"二级分类id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotNull
(
message
=
"二级分类id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
categorySubId
;
private
Integer
categorySubId
;
@ApiModelProperty
(
value
=
"商品状态"
,
example
=
"1"
,
required
=
true
)
@ApiModelProperty
(
value
=
"商品状态"
,
example
=
"1"
,
required
=
true
)
@NotNull
(
message
=
"商品状态不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotNull
(
message
=
"商品状态不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
shelfStatus
;
private
Integer
shelfStatus
;
@ApiModelProperty
(
value
=
"商品标签"
)
@ApiModelProperty
(
value
=
"商品标签"
)
private
String
goodsLabel
;
private
String
goodsLabel
;
@ApiModelProperty
(
value
=
"标签是否显示 0否 1是"
)
@ApiModelProperty
(
value
=
"标签是否显示 0否 1是"
)
private
Integer
labelShow
;
private
Integer
labelShow
;
@ApiModelProperty
(
value
=
"规格"
)
@ApiModelProperty
(
value
=
"规格"
)
@NotEmpty
(
message
=
"规格不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotEmpty
(
message
=
"规格不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
List
<
GoodsSpecVO
>
goodsSpecList
;
private
List
<
GoodsSpecVO
>
goodsSpecList
;
@ApiModelProperty
(
value
=
"商品详情 富文本"
)
@ApiModelProperty
(
value
=
"商品详情 富文本"
)
private
String
goodsDetails
;
private
String
goodsDetails
;
}
}
src/main/java/com/mmc/pms/service/mall/MallGoodsService.java
浏览文件 @
0ebe743e
...
@@ -11,4 +11,6 @@ public interface MallGoodsService {
...
@@ -11,4 +11,6 @@ public interface MallGoodsService {
ResultBody
addMallGoods
(
MallGoodsVO
mallGoodsVO
,
Integer
userAccountId
);
ResultBody
addMallGoods
(
MallGoodsVO
mallGoodsVO
,
Integer
userAccountId
);
ResultBody
<
MallGoodsVO
>
mallGoodsDetails
(
Long
id
);
ResultBody
<
MallGoodsVO
>
mallGoodsDetails
(
Long
id
);
ResultBody
editMallGoods
(
MallGoodsVO
mallGoodsVO
,
Integer
userAccountId
);
}
}
src/main/java/com/mmc/pms/service/mall/impl/MallGoodsServiceImpl.java
浏览文件 @
0ebe743e
...
@@ -50,12 +50,14 @@ public class MallGoodsServiceImpl implements MallGoodsService {
...
@@ -50,12 +50,14 @@ public class MallGoodsServiceImpl implements MallGoodsService {
// 将基础信息存储入库
// 将基础信息存储入库
mallGoodsDao
.
insertMallGoodsBaseInfo
(
mallGoodsDO
);
mallGoodsDao
.
insertMallGoodsBaseInfo
(
mallGoodsDO
);
// 将商品图片等资源存入数据库中
// 将商品图片等资源存入数据库中
List
<
MallGoodsResourcesDO
>
mallGoodsResourcesList
=
mallGoodsVO
.
getResourcesList
().
stream
().
map
(
d
->
{
insertMallGoodsResources
(
mallGoodsVO
,
id
);
MallGoodsResourcesDO
mallGoodsResourcesDO
=
new
MallGoodsResourcesDO
(
d
);
// 将商品规格存入数据库
mallGoodsResourcesDO
.
setMallGoodsId
(
id
);
insertMallGoodsSpec
(
mallGoodsVO
,
id
);
return
mallGoodsResourcesDO
;
return
ResultBody
.
success
();
}).
collect
(
Collectors
.
toList
());
}
mallGoodsDao
.
batchInsertMallGoodsResources
(
mallGoodsResourcesList
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
insertMallGoodsSpec
(
MallGoodsVO
mallGoodsVO
,
long
id
)
{
// 获取输入的规格信息
// 获取输入的规格信息
List
<
GoodsSpecVO
>
goodsSpecList
=
mallGoodsVO
.
getGoodsSpecList
();
List
<
GoodsSpecVO
>
goodsSpecList
=
mallGoodsVO
.
getGoodsSpecList
();
for
(
GoodsSpecVO
goodsSpecVO
:
goodsSpecList
)
{
for
(
GoodsSpecVO
goodsSpecVO
:
goodsSpecList
)
{
...
@@ -70,7 +72,16 @@ public class MallGoodsServiceImpl implements MallGoodsService {
...
@@ -70,7 +72,16 @@ public class MallGoodsServiceImpl implements MallGoodsService {
// 批量插入规格值的信息
// 批量插入规格值的信息
mallGoodsDao
.
batchInsertSpecValues
(
goodsSpecValuesList
);
mallGoodsDao
.
batchInsertSpecValues
(
goodsSpecValuesList
);
}
}
return
ResultBody
.
success
();
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
insertMallGoodsResources
(
MallGoodsVO
mallGoodsVO
,
long
id
)
{
List
<
MallGoodsResourcesDO
>
mallGoodsResourcesList
=
mallGoodsVO
.
getResourcesList
().
stream
().
map
(
d
->
{
MallGoodsResourcesDO
mallGoodsResourcesDO
=
new
MallGoodsResourcesDO
(
d
);
mallGoodsResourcesDO
.
setMallGoodsId
(
id
);
return
mallGoodsResourcesDO
;
}).
collect
(
Collectors
.
toList
());
mallGoodsDao
.
batchInsertMallGoodsResources
(
mallGoodsResourcesList
);
}
}
private
ResultBody
checkInformation
(
MallGoodsVO
mallGoodsVO
,
Integer
userAccountId
)
{
private
ResultBody
checkInformation
(
MallGoodsVO
mallGoodsVO
,
Integer
userAccountId
)
{
...
@@ -113,4 +124,21 @@ public class MallGoodsServiceImpl implements MallGoodsService {
...
@@ -113,4 +124,21 @@ public class MallGoodsServiceImpl implements MallGoodsService {
mallGoodsVO
.
setGoodsSpecList
(
goodsSpec
);
mallGoodsVO
.
setGoodsSpecList
(
goodsSpec
);
return
ResultBody
.
success
(
mallGoodsVO
);
return
ResultBody
.
success
(
mallGoodsVO
);
}
}
@Override
public
ResultBody
editMallGoods
(
MallGoodsVO
mallGoodsVO
,
Integer
userAccountId
)
{
ResultBody
resultError
=
checkInformation
(
mallGoodsVO
,
userAccountId
);
if
(
resultError
!=
null
)
return
resultError
;
MallGoodsDO
mallGoodsDO
=
new
MallGoodsDO
(
mallGoodsVO
);
// 修改商城商品的基本信息
mallGoodsDao
.
updateMallGoods
(
mallGoodsDO
);
// 修改商城商品的图片等资源信息,先删除后新增
mallGoodsDao
.
deleteMallGoodsResources
(
mallGoodsVO
.
getId
());
this
.
insertMallGoodsResources
(
mallGoodsVO
,
mallGoodsVO
.
getId
());
// 修改商城规格信息,先删除后新增
mallGoodsDao
.
deleteMallGoodsSpec
(
mallGoodsVO
.
getId
());
this
.
insertMallGoodsSpec
(
mallGoodsVO
,
mallGoodsVO
.
getId
());
return
ResultBody
.
success
();
}
}
}
src/main/resources/mapper/mall/MallGoodsDao.xml
浏览文件 @
0ebe743e
...
@@ -53,6 +53,28 @@
...
@@ -53,6 +53,28 @@
(#{item.mallGoodsId},#{item.url},#{item.type})
(#{item.mallGoodsId},#{item.url},#{item.type})
</foreach>
</foreach>
</insert>
</insert>
<update
id=
"updateMallGoods"
>
UPDATE mall_goods
SET trade_name = #{mallGoodsDO.tradeName},
description = #{mallGoodsDO.description},
category_primary_id = #{mallGoodsDO.categoryPrimaryId},
category_sub_id = #{mallGoodsDO.categorySubId},
shelf_status = #{mallGoodsDO.shelfStatus},
goods_label = #{mallGoodsDO.goodsLabel},
label_show = #{mallGoodsDO.labelShow},
goods_details = #{mallGoodsDO.goodsDetails}
WHERE id = #{mallGoodsDO.id}
</update>
<delete
id=
"deleteMallGoodsResources"
>
delete
from mall_goods_resources
where mall_goods_id = #{id}
</delete>
<delete
id=
"deleteMallGoodsSpec"
>
delete
from goods_spec
where mall_goods_id = #{id}
</delete>
<select
id=
"countMallGoodsByName"
resultType=
"java.lang.Integer"
>
<select
id=
"countMallGoodsByName"
resultType=
"java.lang.Integer"
>
select count(*)
select count(*)
from mall_goods
from mall_goods
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论