sku库存接口完善
This commit is contained in:
parent
17e6a32d02
commit
f5f4b49de6
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="1524811036" 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="1524816533" 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>1521711025</a:ModificationDate>
|
||||
<a:ModificationDate>1524816533</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>
|
||||
|
@ -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 = "/{pid}", 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 pid, @RequestParam(value = "keyword",required = false) String keyword) {
|
||||
List<PmsSkuStock> skuStockList = skuStockService.getList(pid, 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -13,4 +13,9 @@ public interface PmsSkuStockService {
|
||||
* 根据产品id和skuCode模糊搜索
|
||||
*/
|
||||
List<PmsSkuStock> getList(Long pid, String keyword);
|
||||
|
||||
/**
|
||||
* 批量更新商品库存信息
|
||||
*/
|
||||
int update(Long pid, List<PmsSkuStock> skuStockList);
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
Loading…
x
Reference in New Issue
Block a user