package cn.iocoder.yudao.module.system.controller.admin.biz;

import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.RoundRecordPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.WardRoundRecordDO;
import cn.iocoder.yudao.module.system.service.biz.WardRoundRecordService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;


import javax.annotation.security.PermitAll;
import javax.validation.*;



import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;



@Tag(name = "管理后台 - 查房记录")
@RestController
@RequestMapping("/ward/roundRecord")
@Validated
public class WardRoundRecordController {

    @Resource
    private WardRoundRecordService roundRecordService;

    @PostMapping("/create")
    @Operation(summary = "创建查房记录")
    @TenantIgnore
    @PermitAll
    public CommonResult<Boolean> createRoundRecord(@RequestBody WardRoundRecordDO createReqVO) {
        roundRecordService.createRoundRecord(createReqVO);
        return success(true);
    }

    @PutMapping("/update")
    @Operation(summary = "更新查房记录")
    @TenantIgnore
    public CommonResult<Boolean> updateRoundRecord(@RequestBody WardRoundRecordDO updateReqVO) {
        roundRecordService.updateRoundRecord(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除查房记录")
    @Parameter(name = "id", description = "编号", required = true)
    @TenantIgnore
    public CommonResult<Boolean> deleteRoundRecord(@RequestParam("id") Integer id) {
        roundRecordService.deleteRoundRecord(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得查房记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @TenantIgnore
    public CommonResult<WardRoundRecordDO> getRoundRecord(@RequestParam("id") Integer id) {
        WardRoundRecordDO roundRecord = roundRecordService.getRoundRecord(id);
        return success(roundRecord);
    }

    @GetMapping("/page")
    @Operation(summary = "获得查房记录分页")
    @TenantIgnore
    public CommonResult<PageResult<WardRoundRecordDO>> getRoundRecordPage(@Valid RoundRecordPageReqVO pageReqVO) {
        PageResult<WardRoundRecordDO> pageResult = roundRecordService.getRoundRecordPage(pageReqVO);
        return success(pageResult);
    }

//    @GetMapping("/export-excel")
//    @Operation(summary = "导出查房记录 Excel")
//    @PreAuthorize("@ss.hasPermission('ward:round-record:export')")
//    @ApiAccessLog(operateType = EXPORT)
//    public void exportRoundRecordExcel(@Valid RoundRecordPageReqVO pageReqVO,
//              HttpServletResponse response) throws IOException {
//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
//        List<RoundRecordDO> list = roundRecordService.getRoundRecordPage(pageReqVO).getList();
//        // 导出 Excel
//        ExcelUtils.write(response, "查房记录.xls", "数据", RoundRecordRespVO.class,
//                        BeanUtils.toBean(list, RoundRecordRespVO.class));
//    }

}