package com.jwipc.tender.controller.pc;

import com.jwipc.tender.constant.ModuleConst;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import static com.jwipc.tender.constant.ModuleConst.MODULE_ROOT;

/**
 * <p>投标管理相关页面</p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Controller
@RequiredArgsConstructor
@Slf4j
@RequestMapping(ModuleConst.MODULE_ROOT + "/bid/page")
public class TenderBidPageController {

    /**
     * 投标待确认 列表页面
     *
     * @return
     */
    @GetMapping("confirmJoinList")
    public String confirmJoinList() {
        return MODULE_ROOT + "/bid/confirm_join_index";
    }

    /**
     * 投标待缴纳保证金 列表页面
     *
     * @return
     */
    @GetMapping("securityDeposit")
    public String securityDeposit() {
        return MODULE_ROOT + "/bid/security_deposit";
    }

    /**
     * 投标待报价 列表页面
     *
     * @return
     */
    @GetMapping("toBeQuotedList")
    public String toBeQuotedList() {
        return MODULE_ROOT + "/bid/to_be_quoted_list";
    }

    /**
     * 投标历史 列表页面
     *
     * @return
     */
    @GetMapping("historyList")
    public String historyList() {
        return MODULE_ROOT + "/bid/history_list";
    }

    /**
     * 供应商保证金缴纳页面
     *
     * @return
     */
    @GetMapping("uploadSecurityDeposeit")
    public String uploadSecurityDeposeit(Long bidId, Model model) {
        model.addAttribute("bidId", bidId);
        return MODULE_ROOT + "/bid/upload_security_deposeit";
    }

    /**
     * 投标单详情页面
     *
     * @param type 0:查看;1:报价;2,议价;3:历史查看
     * @return
     * @see com.jwipc.tender.constant.TenderOptType
     */
    @GetMapping("detail")
    public String detail(@RequestParam(required = false, defaultValue = "0") Long id,
                         @RequestParam(required = false, defaultValue = "0") Long tenderId,
                         Model model,
                         @RequestParam(required = false, defaultValue = "0") Integer type)
    {
        model.addAttribute("tenderId", tenderId);
        model.addAttribute("id", id);
        model.addAttribute("type", type);
        return MODULE_ROOT + "/bid/detail";
    }
}
