|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
package com.bweb.controller.goods; |
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
@ -7,7 +9,8 @@ import com.hfkj.common.security.SessionObject; |
|
|
|
|
import com.hfkj.common.security.UserCenter; |
|
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hfkj.entity.*; |
|
|
|
|
import com.hfkj.model.GoodsModel; |
|
|
|
|
import com.hfkj.model.goods.GoodsModel; |
|
|
|
|
import com.hfkj.model.goods.GoodsModelSpecs; |
|
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
|
import com.hfkj.model.SecUserSessionObject; |
|
|
|
|
import com.hfkj.service.goods.*; |
|
|
|
@ -23,7 +26,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping(value="/goods") |
|
|
|
@ -106,7 +109,7 @@ public class GoodsController { |
|
|
|
|
@RequestMapping(value="/editGoodsSpecs",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "编辑商品规格") |
|
|
|
|
public ResponseData editGoodsSpecs(@RequestBody GoodsModel body, HttpServletRequest request) { |
|
|
|
|
public ResponseData editGoodsSpecs(@RequestBody GoodsModelSpecs body, HttpServletRequest request) { |
|
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
|
|
|
@ -150,7 +153,6 @@ public class GoodsController { |
|
|
|
|
goodsSpecs.setCreateTime(new Date()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goodsSpecs.setUpdateTime(new Date()); |
|
|
|
|
goodsSpecs.setGoodsId(body.getGoodsId()); |
|
|
|
|
goodsSpecs.setOriginalPrice(body.getOriginalPrice()); |
|
|
|
@ -209,5 +211,70 @@ public class GoodsController { |
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/getListGoods",method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询列表") |
|
|
|
|
public ResponseData getListGoods(@RequestParam(value = "title" , required = false) String title, |
|
|
|
|
@RequestParam(value = "goodsType" , required = false) Long goodsType, |
|
|
|
|
@RequestParam(value = "goodsBrand" , required = false) Long goodsBrand, |
|
|
|
|
@RequestParam(value = "type" , required = false) Integer type, |
|
|
|
|
@RequestParam(value = "status" , required = false) Integer status, |
|
|
|
|
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
|
|
|
|
@RequestParam(value = "pageSize" , required = true) Integer pageSize) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
map.put("title", title); |
|
|
|
|
map.put("goodsType", goodsType); |
|
|
|
|
map.put("goodsBrand", goodsBrand); |
|
|
|
|
map.put("type", type); |
|
|
|
|
map.put("status", status); |
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(goodsMsgService.getList(map))); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/getGoodsDetail",method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询商品详情") |
|
|
|
|
public ResponseData getGoodsDetail(@RequestParam(value = "id" , required = false) Long id) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GoodsModel goodsModel = new GoodsModel(); |
|
|
|
|
GoodsMsg goodsMsg = goodsMsgService.queryDetail(id); |
|
|
|
|
BeanUtils.copyProperties(goodsMsg, goodsModel); |
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
map.put("goodsId" , id); |
|
|
|
|
|
|
|
|
|
List<GoodsSpecs> goodsSpecs = goodsSpecsService.getList(map); |
|
|
|
|
|
|
|
|
|
List<GoodsModelSpecs> goodsModelSpecs = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (GoodsSpecs goodsSpec : goodsSpecs) { |
|
|
|
|
GoodsModelSpecs goodsModelSpec = new GoodsModelSpecs(); |
|
|
|
|
BeanUtils.copyProperties(goodsSpec, goodsModelSpec); |
|
|
|
|
GoodsVpd goodsVpd = goodsVpdService.queryDetailBySpecsId(goodsSpec.getId()); |
|
|
|
|
if (goodsVpd != null) { |
|
|
|
|
BeanUtils.copyProperties(goodsVpd, goodsModelSpec); |
|
|
|
|
} |
|
|
|
|
goodsModelSpecs.add(goodsModelSpec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(goodsModelSpecs); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|