package com.jwipc.order.controller.pc;

import com.jwipc.order.dto.AppointmentDayOffBaseDTO;
import com.jwipc.order.logic.AppointmentDayOffLogic;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
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-06
 */
@Controller
@RequiredArgsConstructor
@RequestMapping(MODULE_ROOT + "/appointmentDayOff")
public class AppointmentDayOffPageController {

    private final AppointmentDayOffLogic appointmentDayOffLogic;

    @RequestMapping("/index")
    public String index() {
        return MODULE_ROOT + "/delivery/appointmentDayOff/list";
    }

    /**
     * 供预约到货法定节假日配置表列表 维护
     *
     * @param model
     * @param id
     * @param type  1新增 2编辑 3查询
     * @return
     */
    @GetMapping("/detail")
    public String detail(Model model, String id, String type) {
        AppointmentDayOffBaseDTO dayOffBaseDTO = new AppointmentDayOffBaseDTO();
        if (StringUtils.isNotEmpty(id)) {
            dayOffBaseDTO = appointmentDayOffLogic.selectById(id);
        }
        model.addAttribute("data", dayOffBaseDTO);
        model.addAttribute("viewType", type);
        return MODULE_ROOT + "/delivery/appointmentDayOff/detail";
    }

}
