Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
aba49c58
Commit
aba49c58
authored
May 22, 2018
by
zhh
Browse files
商品属性添加删除数量修改
parent
8ad969b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
aba49c58
...
...
@@ -50,8 +50,11 @@ SpringSecurity登录改为Restful形式 | ✔
JWT登录、注册、获取token | ✔
JTA事务处理 | ✔
集成单元测试 | ✔
OSS上传功能 |
OSS上传功能 | ✔
优化po和dto的定义使用 |
SpringSecurity权限管理功能 |
Elasticsearch搜索功能 |
MongoDb 日志存储功能 |
### 后台功能
...
...
mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeService.java
View file @
aba49c58
...
...
@@ -2,6 +2,7 @@ package com.macro.mall.service;
import
com.macro.mall.dto.PmsProductAttributeParam
;
import
com.macro.mall.model.PmsProductAttribute
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
@@ -21,6 +22,7 @@ public interface PmsProductAttributeService {
/**
* 添加商品属性
*/
@Transactional
int
create
(
PmsProductAttributeParam
pmsProductAttributeParam
);
/**
...
...
@@ -33,5 +35,6 @@ public interface PmsProductAttributeService {
*/
PmsProductAttribute
getItem
(
Long
id
);
@Transactional
int
delete
(
List
<
Long
>
ids
);
}
mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductAttributeServiceImpl.java
View file @
aba49c58
...
...
@@ -2,8 +2,10 @@ package com.macro.mall.service.impl;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dto.PmsProductAttributeParam
;
import
com.macro.mall.mapper.PmsProductAttributeCategoryMapper
;
import
com.macro.mall.mapper.PmsProductAttributeMapper
;
import
com.macro.mall.model.PmsProductAttribute
;
import
com.macro.mall.model.PmsProductAttributeCategory
;
import
com.macro.mall.model.PmsProductAttributeExample
;
import
com.macro.mall.service.PmsProductAttributeService
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -20,6 +22,8 @@ import java.util.List;
public
class
PmsProductAttributeServiceImpl
implements
PmsProductAttributeService
{
@Autowired
private
PmsProductAttributeMapper
productAttributeMapper
;
@Autowired
private
PmsProductAttributeCategoryMapper
productAttributeCategoryMapper
;
@Override
public
List
<
PmsProductAttribute
>
getList
(
Long
cid
,
Integer
type
,
Integer
pageSize
,
Integer
pageNum
)
{
...
...
@@ -34,7 +38,16 @@ public class PmsProductAttributeServiceImpl implements PmsProductAttributeServic
public
int
create
(
PmsProductAttributeParam
pmsProductAttributeParam
)
{
PmsProductAttribute
pmsProductAttribute
=
new
PmsProductAttribute
();
BeanUtils
.
copyProperties
(
pmsProductAttributeParam
,
pmsProductAttribute
);
return
productAttributeMapper
.
insertSelective
(
pmsProductAttribute
);
int
count
=
productAttributeMapper
.
insertSelective
(
pmsProductAttribute
);
//新增商品属性以后需要更新商品属性分类数量
PmsProductAttributeCategory
pmsProductAttributeCategory
=
productAttributeCategoryMapper
.
selectByPrimaryKey
(
pmsProductAttribute
.
getProductAttributeCategoryId
());
if
(
pmsProductAttribute
.
getType
()==
0
){
pmsProductAttributeCategory
.
setAttributeCount
(
pmsProductAttributeCategory
.
getAttributeCount
()+
1
);
}
else
if
(
pmsProductAttribute
.
getType
()==
1
){
pmsProductAttributeCategory
.
setParamCount
(
pmsProductAttributeCategory
.
getParamCount
()+
1
);
}
productAttributeCategoryMapper
.
updateByPrimaryKey
(
pmsProductAttributeCategory
);
return
count
;
}
@Override
...
...
@@ -52,8 +65,28 @@ public class PmsProductAttributeServiceImpl implements PmsProductAttributeServic
@Override
public
int
delete
(
List
<
Long
>
ids
)
{
//获取分类
PmsProductAttribute
pmsProductAttribute
=
productAttributeMapper
.
selectByPrimaryKey
(
ids
.
get
(
0
));
Integer
type
=
pmsProductAttribute
.
getType
();
PmsProductAttributeCategory
pmsProductAttributeCategory
=
productAttributeCategoryMapper
.
selectByPrimaryKey
(
pmsProductAttribute
.
getProductAttributeCategoryId
());
PmsProductAttributeExample
example
=
new
PmsProductAttributeExample
();
example
.
createCriteria
().
andIdIn
(
ids
);
return
productAttributeMapper
.
deleteByExample
(
example
);
int
count
=
productAttributeMapper
.
deleteByExample
(
example
);
//删除完成后修改数量
if
(
type
==
0
){
if
(
pmsProductAttributeCategory
.
getAttributeCount
()>=
count
){
pmsProductAttributeCategory
.
setAttributeCount
(
pmsProductAttributeCategory
.
getAttributeCount
()-
count
);
}
else
{
pmsProductAttributeCategory
.
setAttributeCount
(
0
);
}
}
else
if
(
type
==
1
){
if
(
pmsProductAttributeCategory
.
getParamCount
()>=
count
){
pmsProductAttributeCategory
.
setParamCount
(
pmsProductAttributeCategory
.
getParamCount
()-
count
);
}
else
{
pmsProductAttributeCategory
.
setParamCount
(
0
);
}
}
productAttributeCategoryMapper
.
updateByPrimaryKey
(
pmsProductAttributeCategory
);
return
count
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment