|
@@ -0,0 +1,103 @@
|
|
|
+/**
|
|
|
+* @版权信息 (@copyright Copyright 2017-XXXX JDJR.COM All Right Reserved);
|
|
|
+* @see
|
|
|
+* @author 于海涛 京东金融【技术研发部-证券及营销平台研发部-营销平台研发部】
|
|
|
+* @version 1.0
|
|
|
+* @date 2018年6月26日
|
|
|
+*/
|
|
|
+
|
|
|
+package com.zskk.shop.controller.h5;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+
|
|
|
+import com.zskk.shop.controller.AbstractController;
|
|
|
+import com.zskk.shop.controller.bean.GoodBean;
|
|
|
+import com.zskk.shop.dao.entry.Banner;
|
|
|
+import com.zskk.shop.dao.entry.GoodAd;
|
|
|
+import com.zskk.shop.dao.entry.GoodBase;
|
|
|
+import com.zskk.shop.dao.entry.GoodDescribe;
|
|
|
+import com.zskk.shop.dao.entry.GoodPrice;
|
|
|
+import com.zskk.shop.dao.entry.SysLabel;
|
|
|
+import com.zskk.shop.service.BannerService;
|
|
|
+import com.zskk.shop.service.GoodService;
|
|
|
+import com.zskk.shop.service.SysLabelService;
|
|
|
+import com.zskk.shop.service.TJCenterService;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/h5")
|
|
|
+public class H5IndexController extends AbstractController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodService goodService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TJCenterService tjCenterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysLabelService sysLabelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BannerService bannerService;
|
|
|
+
|
|
|
+ @RequestMapping("/index")
|
|
|
+ public String index(Model model, @RequestParam(name="label", required=false) Integer label){
|
|
|
+ List<GoodBean> beans = this.getGoodList(label);
|
|
|
+ List<SysLabel> labels = this.queryAllSysLabel();
|
|
|
+ List<Banner> banners = bannerService.queryAllOnline();
|
|
|
+
|
|
|
+ model.addAttribute("beans", beans);
|
|
|
+ model.addAttribute("labels", labels);
|
|
|
+ model.addAttribute("banners", banners);
|
|
|
+
|
|
|
+ return "/h5/index";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/detail/{gid}")
|
|
|
+ public String detail(Model model, @PathVariable("gid") Integer gid){
|
|
|
+ GoodBase base = goodService.queryOneGoodBase(gid);
|
|
|
+ GoodPrice price = goodService.queryGoodPrice(gid);
|
|
|
+ List<GoodAd> ads = goodService.queryGoodAds(gid);
|
|
|
+ List<GoodDescribe> describes = goodService.queryGoodDescribes(gid);
|
|
|
+ List<String> tjCheckList = tjCenterService.getDJDetail(base.getPackageid());
|
|
|
+
|
|
|
+
|
|
|
+ GoodBean bean = goodService.toDetailGoodBean(base, price, ads, describes);
|
|
|
+ model.addAttribute("good", bean);
|
|
|
+ model.addAttribute("checklist", tjCheckList);
|
|
|
+ this.initUser(model);
|
|
|
+ return "/h5/detail";
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<GoodBean> getGoodList(Integer lid){
|
|
|
+ List<GoodBase> goodList = null;
|
|
|
+ if (lid == null){
|
|
|
+ goodList = goodService.queryGoodBases(null, GoodService.GOOD_ONLINE, 1, 10);
|
|
|
+ }else{
|
|
|
+ List<Integer> gids = sysLabelService.queryLabelGoods(lid).stream().map(obj -> obj.getGid()).collect(Collectors.toList());
|
|
|
+ if (gids.isEmpty()){
|
|
|
+ goodList = new ArrayList<>();
|
|
|
+ }else{
|
|
|
+ goodList = goodService.queryGoodBases(gids, GoodService.GOOD_ONLINE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<GoodBean> beans = new ArrayList<>();
|
|
|
+ for (GoodBase base: goodList){
|
|
|
+ GoodPrice price = goodService.queryGoodPrice(base.getGid());
|
|
|
+ beans.add(goodService.toSimpleGoodBean(base, price));
|
|
|
+ }
|
|
|
+ return beans;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<SysLabel> queryAllSysLabel(){
|
|
|
+ return sysLabelService.queryLabels();
|
|
|
+ }
|
|
|
+}
|