/*
 * Copyright ©2023 CJB-CNIT Team. All rights reserved
 */
package com.openhis.web.doctorstation.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.*;

import com.core.common.core.domain.R;
import com.openhis.web.doctorstation.appservice.IReservationRecordAppService;
import com.openhis.web.doctorstation.dto.ReservationRecordDto;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 医生站-预约记录 controller
 */
@RestController
@RequestMapping("/doctor-station/reservation-record")
@Slf4j
@AllArgsConstructor
public class ReservationRecordController {

    private final IReservationRecordAppService iReservationRecordAppService;

    /**
     * 保存预约记录
     * 
     * @param reservationRecordDto 预约记录dto
     * @return 结果
     */
    @PostMapping(value = "/save-reservation")
    public R<?> saveReservation(@RequestBody ReservationRecordDto reservationRecordDto) {
        return iReservationRecordAppService.saveReservation(reservationRecordDto);
    }

    /**
     * 编辑预约记录
     *
     * @param reservationRecordDto 预约记录dto
     * @return 结果
     */
    @PutMapping(value = "/edit-reservation")
    public R<?> editReservation(@RequestBody ReservationRecordDto reservationRecordDto) {
        return iReservationRecordAppService.editReservation(reservationRecordDto);
    }

    /**
     * 删除预约记录
     * 
     * @param id id
     * @return 结果
     */
    @DeleteMapping("/del-reservation")
    public R<?> delReservation(@RequestParam Long id) {
        return iReservationRecordAppService.delReservation(id);
    }

    /**
     * 查询 预约记录
     * 
     * @param reservationRecordDto 查询条件
     * @param searchKey 模糊查询关键字
     * @param pageNo 当前页
     * @param pageSize 每页多少条
     * @param request 请求
     * @return 预约记录
     */
    @GetMapping(value = "/reservation-info")
    public R<?> getReservationInfo(ReservationRecordDto reservationRecordDto,
        @RequestParam(value = "searchKey", defaultValue = "") String searchKey,
        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
        return R.ok(iReservationRecordAppService.getReservationInfo(reservationRecordDto, searchKey, pageNo, pageSize,
            request));
    }

}
