package com.jwipc.order.controller.pc;

import com.jwipc.order.logic.AppointmentSupplierLogic;
import com.jwipc.order.dto.AppointmentSupplierDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;

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

/**
 * <p>
 * 送货单预约供应商配置 前端控制器
 * </p>
 *
 * @author WT
 * @since 2024-03-04
 */
@Controller
@RequiredArgsConstructor
@RequestMapping(MODULE_ROOT + "/appointmentSupplier")
public class AppointmentSupplierPageController {

    private final AppointmentSupplierLogic appointmentSupplierLogic;

    /**
     * 供应商&启用时间配置表页面
     *
     * @return
     */
    @GetMapping("/index")
    public String index() {
        return MODULE_ROOT + "/delivery/appointmentSupplier/list";
    }

    @GetMapping("/detail")
    public String detail(Long id, Model model) {
        AppointmentSupplierDTO appointmentSupplierDto;
        if (id != null) {
            appointmentSupplierDto = appointmentSupplierLogic.getById(id);
        } else {
            appointmentSupplierDto = new AppointmentSupplierDTO();
        }
        model.addAttribute("data", appointmentSupplierDto);
        return MODULE_ROOT + "/delivery/appointmentSupplier/detail";
    }

}
