package com.xinelu.manage.controller.patientvisitoperation;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.manage.domain.patientvisitoperation.PatientVisitOperation;
import com.xinelu.manage.service.patientvisitoperation.IPatientVisitOperationService;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.common.core.page.TableDataInfo;

/**
 * 患者就诊手术记录信息Controller
 *
 * @author xinelu
 * @date 2024-02-26
 */
@Api(tags = "患者就诊手术记录控制器")
@RestController
@RequestMapping("/manage/visitOperation")
public class PatientVisitOperationController extends BaseController {
    @Resource
    private IPatientVisitOperationService patientVisitOperationService;

	/**
	 * 查询患者就诊手术记录信息列表
	 */
	@ApiOperation("分页查询患者就诊手术记录信息列表")
	@PreAuthorize("@ss.hasPermi('manage:visit:list')")
	@GetMapping("/list")
    public TableDataInfo list(PatientVisitOperation patientVisitOperation) {
        startPage();
        List<PatientVisitOperation> list = patientVisitOperationService.selectPatientVisitOperationList(patientVisitOperation);
        return getDataTable(list);
    }

	/**
	 * 根据患者就诊记录查询患者入院记录信息
	 */
	@ApiOperation("根据患者就诊记录查询患者入院记录信息")
	@GetMapping("/getByVisitRecord/{patientVisitRecordId}")
	public AjaxResult getByVisitRecord(@PathVariable("patientVisitRecordId") Long patientVisitRecordId) {
		return AjaxResult.success(patientVisitOperationService.getByVisitRecord(patientVisitRecordId));
	}

    /**
     * 导出患者就诊手术记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:visit:export')")
    @Log(title = "患者就诊手术记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientVisitOperation patientVisitOperation) {
        List<PatientVisitOperation> list = patientVisitOperationService.selectPatientVisitOperationList(patientVisitOperation);
        ExcelUtil<PatientVisitOperation> util = new ExcelUtil<PatientVisitOperation>(PatientVisitOperation. class);
        util.exportExcel(response, list, "患者就诊手术记录信息数据");
    }

    /**
     * 获取患者就诊手术记录信息详细信息
     */
    @ApiOperation("获取患者就诊手术记录信息详细信息")
    @PreAuthorize("@ss.hasPermi('manage:visit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientVisitOperationService.selectPatientVisitOperationById(id));
    }

    /**
     * 新增患者就诊手术记录信息
     */
    @ApiOperation("新增患者就诊手术记录信息")
    @PreAuthorize("@ss.hasPermi('manage:visit:add')")
    @Log(title = "患者就诊手术记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientVisitOperation patientVisitOperation) {
        return toAjax(patientVisitOperationService.insertPatientVisitOperation(patientVisitOperation));
    }

    /**
     * 修改患者就诊手术记录信息
     */
    @ApiOperation("修改患者就诊手术记录信息")
    @PreAuthorize("@ss.hasPermi('manage:visit:edit')")
    @Log(title = "患者就诊手术记录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientVisitOperation patientVisitOperation) {
        return toAjax(patientVisitOperationService.updatePatientVisitOperation(patientVisitOperation));
    }

    /**
     * 删除患者就诊手术记录信息
     */
    @ApiOperation("删除患者就诊手术记录信息")
    @PreAuthorize("@ss.hasPermi('manage:visit:remove')")
    @Log(title = "患者就诊手术记录信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientVisitOperationService.deletePatientVisitOperationByIds(ids));
    }
}
