package com.xinelu.manage.controller.operationInfo;

import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.operationInfo.OperationInfo;
import com.xinelu.manage.dto.operationinfo.OperationInfoDto;
import com.xinelu.manage.service.operationInfo.IOperationInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 手术信息Controller
 *
 * @author xinelu
 * @date 2024-02-26
 */
@Api(tags = "手术信息控制器")
@RestController
@RequestMapping("/manage/operationInfo")
public class OperationInfoController extends BaseController {
    @Resource
    private IOperationInfoService operationInfoService;

    /**
     * 查询手术信息列表
     */
    @ApiOperation("查询手术信息列表")
    @PreAuthorize("@ss.hasPermi('operationInfo:operationInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperationInfoDto operationInfo) {
        startPage();
        List<OperationInfo> list = operationInfoService.selectOperationInfoList(operationInfo);
        return getDataTable(list);
    }

    /**
     * 导出手术信息列表
     */
    @ApiOperation("导出手术信息列表")
    @PreAuthorize("@ss.hasPermi('operationInfo:operationInfo:export')")
    @Log(title = "手术信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperationInfoDto operationInfo) {
        List<OperationInfo> list = operationInfoService.selectOperationInfoList(operationInfo);
        ExcelUtil<OperationInfo> util = new ExcelUtil<OperationInfo>(OperationInfo.class);
        util.exportExcel(response, list, "手术信息数据");
    }

    /**
     * 获取手术信息详细信息
     */
    @ApiOperation("获取手术信息详细信息")
    @PreAuthorize("@ss.hasPermi('operationInfo:operationInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(operationInfoService.selectOperationInfoById(id));
    }

    /**
     * 新增手术信息
     */
    @ApiOperation("新增手术信息")
    @PreAuthorize("@ss.hasPermi('operationInfo:operationInfo:add')")
    @Log(title = "手术信息", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody OperationInfo operationInfo) {
        return toAjax(operationInfoService.insertOperationInfo(operationInfo));
    }

    /**
     * 修改手术信息
     */
    @ApiOperation("修改手术信息")
    @PreAuthorize("@ss.hasPermi('operationInfo:operationInfo:edit')")
    @Log(title = "手术信息", businessType = BusinessType.UPDATE)
    @PutMapping(value = "/edit")
    public AjaxResult edit(@RequestBody OperationInfo operationInfo) {
        return toAjax(operationInfoService.updateOperationInfo(operationInfo));
    }

    /**
     * 删除手术信息
     */
    @ApiOperation("删除手术信息")
    @PreAuthorize("@ss.hasPermi('operationInfo:operationInfo:remove')")
    @Log(title = "手术信息", businessType = BusinessType.DELETE)
    @DeleteMapping("remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(operationInfoService.deleteOperationInfoByIds(ids));
    }

}
