package com.caimei.www.controller.unlimited;

import com.caimei.www.controller.BaseController;
import com.caimei.www.pojo.page.SupplierDetail;
import com.caimei.www.service.page.SupplierService;
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.RequestParam;


/**
 * 供应商（supplier）
 *
 * @author : Charles
 * @date : 2020/7/15
 */
@Controller
public class SupplierController extends BaseController {

	private static final String SUPPLIER_LIST_PATH = "supplier/list";
	private static final String SUPPLIER_INDEX_PATH = "supplier/index";

    private SupplierService supplierService;
    @Autowired
    public void setSupplierService(SupplierService supplierService) {
        this.supplierService = supplierService;
    }

    /**
     * 供应商搜索结果页
     */
    @GetMapping("/supplier/list.html")
    public String search() {
        return SUPPLIER_LIST_PATH;
    }

    /**
     * 供应商首页
     */
    @GetMapping("/supplier/index.html")
    public String home(final Model model, @RequestParam("id") Integer supplierId) {
        SupplierDetail detail = supplierService.getSupplierById(supplierId);
        model.addAttribute("supplier", detail);
        return SUPPLIER_INDEX_PATH;
    }

}
