diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 0d1d9dd2806f11fe562d3d2016527008b1b98740..0708d4c8c376ac8cbf73461c3e49358dcbbd5fc4 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,6 +7,7 @@ + @@ -17,6 +18,7 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml index b94feb7b48d049b0323a603bdca32ba06adee4ce..c8565b5c7c3ee338a38c23ffad561052705106a8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -15,6 +15,7 @@ diff --git a/bhs/bhs-system/src/main/java/com/bhs/controller/ProductController.java b/bhs/bhs-system/src/main/java/com/bhs/controller/ProductController.java index c829ea69b37cea156ee9c69a00a1949d4df1911f..aedd1cd3ac073fc8b9ea93b5a003b8a4d4e06623 100644 --- a/bhs/bhs-system/src/main/java/com/bhs/controller/ProductController.java +++ b/bhs/bhs-system/src/main/java/com/bhs/controller/ProductController.java @@ -1,6 +1,7 @@ package com.bhs.controller; import com.bhs.pojo.Item; +import com.bhs.pojo.MainMenu; import com.bhs.service.Product.ProductService; import com.bhs.vo.ResponseData; import org.springframework.beans.factory.annotation.Autowired; @@ -14,9 +15,46 @@ import java.util.List; public class ProductController { @Autowired private ProductService productService; + //商品详情 @PostMapping("/getDetails/{id}") public ResponseData getDetails(@PathVariable("id") Integer id){ Item productDetails=productService.getDetails(id); return ResponseData.success(productDetails); } + //商品列表 + @PostMapping("/getGoodsList") + public ResponseData getGoodsList(){ + List goodsList=productService.getGoodsList(); + return ResponseData.success(goodsList); + } + @PostMapping("/getGoodsList1") + public ResponseData getGoodsList1(){ + List items1=productService.getGoodsList1(); + return ResponseData.success(items1); + } + @PostMapping("/getGoodsList2") + public ResponseData getGoodsList2(){ + List items2=productService.getGoodsList2(); + return ResponseData.success(items2); + } + @PostMapping("/getGoodsList3") + public ResponseData getGoodsList3(){ + List items3=productService.getGoodsList3(); + return ResponseData.success(items3); + } + @PostMapping("/getGoodsList4") + public ResponseData getGoodsList4(){ + List items4=productService.getGoodsList4(); + return ResponseData.success(items4); + } + @PostMapping("/getGoodsList5") + public ResponseData getGoodsList5(){ + List items5=productService.getGoodsList5(); + return ResponseData.success(items5); + } + @PostMapping("/getGoodsList6") + public ResponseData getGoodsList6(){ + List items6=productService.getGoodsList6(); + return ResponseData.success(items6); + } } diff --git a/bhs/bhs-system/src/main/java/com/bhs/mappers/Product/ProductMapper.java b/bhs/bhs-system/src/main/java/com/bhs/mappers/Product/ProductMapper.java index a529856305d6df70a7e5285a7b476234299d4f07..bb4ed0cd4344ef4e97f85394c6ad646616ad4164 100644 --- a/bhs/bhs-system/src/main/java/com/bhs/mappers/Product/ProductMapper.java +++ b/bhs/bhs-system/src/main/java/com/bhs/mappers/Product/ProductMapper.java @@ -10,4 +10,28 @@ public interface ProductMapper { "FROM item " + "WHERE id=#{id}") Item getDetails(Integer id); + @Select("SELECT id,menu_id,name,price,img_path,created,updated,status,top_menu_id,repertory,advantage " + + "FROM item " + + "WHERE main_menu_id=1") + List getGoodsList1(); + @Select("SELECT id,menu_id,name,price,img_path,created,updated,status,top_menu_id,repertory,advantage " + + "FROM item " + + "WHERE main_menu_id=2") + List getGoodsList2(); + @Select("SELECT id,menu_id,name,price,img_path,created,updated,status,top_menu_id,repertory,advantage " + + "FROM item " + + "WHERE main_menu_id=3") + List getGoodsList3(); + @Select("SELECT id,menu_id,name,price,img_path,created,updated,status,top_menu_id,repertory,advantage " + + "FROM item " + + "WHERE main_menu_id=4") + List getGoodsList4(); + @Select("SELECT id,menu_id,name,price,img_path,created,updated,status,top_menu_id,repertory,advantage " + + "FROM item " + + "WHERE main_menu_id=5") + List getGoodsList5(); + @Select("SELECT id,menu_id,name,price,img_path,created,updated,status,top_menu_id,repertory,advantage " + + "FROM item " + + "WHERE main_menu_id in (6,7)") + List getGoodsList6(); } diff --git a/bhs/bhs-system/src/main/java/com/bhs/pojo/ShoppingCart.java b/bhs/bhs-system/src/main/java/com/bhs/pojo/ShoppingCart.java new file mode 100644 index 0000000000000000000000000000000000000000..eddd883fa1d94cdbe7787207e8f820273010e57e --- /dev/null +++ b/bhs/bhs-system/src/main/java/com/bhs/pojo/ShoppingCart.java @@ -0,0 +1,14 @@ +package com.bhs.pojo; + +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class ShoppingCart extends basePojo{ + private static final long serialVersionUID = 7291723109947907696L; + private Integer id; + private Integer userId; + private Integer itemId; + private Integer quantity; +} diff --git a/bhs/bhs-system/src/main/java/com/bhs/service/Product/ProductService.java b/bhs/bhs-system/src/main/java/com/bhs/service/Product/ProductService.java index 988186539a30299df6900dd3fcb3d28d73bae95c..da3b783530c631c4f061fd9fe81441d00bf9f08c 100644 --- a/bhs/bhs-system/src/main/java/com/bhs/service/Product/ProductService.java +++ b/bhs/bhs-system/src/main/java/com/bhs/service/Product/ProductService.java @@ -1,11 +1,21 @@ package com.bhs.service.Product; import com.bhs.pojo.Item; +import com.bhs.pojo.MainMenu; import java.util.List; public interface ProductService { - +//商品详情页 Item getDetails(Integer productID); +//商品列表页 + List getGoodsList(); + List getGoodsList1(); + List getGoodsList2(); + List getGoodsList3(); + List getGoodsList4(); + List getGoodsList5(); + List getGoodsList6(); + } diff --git a/bhs/bhs-system/src/main/java/com/bhs/service/Product/impl/ProductServiceImpl.java b/bhs/bhs-system/src/main/java/com/bhs/service/Product/impl/ProductServiceImpl.java index 5881bd2a7a71dfc666536372fc19cd18a30baad2..57ef46078a1807c345fabc108fb46e14e8f750dd 100644 --- a/bhs/bhs-system/src/main/java/com/bhs/service/Product/impl/ProductServiceImpl.java +++ b/bhs/bhs-system/src/main/java/com/bhs/service/Product/impl/ProductServiceImpl.java @@ -1,15 +1,23 @@ package com.bhs.service.Product.impl; import com.bhs.mappers.Product.ProductMapper; +import com.bhs.mappers.menu.LeftMenuMapper; import com.bhs.pojo.Item; +import com.bhs.pojo.MainMenu; import com.bhs.service.Product.ProductService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.sound.midi.Soundbank; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class ProductServiceImpl implements ProductService { + @Autowired + private LeftMenuMapper leftMenuMapper; @Autowired private ProductMapper productMapper; @@ -18,5 +26,82 @@ public class ProductServiceImpl implements ProductService { return productMapper.getDetails(id); } + @Override + public List getGoodsList() { + //获取MainMenu表数据并用List保存,这个里面没children + List mainMenus=leftMenuMapper.getMainMenu(); + //这个是新建的传回前端的,有children + List mainMenuLists=new ArrayList<>(); + //Item表k是表中mainMenuId,v是表数据 + Map> maps=getGoodsMap(); + System.out.println(); + //把MainMenu表中的数据便利出来,这个里面的children没有 + for (MainMenu items:mainMenus){ + //获取MainMenu表id + Integer mainMenuId=items.getId(); + //根据mainMenuId获取Item表并存入List中 + List items1=maps.get(mainMenuId); + //如果为空则说明mainMenuId对应的类型没有则直接结束 + if(items1==null){ + continue; + } + //把上面获取的Item数据写入MainMenu的children里 + items.setChildren(items1); + mainMenuLists.add(items); + } + return mainMenuLists; + } + + @Override + public List getGoodsList1() { + return productMapper.getGoodsList1(); + } + + @Override + public List getGoodsList2() { + return productMapper.getGoodsList2(); + } + + @Override + public List getGoodsList3() { + return productMapper.getGoodsList3(); + } + + @Override + public List getGoodsList4() { + return productMapper.getGoodsList4(); + } + + @Override + public List getGoodsList5() { + return productMapper.getGoodsList5(); + } + + @Override + public List getGoodsList6() { + return productMapper.getGoodsList6(); + } + + public Map> getGoodsMap(){ + HashMap> maps = new HashMap<>(); + //获取Item表 + List itemList = leftMenuMapper.getMainItem(); + //把Item表遍历出来 + for (Item item : itemList){ + //获取item表的mainMenuId + Integer key = item.getMainMenuId(); + //把Item表和Item表中的mainMenuId作为一对传入maps中 + if (maps.containsKey(key)){ + //如果K存在,则只改变V,增加到list中 + List list = maps.get(key); + list.add(item); + continue; + } + List list = new ArrayList<>(); + list.add(item); + maps.put(key, list); + } + return maps; + } } diff --git a/bhs/bhs-system/target/classes/com/bhs/controller/ProductController.class b/bhs/bhs-system/target/classes/com/bhs/controller/ProductController.class index 1a19dc95cc3c9d85e0917ba0e96eab86ac296bd5..0ba7f037199918dc86e7151ee07cae4674aefc7e 100644 Binary files a/bhs/bhs-system/target/classes/com/bhs/controller/ProductController.class and b/bhs/bhs-system/target/classes/com/bhs/controller/ProductController.class differ diff --git a/bhs/bhs-system/target/classes/com/bhs/mappers/Product/ProductMapper.class b/bhs/bhs-system/target/classes/com/bhs/mappers/Product/ProductMapper.class index fd766d23e509a7fb29e86ed05eadee94544fda61..850b6107b52c571a9268364713dd415e393f6687 100644 Binary files a/bhs/bhs-system/target/classes/com/bhs/mappers/Product/ProductMapper.class and b/bhs/bhs-system/target/classes/com/bhs/mappers/Product/ProductMapper.class differ diff --git a/bhs/bhs-system/target/classes/com/bhs/service/Product/ProductService.class b/bhs/bhs-system/target/classes/com/bhs/service/Product/ProductService.class index 9a423ef2a423e3e33bb09c3d54cf91cae2982afc..61394c9123683d02e4cf3170a0c22c71a99aefdc 100644 Binary files a/bhs/bhs-system/target/classes/com/bhs/service/Product/ProductService.class and b/bhs/bhs-system/target/classes/com/bhs/service/Product/ProductService.class differ diff --git a/bhs/bhs-system/target/classes/com/bhs/service/Product/impl/ProductServiceImpl.class b/bhs/bhs-system/target/classes/com/bhs/service/Product/impl/ProductServiceImpl.class index 1d30099cb1276fb4eb1e68ef98f53185b7e26249..50267fdd19c7422d3c419592e5fe9d99d0b6c27f 100644 Binary files a/bhs/bhs-system/target/classes/com/bhs/service/Product/impl/ProductServiceImpl.class and b/bhs/bhs-system/target/classes/com/bhs/service/Product/impl/ProductServiceImpl.class differ diff --git a/bhs/bhs.iml b/bhs/bhs.iml index c432f6ee9084517aa6c5efd43c36176bae0b45cb..7c3ac58227952b322c0a035eb154c03d40c06368 100644 --- a/bhs/bhs.iml +++ b/bhs/bhs.iml @@ -4,6 +4,7 @@ + diff --git a/bhs/pom.xml b/bhs/pom.xml index 537d6cb6216e37a212c44f58c0001fa1174e4bd6..ab9cbae72e6d70cd38997391c19fbe7d7ad86fbd 100644 --- a/bhs/pom.xml +++ b/bhs/pom.xml @@ -12,6 +12,7 @@ bhs-system bhs-user bhs-gatway + bhs-cart diff --git a/vue-store/src/components/Phone.vue b/vue-store/src/components/Phone.vue index a2a1f5c2715c11f07a7ce26315ffd4f6c04a9040..a59c65a4057e24e3d1e51231a44eab7c3d97c465 100644 --- a/vue-store/src/components/Phone.vue +++ b/vue-store/src/components/Phone.vue @@ -38,41 +38,40 @@ export default { \ No newline at end of file diff --git a/vue-store/src/views/ShoppingCart.vue b/vue-store/src/views/ShoppingCart.vue index 7765a22316d4b37f0aa84774fc34ca7ada5cc11d..1404df303e61d191ffa47ca22394364df5179a6e 100644 --- a/vue-store/src/views/ShoppingCart.vue +++ b/vue-store/src/views/ShoppingCart.vue @@ -1,11 +1,4 @@ - - +