package com.openhis.web.appointmentmanage.controller;

import com.core.common.core.domain.R;
import com.openhis.appointmentmanage.domain.ClinicRoom;
import com.openhis.web.appointmentmanage.appservice.IClinicRoomAppService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/appoinment/clinic-room")
public class ClinicRoomController {

    @Resource
    private IClinicRoomAppService clinicRoomAppService;

    /**
     * 分页查询诊室列表
     * @param pageNum 页码
     * @param pageSize 每页条数
     * @param orgName 卫生机构名称
     * @param roomName 诊室名称
     * @return 分页查询结果
     */
    @GetMapping("/page")
    public R<?> selectClinicRoomPage(
            @RequestParam(required = true) Integer pageNum,
            @RequestParam(required = true) Integer pageSize,
            @RequestParam(required = false) String orgName,
            @RequestParam(required = false) String roomName) {
        return clinicRoomAppService.selectClinicRoomPage(pageNum, pageSize, orgName, roomName);
    }

    /**
     * 查询诊室详情
     * @param id 诊室ID
     * @return 诊室详情
     */
    @GetMapping("/{id}")
    public R<?> selectClinicRoomById(@PathVariable Long id) {
        return clinicRoomAppService.selectClinicRoomById(id);
    }

    /**
     * 新增诊室
     * @param clinicRoom 诊室信息
     * @return 新增结果
     */
    @PostMapping
    public R<?> insertClinicRoom(@RequestBody ClinicRoom clinicRoom) {
        return clinicRoomAppService.insertClinicRoom(clinicRoom);
    }

    /**
     * 更新诊室
     * @param clinicRoom 诊室信息
     * @return 更新结果
     */
    @PutMapping
    public R<?> updateClinicRoom(@RequestBody ClinicRoom clinicRoom) {
        return clinicRoomAppService.updateClinicRoom(clinicRoom);
    }

    /**
     * 删除诊室
     * @param id 诊室ID
     * @return 删除结果
     */
    @DeleteMapping("/{id}")
    public R<?> deleteClinicRoomById(@PathVariable Long id) {
        return clinicRoomAppService.deleteClinicRoomById(id);
    }
}
