diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsBrandController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsBrandController.java index e7bc4de..7f614e9 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsBrandController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsBrandController.java @@ -102,6 +102,20 @@ public class GoodsBrandController { } } + @RequestMapping(value="/getListBrandAll",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询列表") + public ResponseData getListBrandAll() { + try { + + return ResponseMsgUtil.success(goodsBrandService.getList(new HashMap<>())); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/delete",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除") diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java index a11b52e..790ef99 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java @@ -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 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 map = new HashMap<>(); + map.put("goodsId" , id); + + List goodsSpecs = goodsSpecsService.getList(map); + + List 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); + } + } + } diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsTypeController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsTypeController.java index a5b43f9..454b91e 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsTypeController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsTypeController.java @@ -1,6 +1,5 @@ package com.bweb.controller.goods; -import com.bweb.controller.FileUploadController; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -8,8 +7,7 @@ import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.GoodsType; -import com.hfkj.entity.SecMenu; -import com.hfkj.model.GoodsTypeModel; +import com.hfkj.model.goods.GoodsTypeModel; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.goods.GoodsTypeService; @@ -24,7 +22,6 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.*; -import java.util.stream.Collectors; @Controller @RequestMapping(value="/goodsType") diff --git a/service/src/main/java/com/hfkj/model/goods/GoodsModel.java b/service/src/main/java/com/hfkj/model/goods/GoodsModel.java new file mode 100644 index 0000000..64f5bfc --- /dev/null +++ b/service/src/main/java/com/hfkj/model/goods/GoodsModel.java @@ -0,0 +1,13 @@ +package com.hfkj.model.goods; + +import com.hfkj.entity.GoodsMsg; +import com.hfkj.entity.GoodsSpecs; +import lombok.Data; + +import java.util.List; + +@Data +public class GoodsModel extends GoodsMsg { + + List goodsModelSpecs; +} diff --git a/service/src/main/java/com/hfkj/model/GoodsModel.java b/service/src/main/java/com/hfkj/model/goods/GoodsModelSpecs.java similarity index 89% rename from service/src/main/java/com/hfkj/model/GoodsModel.java rename to service/src/main/java/com/hfkj/model/goods/GoodsModelSpecs.java index 439667f..5c0cef0 100644 --- a/service/src/main/java/com/hfkj/model/GoodsModel.java +++ b/service/src/main/java/com/hfkj/model/goods/GoodsModelSpecs.java @@ -1,14 +1,13 @@ -package com.hfkj.model; +package com.hfkj.model.goods; import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsSpecs; -import com.hfkj.entity.GoodsVpd; import lombok.Data; import java.util.Date; @Data -public class GoodsModel extends GoodsSpecs { +public class GoodsModelSpecs extends GoodsSpecs { GoodsMsg goodsMsg; diff --git a/service/src/main/java/com/hfkj/model/GoodsTypeModel.java b/service/src/main/java/com/hfkj/model/goods/GoodsTypeModel.java similarity index 86% rename from service/src/main/java/com/hfkj/model/GoodsTypeModel.java rename to service/src/main/java/com/hfkj/model/goods/GoodsTypeModel.java index ed84c61..6ff48ba 100644 --- a/service/src/main/java/com/hfkj/model/GoodsTypeModel.java +++ b/service/src/main/java/com/hfkj/model/goods/GoodsTypeModel.java @@ -1,4 +1,4 @@ -package com.hfkj.model; +package com.hfkj.model.goods; import com.hfkj.entity.GoodsType; import lombok.Data; diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java b/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java index f7b8e20..5a80a62 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java @@ -1,7 +1,7 @@ package com.hfkj.service.goods; import com.hfkj.entity.GoodsType; -import com.hfkj.model.GoodsTypeModel; +import com.hfkj.model.goods.GoodsTypeModel; import java.util.List; import java.util.Map; diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java index 0c444d9..a48a910 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java @@ -7,6 +7,7 @@ import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsType; import com.hfkj.service.goods.GoodsBrandService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -58,8 +59,8 @@ public class GoodsBrandServiceImpl implements GoodsBrandService { GoodsBrandExample example = new GoodsBrandExample(); GoodsBrandExample.Criteria criteria = example.createCriteria(); - if (MapUtils.getString(map, "title") != null) { - criteria.andTitleEqualTo(MapUtils.getString(map, "title")); + if (StringUtils.isNotBlank(MapUtils.getString(map, "title"))) { + criteria.andTitleLike("%"+MapUtils.getString(map, "title")+"%"); } criteria.andStatusNotEqualTo(0); diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java index 827065b..4eb49db 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java @@ -3,7 +3,10 @@ package com.hfkj.service.goods.impl; import com.hfkj.dao.GoodsMsgMapper; import com.hfkj.entity.GoodsBrand; import com.hfkj.entity.GoodsMsg; +import com.hfkj.entity.GoodsMsgExample; import com.hfkj.service.goods.GoodsMsgService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -52,6 +55,28 @@ public class GoodsMsgServiceImpl implements GoodsMsgService { @Override public List getList(Map map) { - return Collections.emptyList(); + GoodsMsgExample example = new GoodsMsgExample(); + GoodsMsgExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "goodsType") != null) { + criteria.andGoodsTypeEqualTo(MapUtils.getLong(map, "goodsType")); + } + if (MapUtils.getInteger(map, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); + } + if (MapUtils.getLong(map, "goodsBrand") != null) { + criteria.andGoodsBrandEqualTo(MapUtils.getLong(map, "goodsBrand")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "title"))) { + criteria.andTitleLike("%"+MapUtils.getString(map, "title")+"%"); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } else { + criteria.andStatusNotEqualTo(0); + } + + + return goodsMsgMapper.selectByExample(example); } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java index 40d8080..439bb31 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java @@ -6,6 +6,7 @@ import com.hfkj.entity.GoodsSpecs; import com.hfkj.entity.GoodsSpecsExample; import com.hfkj.service.goods.GoodsSpecsService; import com.hfkj.service.goods.GoodsVpdService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -75,6 +76,16 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService { @Override public List getList(Map map) { - return Collections.emptyList(); + + GoodsSpecsExample goodsSpecsExample = new GoodsSpecsExample(); + GoodsSpecsExample.Criteria criteria = goodsSpecsExample.createCriteria(); + + if (MapUtils.getLong(map, "goodsId") != null) { + criteria.andGoodsIdEqualTo(MapUtils.getLong(map, "goodsId")); + } + criteria.andStatusNotEqualTo(0); + + + return goodsSpecsMapper.selectByExample(goodsSpecsExample); } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java index f331b65..28def1c 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java @@ -3,11 +3,10 @@ package com.hfkj.service.goods.impl; import com.hfkj.dao.GoodsTypeMapper; import com.hfkj.entity.GoodsType; import com.hfkj.entity.GoodsTypeExample; -import com.hfkj.entity.SecMenu; -import com.hfkj.model.GoodsTypeModel; -import com.hfkj.model.MenuTreeModel; +import com.hfkj.model.goods.GoodsTypeModel; import com.hfkj.service.goods.GoodsTypeService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -84,8 +83,8 @@ public class GoodsTypeServiceImpl implements GoodsTypeService { if (MapUtils.getLong(map, "parentId") != null) { criteria.andParentIdEqualTo(MapUtils.getLong(map, "parentId")); } - if (MapUtils.getString(map, "title") != null) { - criteria.andTitleEqualTo(MapUtils.getString(map, "title")); + if (StringUtils.isNotBlank(MapUtils.getString(map, "title"))) { + criteria.andTitleLike("%"+MapUtils.getString(map, "title")+"%"); } if (MapUtils.getInteger(map, "businessType") != null) { criteria.andBusinessTypeEqualTo(MapUtils.getInteger(map, "businessType"));