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
f5f4b49d
Commit
f5f4b49d
authored
Apr 28, 2018
by
zhh
Browse files
sku库存接口完善
parent
17e6a32d
Changes
6
Hide whitespace changes
Inline
Side-by-side
document/pdm/mall.pdb
View file @
f5f4b49d
<?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="152481
1036
" Name="mall" Objects="985" Symbols="123" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="152481
6533
" Name="mall" Objects="985" Symbols="123" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
...
...
@@ -8028,8 +8028,9 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>status</a:Code>
<a:CreationDate>1521710821</a:CreationDate>
<a:Creator>zhenghong</a:Creator>
<a:ModificationDate>152
1711025
</a:ModificationDate>
<a:ModificationDate>152
4816533
</a:ModificationDate>
<a:Modifier>zhenghong</a:Modifier>
<a:Comment>审核后的状态:0->未通过;2->已通过</a:Comment>
<a:DataType>int(1)</a:DataType>
<a:Length>1</a:Length>
</o:Column>
...
...
mall-admin/src/main/java/com/macro/mall/controller/PmsSkuStockController.java
View file @
f5f4b49d
...
...
@@ -7,10 +7,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -18,17 +15,29 @@ import java.util.List;
* sku库存Controller
* Created by macro on 2018/4/27.
*/
@Api
(
"sku商品库存管理"
)
@Controller
@Api
(
tags
=
"PmsSkuStockController"
,
description
=
"sku商品库存管理"
)
@RequestMapping
(
"/sku"
)
public
class
PmsSkuStockController
{
@Autowired
private
PmsSkuStockService
skuStockService
;
@ApiOperation
(
"根据商品编号及编号模糊搜索sku库存"
)
@RequestMapping
(
"/{id}"
)
@RequestMapping
(
value
=
"/{
p
id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getList
(
@PathVariable
Long
id
,
@RequestParam
(
"keyword"
)
String
keyword
){
List
<
PmsSkuStock
>
skuStockList
=
skuStockService
.
getList
(
id
,
keyword
);
public
Object
getList
(
@PathVariable
Long
p
id
,
@RequestParam
(
value
=
"keyword"
,
required
=
false
)
String
keyword
)
{
List
<
PmsSkuStock
>
skuStockList
=
skuStockService
.
getList
(
p
id
,
keyword
);
return
new
CommonResult
().
success
(
skuStockList
);
}
@ApiOperation
(
"批量更新库存信息"
)
@RequestMapping
(
value
=
"/update/{pid}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
update
(
@PathVariable
Long
pid
,
@RequestBody
List
<
PmsSkuStock
>
skuStockList
){
int
count
=
skuStockService
.
update
(
pid
,
skuStockList
);
if
(
count
>
0
){
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
}
mall-admin/src/main/java/com/macro/mall/dao/PmsSkuStockDao.java
View file @
f5f4b49d
...
...
@@ -10,5 +10,13 @@ import java.util.List;
* Created by macro on 2018/4/26.
*/
public
interface
PmsSkuStockDao
{
/**
* 批量插入操作
*/
int
insertList
(
@Param
(
"list"
)
List
<
PmsSkuStock
>
skuStockList
);
/**
* 批量插入或替换操作
*/
int
replaceList
(
@Param
(
"list"
)
List
<
PmsSkuStock
>
skuStockList
);
}
mall-admin/src/main/java/com/macro/mall/service/PmsSkuStockService.java
View file @
f5f4b49d
...
...
@@ -13,4 +13,9 @@ public interface PmsSkuStockService {
* 根据产品id和skuCode模糊搜索
*/
List
<
PmsSkuStock
>
getList
(
Long
pid
,
String
keyword
);
/**
* 批量更新商品库存信息
*/
int
update
(
Long
pid
,
List
<
PmsSkuStock
>
skuStockList
);
}
mall-admin/src/main/java/com/macro/mall/service/impl/PmsSkuStockServiceImpl.java
View file @
f5f4b49d
package
com.macro.mall.service.impl
;
import
com.macro.mall.dao.PmsSkuStockDao
;
import
com.macro.mall.mapper.PmsSkuStockMapper
;
import
com.macro.mall.model.PmsSkuStock
;
import
com.macro.mall.model.PmsSkuStockExample
;
import
com.macro.mall.service.PmsSkuStockService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
...
...
@@ -17,11 +19,21 @@ import java.util.List;
public
class
PmsSkuStockServiceImpl
implements
PmsSkuStockService
{
@Autowired
private
PmsSkuStockMapper
skuStockMapper
;
@Autowired
private
PmsSkuStockDao
skuStockDao
;
@Override
public
List
<
PmsSkuStock
>
getList
(
Long
pid
,
String
keyword
)
{
PmsSkuStockExample
example
=
new
PmsSkuStockExample
();
example
.
createCriteria
().
andProductIdEqualTo
(
pid
).
andSkuCodeLike
(
"%"
+
keyword
+
"%"
)
PmsSkuStockExample
.
Criteria
criteria
=
example
.
createCriteria
().
andProductIdEqualTo
(
pid
);
if
(!
StringUtils
.
isEmpty
(
keyword
))
{
criteria
.
andSkuCodeLike
(
"%"
+
keyword
+
"%"
);
}
return
skuStockMapper
.
selectByExample
(
example
);
}
@Override
public
int
update
(
Long
pid
,
List
<
PmsSkuStock
>
skuStockList
)
{
return
skuStockDao
.
replaceList
(
skuStockList
);
}
}
mall-admin/src/main/resources/dao/PmsSkuStockDao.xml
View file @
f5f4b49d
...
...
@@ -16,4 +16,20 @@
#{item.sale,jdbcType=INTEGER})
</foreach>
</insert>
<insert
id=
"replaceList"
>
REPLACE INTO pms_sku_stock (id,product_id, sku_code, price, stock, low_stock, sp1, sp2, sp3, pic, sale) VALUES
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.id,jdbcType=BIGINT},
#{item.productId,jdbcType=BIGINT},
#{item.skuCode,jdbcType=VARCHAR},
#{item.price,jdbcType=DECIMAL},
#{item.stock,jdbcType=INTEGER},
#{item.lowStock,jdbcType=INTEGER},
#{item.sp1,jdbcType=VARCHAR},
#{item.sp2,jdbcType=VARCHAR},
#{item.sp3,jdbcType=VARCHAR},
#{item.pic,jdbcType=VARCHAR},
#{item.sale,jdbcType=INTEGER})
</foreach>
</insert>
</mapper>
\ No newline at end of file
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