package com.jwipc.order.controller.pc;

import com.alibaba.fastjson2.JSON;
import com.jwipc.order.dto.AppointmentDayOffBaseDTO;
import com.jwipc.order.logic.AppointmentDayOffLogic;
import com.jwipc.order.model.query.AppointmentDayOffQuery;
import com.jwipc.order.model.query.AppointmentDockerQuery;
import com.jwipc.page.PageView;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * <p>
 * 预约到货法定节假日配置表
 * </p>
 *
 * @author wt
 * @version 1.0
 * @since 2024/3/6
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(MODULE_ROOT + "/appointmentDayOff/rest")
public class AppointmentDayOffRestController {
    private final AppointmentDayOffLogic appointmentDayOffLogic;

    @RequestMapping("/list")
    public PageView list(AppointmentDayOffQuery query){
        PageView pageView = appointmentDayOffLogic.selectListByPage(query);
        return pageView;
    }

    /**
     * 保存数据
     */
    @PostMapping("/save")
    public ResponseEntity<String> save(String data) {
        appointmentDayOffLogic.createOrUpdate(JSON.parseObject(data, AppointmentDayOffBaseDTO.class));
        return ResponseEntity.ok(StringUtils.EMPTY);
    }
    /**
     * 删除
     *
     * @param id
     * @return
     */
    @PostMapping("/del")
    public ResponseEntity<String> del(Long id) {
        appointmentDayOffLogic.deleteById(id);
        return ResponseEntity.ok(StringUtils.EMPTY);
    }


}
