package com.ruoyi.web.modules.diagnosis.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.modules.diagnosis.domain.BizServiceAppointment;
import com.ruoyi.web.modules.diagnosis.service.IBizOrgMyAppointmentService;

/**
 * 我的预约（机构）
 */
@RestController
@RequestMapping("/diseaseTreatment/myAppointment/org")
public class BizOrgMyAppointmentController extends BaseController
{
    @Autowired
    private IBizOrgMyAppointmentService bizOrgMyAppointmentService;

    @PreAuthorize("@ss.hasPermi('diseaseTreatment:orgMyAppointment:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizServiceAppointment query)
    {
        startPage();
        List<BizServiceAppointment> list = bizOrgMyAppointmentService.selectOrgAppointmentList(query,
                SecurityUtils.getUserId());
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('diseaseTreatment:orgMyAppointment:query')")
    @Log(title = "我的预约（机构）查看详情", businessType = BusinessType.OTHER)
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizOrgMyAppointmentService.selectOrgAppointmentById(id, SecurityUtils.getUserId()));
    }

    @PreAuthorize("@ss.hasPermi('diseaseTreatment:orgMyAppointment:complete')")
    @Log(title = "我的预约（机构）完成接诊", businessType = BusinessType.UPDATE)
    @PostMapping("/complete/{id}")
    public AjaxResult complete(@PathVariable("id") Long id)
    {
        return toAjax(bizOrgMyAppointmentService.complete(id, SecurityUtils.getUserId(), getUsername()));
    }
}
