package com.jwipc.order.controller.pc;

import com.jwipc.order.dto.AppointmentTimeDTO;
import com.jwipc.order.logic.AppointmentTimeLogic;
import lombok.RequiredArgsConstructor;
import org.springframework.ui.Model;
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-05
 */
@Controller
@RequiredArgsConstructor
@RequestMapping(MODULE_ROOT + "/appointmentTime")
public class AppointmentTimePageController {

    private final AppointmentTimeLogic appointmentTimeLogic;
    /**
     * 预约时间范围数据配置 主页
     * @return
     */
    @RequestMapping("/index")
    public String index(){
        return MODULE_ROOT + "/delivery/appointmentTime/list";
    }

    /**
     * 预约时间范围数据配置 明细
     * @param model model
     * @param type 1.新增 2.编辑 3.查看
     * @param id id
     * @return
     */
    @RequestMapping("/detail")
    public String detail(Model model,Integer type,Long id){
        AppointmentTimeDTO dto = new AppointmentTimeDTO();
        if(id != null){
            dto = appointmentTimeLogic.getById(id);
        }
        model.addAttribute("data",dto);
        model.addAttribute("viewType",type);
        return MODULE_ROOT + "/delivery/appointmentTime/detail";
    }
}
