package com.caimei.www.controller.unlimited;

import com.caimei.www.controller.BaseController;
import com.caimei.www.pojo.page.ImageLink;
import com.caimei.www.pojo.JsonModel;
import com.caimei.www.pojo.page.PageFloor;
import com.caimei.www.pojo.page.ProductList;
import com.caimei.www.service.page.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Description
 *
 * @author : Charles
 * @date : 2020/6/15
 */
@Controller
public class HomeController extends BaseController {

	private static final String HOME_PATH = "index";

    private HomeService homeService;
    @Autowired
    public void setHomeService(HomeService homeService) {
        this.homeService = homeService;
    }

    /**
     * 首页页面路径
     * @param model
     * @return
     */
    @GetMapping("/index.html")
    public String home(final Model model) {
        model.addAttribute("msg", "首页");
        /*List<PageFloor> pageFloors = homeService.getHomePageFloor();*/
       /* model.addAttribute("pageFloors", pageFloors);*/
        return HOME_PATH;
    }

    /**
     * 首页轮播图列表
     * @return
     */
    @GetMapping("/home/banner")
    @ResponseBody
    public JsonModel<List<ImageLink>> getHomeBanners() {
        return homeService.getHomeBanners();
    }

    /**
     * 首页推荐专区
     * @return
     */
    @GetMapping("/home/recommend")
    @ResponseBody
    public JsonModel<List<ProductList>> getRecommendProducts() {
        return homeService.getRecommendProducts();
    }

    /**
     * 首页楼层专题数据
     * @return
     */
    @GetMapping("/home/floor")
    @ResponseBody
    public JsonModel<List<PageFloor>> getHomePageFloorData() {
        return homeService.getHomePageFloorData();
    }

    /**
     * 首页楼层专题数据
     * @return
     */
    /*@GetMapping("/home/topic")
    @ResponseBody
    public JsonModel<Map<String, Object>> getHomeTopicData() {
        return homeService.getHomeTopicData();
    }*/

    /**
     * 首页左侧广告图
     * @return
     */
    @GetMapping("/home/advertising")
    @ResponseBody
    public JsonModel<List<ImageLink>> getAdvertising() {
        return homeService.getAdvertising();
    }

}
